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 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 = '' 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") easydraw.nickname() on_usb = pm.usb_attached() vBatt = badge.battery_volt_sense() vBatt += vDrop charging = badge.battery_charge_status() easydraw.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)
def drawTask(onSleep=False): global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available if gui_redraw or onSleep: gui_redraw = False ugfx.clear(ugfx.WHITE) currHeight = 0 if gui_app_current < 0: if cfg_nickname: currHeight += easydraw.nickname() currHeight += 4 ugfx.line(0, currHeight, ugfx.width(), currHeight, ugfx.BLACK) currHeight += 4 app_height = ugfx.height() - 16 - currHeight logoHeight = drawLogo(currHeight, app_height, True) else: display_app(currHeight) if onSleep: info = 'Sleeping...' #elif badge.safe_mode(): # info = "Recovery mode" #elif not rtc.isSet(): # info = "Clock not set" elif ota_available: info = "Update available!" #elif wifi_status_curr: # info = "WiFi connected" else: info = 'Press START' ugfx.line(0, ugfx.height() - 16, ugfx.width(), ugfx.height() - 16, ugfx.BLACK) easydraw.disp_string_right_bottom(0, info) if len(gui_apps) > 0: drawPageIndicator(len(gui_apps), gui_app_current) ugfx.flush(ugfx.LUT_NORMAL) return 1000
def drawTask(onSleep=False): global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available if gui_redraw or onSleep: gui_redraw = False display.drawFill(0xFFFFFF) currHeight = 0 noLine = False if gui_app_current < 0: if cfg_logo and cfg_nickname: currHeight += easydraw.nickname() currHeight += 4 display.drawLine(0, currHeight, display.width() - 1, currHeight, 0x000000) currHeight += 4 app_height = display.height() - 16 - currHeight logoHeight = drawLogo(currHeight, app_height, True) if logoHeight > 0: noLine = True if logoHeight < 1 and cfg_logo: title = "BADGE.TEAM" subtitle = "PLATFORM" logoHeight = display.getTextHeight( title, "permanentmarker22") + display.getTextHeight( subtitle, "fairlight12") display.drawText( (display.width() - display.getTextWidth(title, "permanentmarker22")) // 2, currHeight + (app_height - logoHeight) // 2, title, 0x000000, "permanentmarker22") currHeight += display.getTextHeight(title, "permanentmarker22") display.drawText( (display.width() - display.getTextWidth(subtitle, "fairlight12")) // 2, currHeight + (app_height - logoHeight) // 2, subtitle, 0x000000, "fairlight12") currHeight += display.getTextHeight(subtitle, "fairlight12") if (not cfg_logo) and cfg_nickname: noLine = True nick = machine.nvs_getstr("owner", "name") if nick == None: nick = "BADGE.TEAM" currHeight += ( display.getTextHeight(nick, "permanentmarker22") // 2) - 8 display.drawText( (display.width() - display.getTextWidth(nick, "permanentmarker22")) // 2, currHeight, nick, 0x000000, "permanentmarker22") currHeight += display.getTextHeight(nick, "permanentmarker22") else: display_app(currHeight) if onSleep: info = 'Sleeping...' #elif not rtc.isSet(): # info = "RTC not available" elif ota_available: info = "Update available!" #elif wifi_status_curr: # info = "WiFi connected" else: info = 'Press START' if not noLine: display.drawLine(0, display.height() - 16, display.width(), display.height() - 16, 0x000000) easydraw.disp_string_right_bottom(0, info) if len(gui_apps) > 0: drawPageIndicator(len(gui_apps), gui_app_current) if cfg_greyscale: display.flush(display.FLAG_LUT_GREYSCALE) else: display.flush(display.FLAG_LUT_NORMAL) return 1000