Toggle Navigation
Hatchery
Eggs
Clock
__init__.py
Login
Register
__init__.py
Content
import system, badge, ugfx, wifi, utime, samd BACKLIGHT = 255 def action_backlight(pushed): global BACKLIGHT if pushed: if BACKLIGHT == 255: BACKLIGHT = 0 else: BACKLIGHT = 255 samd.backlight(BACKLIGHT) def action_exit(pushed): if pushed: # go back to the home screen system.home() def show_clock(y=20, font='Roboto_BlackItalic24', color=ugfx.BLACK): badge.init() # correct time will be fetched from the NTP server - must have network connectivity wifi.ntp(False) while True: ugfx.clear() time_tup = utime.localtime(int(utime.time())) time_str = '%02d:%02d' % (time_tup[3], time_tup[4]) date_str = '%02d/%02d/%4d' % (time_tup[2], time_tup[1], time_tup[0]) width = ugfx.get_string_width(time_str, font) ugfx.string(int((128 - width)/2), y, time_str, font, color) ugfx.string(0, 0, date_str, 'Roboto_Regular12', color) ugfx.flush() utime.sleep(1) # sleep for 30 seconds #utime.sleep(30) #system.sleep(30*1000) def main(): ugfx.input_init() ugfx.input_attach(ugfx.JOY_RIGHT, action_backlight) ugfx.input_attach(ugfx.BTN_B, action_exit) ugfx.input_attach(ugfx.BTN_START, action_exit) show_clock() #sys.stdin.read(1) #Wait for any key #action_exit(True) main()