Skip to content

Commit 7a13a02

Browse files
author
brentru
committed
add timer
1 parent b0123ce commit 7a13a02

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

PyPortal_TOTP_Friend/code.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def generate_otp(int_input, secret_key, digits=6):
238238

239239
# how long to stay on if not in always_on mode
240240
countdown = ON_SECONDS
241+
timer = 30
241242

242243
# current button state, defaults to first item in totp_keys
243244
current_button = secrets['totp_keys'][0][0]
@@ -274,6 +275,13 @@ def generate_otp(int_input, secret_key, digits=6):
274275
# format and display the OTP
275276
label_secret.text = "{} {}".format(str(otp)[0:3],str(otp)[3:6])
276277

278+
if timer > 0:
279+
timer=-0.25
280+
print('Timer: ', int(timer))
281+
else:
282+
# reset the display timer
283+
timer = 30
284+
277285
# We'll update every 1/4 second, we can hash very fast so its no biggie!
278286
countdown -= 0.25
279287
time.sleep(0.25)

0 commit comments

Comments
 (0)