import network sta_if = network.WLAN(network.STA_IF) ap_if = network.WLAN(network.AP_IF) from machine import Pin, SPI import upcd8544 spi = SPI(1, baudrate=80000000, polarity=0, phase=0) RST = Pin(2) CE = Pin(15) DC = Pin(0) BC = Pin(16) lcd = upcd8544.PCD8544(spi, RST, CE, DC, BC) import framebuf width = 84 height = 48 pages = height // 8 buffer = bytearray(pages * width) framebuf = framebuf.FrameBuffer1(buffer, width, height) framebuf.fill(0) framebuf.text("EIK ROBO", 10, 0, 1) lcd.data(buffer) import time framebuf.text("Wifi conn", 5, 10, 1) lcd.data(buffer) s = 0 dots = ('|', '/', '-', '\\') while not sta_if.isconnected(): framebuf.fill_rect(30, 20, 8, 8, 0) framebuf.text(dots[s], 30, 20, 1) print(dots[s]) lcd.data(buffer) s += 1 if s == len(dots): s = 0 time.sleep(0.05) framebuf.fill_rect(30, 20, 8, 8, 0) ip = sta_if.ifconfig()[0].split(".") framebuf.text("IP:"+ip[0]+"."+ip[1], 0, 20, 1) framebuf.text("."+ip[2]+"."+ip[3], 16, 30, 1) print(sta_if.ifconfig()) lcd.data(buffer) framebuf.text("get time", 0, 40, 1) lcd.data(buffer) import ntptime retry = 5 while retry: try: ntptime.settime() break except: retry -= 1 time.sleep(0.5) if retry == 0: framebuf.fill_rect(0, 40, width, 8, 0) framebuf.text("error", 0, 40, 1) time.sleep(5) import utime while True: framebuf.fill_rect(0, 40, width, 8, 0) t = time.localtime() timezone = +2 hours = t[3]+timezone if hours > 23: hours -= 24 framebuf.text(str(hours)+":"+str(t[4])+":"+str(t[5]), 12, 40, 1) lcd.data(buffer) time.sleep(1)