pyonair / PyonAir-pycom

http://www.PyonAir.org
Apache License 2.0
8 stars 3 forks source link

Add led warning : this is a show stopper error #120

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

Add led warning : this is a show stopper error

===================Get a logger up and running asap!

https://github.com/pyonair/PyonAir-pycom/blob/9b8cd7f8cb06d958981c1841ca740c9ae1cf723d/code/main.py#L108


# pybytes = Pybytes(conf)
# pybytes.update_config('pybytes_autostart', False, permanent=True, silent=False, reconnect=False)
# pybytes.activate("eyJhIjoiMjc0MWQ0ZWItMmRmMS00Mzg0LTkxMGQtMzIzMGI5MTE2N2M3IiwicyI6InB5b25haXIiLCJwIjoicHlvbmFpciJ9")
# ===================Disable default wifi===================

try:
    wlan = network.WLAN()
    wlan.deinit()
    print("Disable WiFi")
# trunk-ignore(flake8/F841)
except Exception as e:
    print("Unable to disable WiFi")

# ===============LED
pycom.heartbeat(False)  # disable the heartbeat LED
pycom.rgbled(0x552000)  # flash orange to indicate startup

##
# ====== get time from RTC regardless -- better than default -- later we will try gps

rtc = RTC()
# Get time from RTC module
rtcClock = clock.get_time()
rtc.init(rtcClock)  # Set Pycom time to RTC time
print(str(rtcClock))

# =========================Mount SD card=======
try:
    sd = SD()
    os.mount(sd, "/sd")
    # TODO: Error catch , set led for no SD card
# trunk-ignore(flake8/F841)
except Exception as e:
    print("============================")
    print("===   SD did not mount   ===")
    print("============================")
    # TODO: Add led warning :  this is a show stopper error

# ================ thread memory default 4096
_thread.stack_size(4096 * 3)  # default is 4096 (and also min!)

# ===================Get a logger up and running asap!
logger_factory = LoggerFactory()
# TODO: Set log level to level in config file
fileNameStr = LOG_FILENAME + FILENAME_FMT.format(*time.gmtime()) + LOG_EXT
print(fileNameStr)
status_logger = logger_factory.create_status_logger(
    DEFAULT_LOG_NAME, level=loggingpycom.DEBUG, terminal_out=True, filename=fileNameStr
)

status_logger.info("Rebooted")

# =============Global config

config = Configuration.Configuration(status_logger)
status_logger.info("Config loaded")

# =============Init functions

init = initialisation(config, status_logger)

# =========================Get time sorted
# Get current time
rtc = RTC()
# Get time from RTC module
# rtc.init(clock.get_time())
no_time, update_time_later = init.initialise_time(
    rtc, False
)  # Dont use GPS , yet - just read RTC
update_time_later = True  # Force a gps fix
status_logger.info(
    "RTC read"
)  # TODO: fix GPS and time in general -- remember to roll over logs if big change

# ======================== Setup user interupt button
user_button = UserButton(status_logger)
pin_14 = Pin("P14", mode=Pin.IN, pull=Pin.PULL_DOWN)
pin_14.callback(Pin.IRQ_RISING | Pin.IRQ_FALLING, user_button.button_handler)

184cac4b2d932bf55ae02769bbb7d13852057ced