# Wemos D1 Mini / ESP8266import uasyncio as asyncio
import tm1638
from machine import Pin
asyncdeftm1638_task(stb_pin, clk_pin, dio_pin):
tm = tm1638.TM1638(stb=Pin(stb_pin), clk=Pin(clk_pin), dio=Pin(dio_pin))# every 2nd LED on
tm.leds(0b01010101)# all LEDs off
tm.leds(0)# segments
tm.show('cool')
tm.show('abcdefgh')
tm.number(-1234567)
tm.number(1234)
tm.number(5678,4)
tm.hex(0xdeadbeef)# dim both LEDs and segments
tm.brightness(0)# all LEDs and segments off
tm.clear()# get which buttons are pressed
tm.keys()defmain():
loop = asyncio.get_event_loop()
loop.create_task(tm1638_task(stb_pin=13, clk_pin=14, dio_pin=12))
loop.run_forever()if __name__ =='__main__':
main()