def draw(mode, goingToSleep=False): if mode: # We flush the buffer and wait ugfx.flush(ugfx.LUT_FULL) badge.eink_busy_wait() else: # We prepare the screen refresh ugfx.clear(ugfx.WHITE) if goingToSleep: info1 = 'Sleeping...' info2 = 'Press any key to wake up' else: info1 = 'Press start to open the launcher' if otac.available(False): info2 = 'Press select to start OTA update' else: info2 = '' l = ugfx.get_string_width(info1,"Roboto_Regular12") ugfx.string(296-l, 0, info1, "Roboto_Regular12",ugfx.BLACK) l = ugfx.get_string_width(info2,"Roboto_Regular12") ugfx.string(296-l, 12, info2, "Roboto_Regular12",ugfx.BLACK) easydraw.nickname() vUsb = badge.usb_volt_sense() vBatt = badge.battery_volt_sense() vBatt += vDrop charging = badge.battery_charge_status() easydraw.battery(vUsb, vBatt, charging) if vBatt>500: ugfx.string(52, 0, str(round(vBatt/1000, 1)) + 'v','Roboto_Regular12',ugfx.BLACK)
def wifiTask(): global wifi_status_prev, wifi_status_curr, gui_redraw, ota_available wifi_status_prev = wifi_status_curr wifi_status_curr = wifi.status() if wifi_status_curr: wifi.ntp(True) if wifi_status_curr != wifi_status_prev: #pm.feed() wifi_status_prev = wifi_status_curr gui_redraw = True if wifi_status_curr: ota_available = otacheck.available(True) return 1000
def wifiTask(): global wifi_status_prev, wifi_status_curr, gui_redraw, ota_available wifi_status_prev = wifi_status_curr wifi_status_curr = wifi.status() if wifi_status_curr: wifi.ntp(True) if wifi_status_curr != wifi_status_prev: print("WiFi status changed", wifi_status_curr) pm.feed() wifi_status_prev = wifi_status_curr gui_redraw = True if wifi_status_curr: ota_available = otacheck.available(True) print("Check OTA", ota_available) return 1000
def draw(mode, goingToSleep=False): ugfx.orientation(0) if mode: # We flush the buffer and wait ugfx.flush(ugfx.LUT_FULL) badge.eink_busy_wait() else: # We prepare the screen refresh ugfx.clear(ugfx.WHITE) if goingToSleep: info1 = 'Sleeping...' info2 = 'Press any key to wake up' else: info1 = 'Press start to open the launcher' if otac.available(False): info2 = 'Press select to start OTA update' else: info2 = '' def disp_string_right(y, s): l = ugfx.get_string_width(s, "Roboto_Regular12") ugfx.string(296 - l, y, s, "Roboto_Regular12", ugfx.BLACK) disp_string_right(0, info1) disp_string_right(12, info2) if badge.safe_mode(): disp_string_right(92, "Safe Mode - services disabled") disp_string_right(104, "Sleep disabled - will drain battery quickly") disp_string_right(116, "Press Reset button to exit") nickname() on_usb = pm.usb_attached() vBatt = badge.battery_volt_sense() vBatt += vDrop charging = badge.battery_charge_status() battery(on_usb, vBatt, charging) if vBatt > 500: ugfx.string(52, 0, str(round(vBatt / 1000, 1)) + 'v', 'Roboto_Regular12', ugfx.BLACK)
def draw(mode, goingToSleep=False): info1 = '' info2 = '' if mode: # We flush the buffer and wait ugfx.flush(ugfx.GREYSCALE) else: # We prepare the screen refresh ugfx.clear(ugfx.WHITE) easydraw.nickname() if goingToSleep: info = 'Sleeping...' elif badge.safe_mode(): info = "(Services disabled!)" elif otac.available(False): info = 'Update available!' else: info = '' easydraw.disp_string_right_bottom(0, info)
if splash.startswith('bpp '): splash = splash[4:len(splash)] badge.mount_bpp() elif splash.startswith('sdcard '): splash = splash[7:len(splash)] badge.mount_sdcard() __import__(splash) setupState = badge.nvs_get_u8('badge', 'setup.state', 0) if setupState == 0: #First boot print("First boot (start setup)...") __import__("setup") elif setupState == 1: # Second boot: Show sponsors print("Second boot (show sponsors)...") badge.nvs_set_u8('badge', 'setup.state', 2) spoc.show(True) elif setupState == 2: # Third boot: force OTA check print("Third boot (force ota check)...") badge.nvs_set_u8('badge', 'setup.state', 3) if not easywifi.failure(): otac.available(True) start() else: # Normal boot print("Normal boot... (" + str(machine.reset_cause()) + ")") if (machine.reset_cause() != machine.DEEPSLEEP_RESET): print("... from reset: checking for ota update") if not easywifi.failure(): otac.available(True) start()
def splash_input_select(pressed): if pressed: if otac.available(False): appglue.start_ota() pm.feed()
def splash_input_select(pressed): if pressed: if otac.available(False): system.ota() pm.feed()