def nvs_get_u16(space, item, default=None): if space == "badge": space = "system" res = machine.nvs_get_u16(space, item) if res == None: res = default return res
# SHA2017 "factory" tool # Does function as factory tool but also implements an upgrade path from our old firmware currentState = machine.nvs_getint('system', 'factory_checked') or 0 if currentState < 2: display.drawFill(0xFFFFFF) display.drawText(0, 0, "Welcome to the BADGE.TEAM platform firmware!", 0x000000, "7x5") display.drawText(0, 6, "Please wait while we're setting things up...", 0x000000, "7x5") display.flush() time.sleep(2) # Check if we have upgraded from a legacy firmware legacy_mpr0 = machine.nvs_get_u16("badge", "mpr121.base.0") if legacy_mpr0: display.drawFill(0xFFFFFF) display.drawText(0, 0, "Welcome to the BADGE.TEAM platform firmware!", 0x000000, "7x5") display.drawText(0, 6, "You have upgraded from an older firmware,", 0x000000, "7x5") display.drawText(0, 12, "now migrating your settings...", 0x000000, "7x5") display.flush() legacy_wifi_ssid = machine.nvs_getstr("badge", "wifi.ssid") legacy_wifi_password = machine.nvs_getstr("badge", "wifi.password") legacy_eink_type = machine.nvs_getstr("badge", "eink.dev.type") if currentState != 1:
import virtualtimers, system, sys, machine requestedStandbyTime = 0 onSleepCallback = None timeout = machine.nvs_get_u16('system', 'sleep') if not timeout: timeout = 10000 disabled = False enabled = False def disable(): global disabled, enabled disabled = True enabled = False kill() def enable(): global disabled, enabled, timeout if timeout < 1: #Disabled by setting return disabled = False enabled = True feed() def resume(): global disabled, enabled
def setDisplayOrientation(value=None): display.orientation(value or machine.nvs_get_u16('system', 'orientation') or consts.DEFAULT_ORIENTATION)
def getDefault(): res = machine.nvs_get_u16('system', 'orientation') if not res: res = version.default_orientation return res
def getDefault(): return machine.nvs_get_u16('system', 'orientation') or consts.DEFAULT_ORIENTATION
def default(rotateButtons=True): value = machine.nvs_get_u16('system', 'orientation') or consts.DEFAULT_ORIENTATION if rotateButtons: buttons.rotate(value) display.orientation(value)