Esempio n. 1
0
def loadOnline():
    try:
        import wifisetup
        wifisetup.auto_connect()
        global Menu
        clear_bg(0x222222)
        M5Title(title="You are Online. Congratulations!",
                fgcolor=0xFFFFFF,
                bgcolor=0x0000FF)
        Menu.maximo = 3
        Menu.sair = 0
        Menu.escolha = 1
        clearcolors()
        color[1] = 0x0007fd
        while True:
            if Menu.sair == 1:
                Menu.load = "4." + str(Menu.escolha)
                break
            M5TextBox(25, 70, "Upload Save", lcd.FONT_Default, color[1])
            M5TextBox(25, 90, "Download Save", lcd.FONT_Default, color[2])
            M5TextBox(25, 110, "Update Game & Restart", lcd.FONT_Default,
                      color[3])
            escolher()

    except:
        clear_bg(0x222222)
        M5TextBox(25, 106, "No internet available", lcd.FONT_Default, 0x0000FF)
        time.sleep(3)
        Menu.load = "startMenu"
import gc
import uos as os
import ubinascii
from m5stack import lcd, node_id
from utils import *
from config import __VERSION__
import machine

wait(0.5)
# Connect network
import wifisetup
wifisetup.auto_connect()

# rtc = machine.RTC()
# rtc.ntp_sync(server="cn.ntp.org.cn", tz="CET-8CEST")

# Reset apikey
if buttonA.isPressed():
    try:
        machine.nvs_erase('apikey.pem')
    except:
        pass

# Read apikey
apikey = machine.nvs_getstr('apikey.pem')
if apikey == None:
    apikey = ubinascii.hexlify(os.urandom(4)).decode('utf8')  #Random APIKEY
    apikey = apikey.upper()
    machine.nvs_setstr('apikey.pem', apikey)

# M5Cloud