Toggle Navigation
Hatchery
Eggs
Menu++
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import os import display import buttons import color import utime with display.open() as disp: disp.clear() disp.print(" OVERWRITE ", posx=3, posy=0, fg=color.YELLOW) disp.print(" /menu.py? ", posx=3, posy=20, fg=color.YELLOW) disp.print("No", posx=120, posy=60, fg=color.RED) disp.print("Yes", posy=60, fg=[100,100,100]) disp.update() timeout = -500 wait = 1 skip = 0 while wait: btn = buttons.read() timeout += 1 if timeout == 0: disp.print("Yes", posy=60, fg=color.GREEN) disp.update() if timeout == 1000: skip = 1 if btn & buttons.BOTTOM_LEFT: if timeout < 0: skip = 1 disp.clear() disp.print("You decided", posx=3, posy=0, fg=color.MAGENTA) disp.print(" too fast! ", posx=3, posy=20, fg=color.MAGENTA) disp.print("Do you have", posx=3, posy=40, fg=color.MAGENTA) disp.print(" a backup? ", posx=3, posy=60, fg=color.MAGENTA) disp.update() utime.sleep(5) else: wait = 0 if btn & buttons.BOTTOM_RIGHT: skip = 1 if skip: disp.clear() disp.print(" Nothing ", posy=20, fg=color.WHITE) disp.print(" changed ", posy=40, fg=color.WHITE) disp.update() utime.sleep(3) os.exit() utime.sleep_ms(10) disp.clear() disp.print("Installing", posx = 10, posy=20, fg=color.CYAN) disp.print("Menu++ ...", posx = 10, posy=40, fg=color.CYAN) disp.update() try: os.unlink('/menu.py') os.rename('/apps/menu/menu.py', '/menu.py') for file in os.listdir('/apps/menu/'): os.unlink('/apps/menu/'+file) os.unlink('/apps/menu') disp.clear() disp.print(" Menu++ ", posx = 10, posy=20, fg=color.GREEN) disp.print("installed.", posx = 10, posy=40, fg=color.GREEN) disp.update() utime.sleep(3) os.exit() except: disp.clear() disp.print(" Install ", posx = 3, posy=20, fg=color.RED) disp.print(" failed ", posx = 10, posy=40, fg=color.RED) disp.update() while True: utime.sleep(1)