# os.remove(confFile) #except: pass try: update except: update = True abus = 'i2c' atype = 'display' print("%s %s MySense configuration." % ('Updating' if update else 'No update', atype)) import ConfigJson config = {abus: {}} MyConfig = ConfigJson.MyConfig(debug=debug) config[abus] = MyConfig.getConfig(abus=abus) FndDevices = [] if config[abus]: print("Found archived %s configuration for:" % abus) for dev in config[abus].keys(): if dev == 'updated': continue FndDevices.append(dev) print("\t%s: " % dev, config[abus][dev]) if not atype in FndDevices: print("Sensor %s not found in conf %s file." % (atype, confFile)) if atype in FndDevices and update: del config[abus][dev] FndDevices.remove(atype) import whichI2C as DEV
If no accu is attached and deepsleep pin is enabled flashed config file will be cleared. ''' from machine import deepsleep, wake_reason, PWRON_WAKE wokeUp = wake_reason()[0] != PWRON_WAKE if wokeUp: print("Woke up from deepsleep.") else: print("Cold reboot") ################## json flashed configuration # roll in archive configuration try: import ConfigJson except: print("Missing library led and/or ConfigJson") sys.exit() MyConfig = ConfigJson.MyConfig(archive=(not wokeUp), debug=False) config = MyConfig.getConfig() # configuration if config: print("Got config from flash: %s" % str(config)) ####################### RGB led import sys from time import time, sleep # Turn off hearbeat LED import pycom pycom.heartbeat(False) LED = None try: import led # show errors LED = led.LED() except: pass