9
9
import adafruit_hashlib as hashlib
10
10
import adafruit_touchscreen
11
11
from adafruit_button import Button
12
- from adafruit_display_shapes . rect import Rect
12
+ from adafruit_progressbar import ProgressBar
13
13
from adafruit_display_text .label import Label
14
14
from adafruit_esp32spi import adafruit_esp32spi
15
15
from adafruit_ntp import NTP
16
16
from adafruit_pyportal import PyPortal
17
17
18
18
19
19
# Background Color
20
- BACKGROUND = 0x059ACE
20
+ BACKGROUND = 0x0
21
21
22
22
# Button color
23
23
BTN_COLOR = 0xFFFFFF
@@ -247,9 +247,10 @@ def generate_otp(int_input, secret_key, digits=6):
247
247
label_timer .y = 15
248
248
splash .append (label_timer )
249
249
250
- # timer bar
251
- rect = Rect (0 , 120 , 0 , 30 , fill = 0xFF0000 )
252
- splash .append (rect )
250
+ # create a new progress bar
251
+ progress_bar = ProgressBar (display .width // 5 , 125 , 200 , 30 )
252
+
253
+ splash .append (progress_bar )
253
254
254
255
# how long to stay on if not in always_on mode
255
256
countdown = ON_SECONDS
@@ -274,13 +275,13 @@ def generate_otp(int_input, secret_key, digits=6):
274
275
print ('countdown:' , countdown )
275
276
276
277
# change the timer bar's color if text is about to refresh
278
+ # TODO: this needs to be added to progressbar!
277
279
fill_color = 0xFFFFFF
278
280
if countdown < 5 :
279
281
fill_color = 0xFF0000
280
282
# "animate" the timer-bar
281
- splash .remove (rect )
282
- rect = Rect (0 , 120 , countdown * 12 , 30 , fill = fill_color )
283
- splash .append (rect )
283
+ progress_bar .progress = countdown
284
+
284
285
285
286
# poll the touchscreen
286
287
p = ts .touch_point
0 commit comments