def load(): cfg_term_menu = machine.nvs_get_u8('splash', 'term_menu') if cfg_term_menu == None: cfg_term_menu = True cfg_wifi = machine.nvs_get_u8('splash', 'wifi') # Allow the use of WiFi on the splash screen if cfg_wifi == None: cfg_wifi = False # If not set the use of WiFi is not allowed cfg_services = machine.nvs_get_u8('splash', 'services') # Enable splash screen services (fun but dangerous) if cfg_services == None: cfg_services = False # If not set services are disabled cfg_logo = machine.nvs_getstr('splash', 'logo') # Filename of a PNG image to show on the splash screen cfg_nickname = machine.nvs_get_u8('splash', 'nickname') # Show the nickname of the user on the splash screen if cfg_nickname == None: cfg_nickname = True # If not set we want to show the nickname cfg_greyscale = machine.nvs_get_u8('splash', 'greyscale') # Use greyscale mode if cfg_greyscale == None: cfg_greyscale = False # Disabled by default cfg_led_animation = machine.nvs_getstr('splash', 'ledApp') # Application which shows a LED animation while the splash screen is visible return cfg_term_menu, cfg_wifi, cfg_services, cfg_logo, cfg_nickname, cfg_greyscale, cfg_led_animation
def pm_task(): ''' The power management task [internal function] ''' global requestedStandbyTime global timeout global disabled if disabled: return timeout idleTime = virtualtimers.idle_time() usbStayAwake = False try: import badge usbStayAwake = badge.usb_attached() and machine.nvs_get_u8( 'system', 'usb_stay_awake') except: pass if idleTime > 30000 and (not usbStayAwake): global onSleepCallback if not onSleepCallback == None: print("[Power management] Running onSleepCallback...") try: onSleepCallback(idleTime) except BaseException as e: print("[ERROR] An error occured in the on sleep callback.") sys.print_exception(e) system.sleep(idleTime, False) return timeout
def nvs_get_u8(space, item, default=None): if space == "badge": space = "system" res = machine.nvs_get_u8(space, item) if res == None: res = default return res
populate_options() # do a greyscale flush on start ugfx.flush(ugfx.GREYSCALE) start() def goToSleep(unused_variable=None): system.home() # Read configuration from NVS or apply default values cfg_term_menu = machine.nvs_get_u8( 'splash', 'term_menu') # Show a menu on the serial port instead of a prompt if cfg_term_menu == None: cfg_term_menu = True # If not set the menu is shown # Scheduler virtualtimers.activate(100) # Start scheduler with 100ms ticks virtualtimers.new(100, updateEink) # Terminal menu if cfg_term_menu: init_power_management() umenu = term_menu.UartMenu(system.home, pm, False, "< Back") umenu.main() #(Note: power management is disabled when the menu is disabled, to keep the python prompt clean and usefull)
else: app = rtc.read_string() if not app: if fc_level < 3: app = "factory_checks" else: app = machine.nvs_getstr("system", 'default_app') if not app: app = 'dashboard.home' del fc_level del __chk_recovery del rtc del recovery_button if app and not app == "shell": try: print("Starting app '%s'..." % app) system.__current_app__ = app if app: __import__(app) except KeyboardInterrupt: system.launcher() except BaseException as e: sys.print_exception(e) if not machine.nvs_get_u8("system", "ignore_crash"): print("Fatal exception in the running app!") system.crashedWarning() time.sleep(3) system.launcher()
except: samd = None if consts.INFO_HARDWARE_NAME == "Disobey 2019": COLOR_BG = 0xFFFFFF COLOR_FG = 0x000000 LOGO = b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x80\x00\x00\x00\x1a\x01\x00\x00\x00\x00W\xb8iC\x00\x00\x00\xf0IDAT\x18\xd3\x8d\xd1\xa1N\xc4@\x10\x06\xe0!\x88\xcaJ\xe4>\x06\xb8}\x1c,\x9e\xe4*\x10'O I\xe8C p7G\x10+\xf7\x01.\x17\x9a \xd6\\\xd2\xbdT\xdc4m\xe6g\xdb+\xbd\x80\x81\x91\x9f\x98\xfc\xf3\x0f\xe1\xd7\xd0\x1f\xa0\xa0\xfe\x02\x889\x1eP\x19\x98\t\\4zSl\xf2\x9eT,\xf5\x02\xe7\xd1\xc2>g\x91\x16b\x12\xd8\x04\x8d+y)\xa6[\x17\x03,=\x02\xd5\xec\xd4v\xeb\xb4\x03y\x82\xbd\xde\xb2\xeb\xad\xe2\x1bv\xb8\xe60\xc3\xcac\x8b\xd7\x01\xd0\x9d\xe1\x89?{*&\x88\xe61\xc1\x9b\xd0\xfd\x0c/\xd8r%Yw\x02\x8fc\x89\x8e\xa3`\x02\x87\xf0\x81\x86e\x06?\xc0\x91\xe5\x00\xbdL\xa0\x03\xf8\xbb3\xa4[\x10\xea\xa2N\x10\xc6\x1c#\x04xn#\x8dp@\x82\x06%\xb7\x15-\xf2\xb1\xa0w\xb9\x12\xb5\xdcT\x99\x9e\xc0\xc7\\\t\xec\xab\x9f%o\xec\xbf\xde\x00|\x01\x10\x96RtD\x90\x0f\xda\x00\x00\x00\x00IEND\xaeB`\x82" else: COLOR_BG = 0x000000 COLOR_FG = 0xFFFFFF LOGO = b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x80\x00\x00\x00\x1a\x01\x00\x00\x00\x00W\xb8iC\x00\x00\x00\xecIDAT\x18\xd3\x95\xd1\xa1N\x041\x10\x06\xe0\x7f\xd2f\xe7\xc4\xe6\xba\t\xa6\x82d\t\xb9\x07\xa8\xac \xdc\x9cC\xf0\x10K\x82D\x9c<\x81\xd8K\xf0X\x1e\xa7\x0e\x1e\xa3\x12Y\xb9\x82P\xba{\x9b\xbd\xe0`\xe4'\xfe\xcc\xfc\x03\xfcs\x08P\xdf\x80IxF\x1b\x11g\xf0&\xd2{\xbfM*\x13\x07(\x86w\xa8\x10\x1e\x06\x93\x8f\x1c\x0b\x84\x02\xb5\xef\xe4\xc0Q\xef\xfa\x11\x0e\x0e67\xe2)\xe8]\xc9@*pAo\xe2U(\x993\\\xe3C\xec\x02{\x87\r\xeeF\x80>\xc3\xa3\\\xaa\xdc\xcf`\xe2S\x81[\xce/\x0b\xdcc#-\x0f\xfa\x04\x0e\xab\x0eZ\x0cc\x06\x0f{\x85Zx\x017\xc2Jx\r\xfa*@#\xb8\xd73\x94[`\x9b\xbe)`\xa7=&\xb0pR\x99<\xc1\x1a\x05jtR\xb5\xf9\x98\xa6\x82n\xf8\x93)H\xdd\x0et\x02g\x12e\x88k\x7f\xf7\xbb\r\x7f|\xc4\x0f\xc0\xa9K\xfd1u\xb7\xde\x00\x00\x00\x00IEND\xaeB`\x82" stopThreads = False # Read configuration from NVS or apply default values cfg_term_menu = machine.nvs_get_u8('splash', 'term_menu') # Show a menu on the serial port instead of a prompt if cfg_term_menu == None: cfg_term_menu = True # If not set the menu is shown cfg_wifi = machine.nvs_get_u8('splash', 'wifi') # Allow the use of WiFi on the splash screen if cfg_wifi == None: cfg_wifi = False # If not set the use of WiFi is not allowed cfg_services = machine.nvs_get_u8('splash', 'services') # Enable splash screen services (fun but dangerous) if cfg_services == None: cfg_services = False # If not set services are disabled cfg_logo = machine.nvs_getstr('splash', 'logo') # Filename of a PNG image to show on the splash screen cfg_nickname = machine.nvs_get_u8('splash', 'nickname') # Show the nickname of the user on the splash screen if cfg_nickname == None:
start() init_power_management() # Install CZ countdown app to replace activities app # if not machine.nvs_getint('system', 'czcount_inst'): # if woezel.is_installed('campzone_2020_countdown'): # machine.nvs_setint('system', 'czcount_inst', 1) # else: # if uinterface.connect_wifi(): # uinstaller.install('campzone_2020_countdown') # # render_current_app() cfg_term_menu = machine.nvs_get_u8('splash', 'term_menu') if cfg_term_menu == None: cfg_term_menu = True if cfg_term_menu: menu = term_menu.UartMenu(deepsleep.start_sleeping, pm) print(gc.mem_free()) menu.main() else: print("Welcome!") print("Press CTRL+C to reboot directly to a Python prompt.") wait = True while wait: c = machine.stdin_get(1, 1) if c == "\x03" or c == "\x04": # CTRL+C or CTRL+D wait = False
import time, display, _thread, wifi, term, _buttons, machine, binascii, system from umqtt.simple import MQTTClient # System settings mac_address = wifi._STA_IF.config("mac") mqtt_hostname = "decennium-{}".format(binascii.hexlify(mac_address)) mqtt_server = machine.nvs_getstr("hsnl", "mqtt_server") or "hoera10jaar.revspace.nl" ota_allowed = machine.nvs_get_u8("hsnl", "ota_allowed") or 1 # Global state variables wifi_ap = False # Hackerspaces spaces = [ { "red": (0, 0), "grn": (3, 0), "channel": "leeuwarden", "state": 0 }, { "red": (0, 1), "grn": (3, 1), "channel": "amsterdam", "state": 0 }, { "red": (0, 2), "grn": (3, 2), "channel": "utrecht",
def load(): return machine.nvs_get_u8('system', 'eink.dev.type')