From a14e92ba08ffe83ffcb90fb57e0e2a37d26f9b37 Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Wed, 14 Aug 2024 19:01:31 +0100 Subject: [PATCH] Use supervisor.reload instead of microcontroller.reset as it's broken in 9.1.1 with tinyUF2 0.18.2 --- .../Qualia_820x320_IO_Countdown/code.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CircuitPython_Day_2024_Projects/Qualia_820x320_IO_Countdown/code.py b/CircuitPython_Day_2024_Projects/Qualia_820x320_IO_Countdown/code.py index 66f250d4e..9e369cba0 100644 --- a/CircuitPython_Day_2024_Projects/Qualia_820x320_IO_Countdown/code.py +++ b/CircuitPython_Day_2024_Projects/Qualia_820x320_IO_Countdown/code.py @@ -8,7 +8,7 @@ import wifi import board import displayio -import microcontroller +import supervisor import adafruit_connection_manager import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP @@ -113,9 +113,13 @@ total_seconds = time.mktime(now) refresh_clock = ticks_add(refresh_clock, refresh_timer) except Exception as e: # pylint: disable=broad-except - print("Some error occured, retrying via reset in 15seconds! -", e) - time.sleep(15) - microcontroller.reset() + print("Some error occured, retrying via supervisor.reload in 5seconds! -", e) + time.sleep(5) + # Normally calling microcontroller.reset() would be the way to go, but due to + # a bug causing a reset into tinyUF2 bootloader mode we're instead going to + # disconnect wifi to ensure fresh connection + use supervisor.reload() + wifi.radio.enabled = False + supervisor.reload() if ticks_diff(ticks_ms(), clock_clock) >= clock_timer: remaining = time.mktime(event_time) - total_seconds