Esempio n. 1
0
import esp, machine, sys, system, os

esp.rtcmem_write(0, 0)
esp.rtcmem_write(1, 0)

#Application starting
app = esp.rtcmem_read_string()
if app:
    esp.rtcmem_write_string("")
else:
    if not machine.nvs_getint("system", 'factory_checked'):
        app = "factory_checks"
    else:
        app = machine.nvs_getstr("system", 'default_app')
        #if not app: #This generic set of modules has no default app
        #app = 'dashboard.home'

try:
    print("Starting app '%s'..." % app)
    system.__current_app__ = app
    if app:
        __import__(app)
except BaseException as e:
    print("Fatal exception in the running app!")
    sys.print_exception(e)
Esempio n. 2
0
# setup timezone
timezone = badge.nvs_get_str('system', 'timezone',
                             'CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00')
time.settimezone(timezone)

if badge.safe_mode():
    splash = 'splash'
else:
    splash = badge.nvs_get_str('boot', 'splash', 'splash')

if machine.reset_cause() != machine.DEEPSLEEP_RESET:
    print('[BOOT] Cold boot')
else:
    print("[BOOT] Wake from sleep")
    load_me = esp.rtcmem_read_string()
    if load_me:
        splash = load_me
        print("starting %s" % load_me)
        esp.rtcmem_write_string("")

try:
    if not splash == "shell":
        if splash.startswith('bpp '):
            splash = splash[4:len(splash)]
            badge.mount_bpp()
        elif splash.startswith('remfs '):
            splash = splash[6:len(splash)]
            badge.mount_remfs()
        elif splash.startswith('sdcard '):
            splash = splash[7:len(splash)]
    boxes = drawweather(r)

    ugfx.flush()

    try:
        boxes[0].destroy()
        boxes[1].destroy()
    except:
        print("no weather")


def wait_for_network():
    # Handle network connection
    if not wifi.sta_if.isconnected():
        while not wifi.sta_if.isconnected():
            log('Waiting for network')
            utime.sleep(1)
        log('Connected!')


clear_ghosting()
wait_for_network()
draw(makeRequest())
if (esp.rtcmem_read_string(2) != "niall"):
    esp.rtcmem_write_string("0", 0)
    esp.rtcmem_write_string("0", 1)
    esp.rtcmem_write_string("niall", 2)
# 35 mins, seems that works.
deepsleep.start_sleeping(2100 * 1000)