From 327643f73c27266536be99d7dec326b2b3749944 Mon Sep 17 00:00:00 2001 From: David Todd Date: Mon, 27 Jan 2020 18:57:40 -0600 Subject: [PATCH] Clear screen with more efficient timeout --- pixo/wifi.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pixo/wifi.py b/pixo/wifi.py index ad31a8c..0d00871 100644 --- a/pixo/wifi.py +++ b/pixo/wifi.py @@ -67,12 +67,9 @@ if not STA_IF.isconnected(): connect(AP_IF, 'Access Point', creds.AP_SSID, creds.AP_PASSWORD) -# If anything is connected, and it's been at least 30 seconds, clear the board -def timeout(): - if is_connected(STA_IF) or is_connected(AP_IF) and time.time() - time_connected > 30: - Pixo().transition_image_dissolve() - tim.deinit() - -# Check if the timeout is satisfied, every 30s -tim = Timer(-1) -tim.init(period=30000, mode=Timer.PERIODIC, callback=lambda t:timeout()) +# Clear the board with dissolve animation after 15 seconds +# We'll assume that the board is showing a green wifi logo +Timer(-1).init( + period=15000, + mode=Timer.ONE_SHOT, + callback=lambda t: Pixo().transition_image_dissolve())