Skip to content

Commit 5a718e7

Browse files
author
brentru
committed
switch to progressbar library
1 parent 47142d3 commit 5a718e7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

PyPortal_TOTP_Friend/code.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
import adafruit_hashlib as hashlib
1010
import adafruit_touchscreen
1111
from adafruit_button import Button
12-
from adafruit_display_shapes.rect import Rect
12+
from adafruit_progressbar import ProgressBar
1313
from adafruit_display_text.label import Label
1414
from adafruit_esp32spi import adafruit_esp32spi
1515
from adafruit_ntp import NTP
1616
from adafruit_pyportal import PyPortal
1717

1818

1919
# Background Color
20-
BACKGROUND = 0x059ACE
20+
BACKGROUND = 0x0
2121

2222
# Button color
2323
BTN_COLOR = 0xFFFFFF
@@ -247,9 +247,10 @@ def generate_otp(int_input, secret_key, digits=6):
247247
label_timer.y = 15
248248
splash.append(label_timer)
249249

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)
253254

254255
# how long to stay on if not in always_on mode
255256
countdown = ON_SECONDS
@@ -274,13 +275,13 @@ def generate_otp(int_input, secret_key, digits=6):
274275
print('countdown:', countdown)
275276

276277
# change the timer bar's color if text is about to refresh
278+
# TODO: this needs to be added to progressbar!
277279
fill_color = 0xFFFFFF
278280
if countdown < 5:
279281
fill_color = 0xFF0000
280282
# "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+
284285

285286
# poll the touchscreen
286287
p = ts.touch_point

PyPortal_TOTP_Friend/secrets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
88
# https://github.com/pyotp/pyotp example
99
'totp_keys' : [("Discord ", "JBSWY3DPEHPK3PXP"),
10-
("Gmail", "JBSWY3DPEHPK3PZP"),
10+
(" Gmail", "JBSWY3DPEHPK3PZP"),
1111
("GitHub", "JBSWY5DZEHPK3PXP"),
1212
("Adafruit", "JBSWY6DZEHPK3PXP"),
1313
("Outlook", "JBSWY7DZEHPK3PXP")]

0 commit comments

Comments
 (0)