11import time
22
3- import adafruit_hashlib as hashlib
4- import adafruit_touchscreen
53import board
64import busio
5+ from digitalio import DigitalInOut
76import displayio
87import terminalio
8+
9+ import adafruit_hashlib as hashlib
10+ import adafruit_touchscreen
911from adafruit_button import Button
1012from adafruit_display_shapes .rect import Rect
1113from adafruit_display_text .label import Label
1214from adafruit_esp32spi import adafruit_esp32spi
1315from adafruit_ntp import NTP
1416from adafruit_pyportal import PyPortal
15- from digitalio import DigitalInOut
17+
1618
1719# Background Color
1820BACKGROUND = 0x059ACE
@@ -194,10 +196,10 @@ def generate_otp(int_input, secret_key, digits=6):
194196 try :
195197 esp .connect_AP (secrets ['ssid' ], secrets ['password' ])
196198 except RuntimeError as e :
197- print ("could not connect to AP, retrying: " , e )
199+ print ("Could not connect to AP, retrying: " , e )
198200 continue
199201
200- print ("Connected to SSID: " , secrets ['ssid' ])
202+ print ("Connected to " , secrets ['ssid' ])
201203
202204# Initialize the NTP object
203205ntp = NTP (esp )
@@ -206,7 +208,7 @@ def generate_otp(int_input, secret_key, digits=6):
206208# keep retrying until a valid time is returned
207209while not ntp .valid_time :
208210 ntp .set_time ()
209- print ("Failed to obtain time, retrying in 5 seconds..." )
211+ print ("Could not obtain NTP, re-fetching in 5 seconds..." )
210212 time .sleep (5 )
211213
212214# Get the current time in seconds since Jan 1, 1970
@@ -246,7 +248,7 @@ def generate_otp(int_input, secret_key, digits=6):
246248splash .append (label_timer )
247249
248250# timer bar
249- rect = Rect (0 , 150 , 0 , 20 , fill = 0xFF0000 )
251+ rect = Rect (0 , 120 , 0 , 30 , fill = 0xFF0000 )
250252splash .append (rect )
251253
252254# how long to stay on if not in always_on mode
@@ -277,7 +279,7 @@ def generate_otp(int_input, secret_key, digits=6):
277279 fill_color = 0xFF0000
278280 # "animate" the timer-bar
279281 splash .remove (rect )
280- rect = Rect (0 , 140 , countdown * 12 , 30 , fill = fill_color )
282+ rect = Rect (0 , 120 , countdown * 12 , 30 , fill = fill_color )
281283 splash .append (rect )
282284
283285 # poll the touchscreen
@@ -310,5 +312,5 @@ def generate_otp(int_input, secret_key, digits=6):
310312 # format and display the OTP
311313 label_secret .text = "{} {}" .format (str (otp )[0 :3 ], str (otp )[3 :6 ])
312314 # We'll update every 1/4 second, we can hash very fast so its no biggie!
313- countdown -= 0.1
314- time .sleep (0.1 )
315+ countdown -= 0.25
316+ time .sleep (0.25 )
0 commit comments