fill the default button
@@ -23,7 +23,7 @@ from adafruit_pyportal import PyPortal
BACKGROUND = 0x059ACE
TEST = True # if you want to print out the tests the hashers
-ALWAYS_ON = False # Set to true if you never want to go to sleep!
+ALWAYS_ON = True # Set to true if you never want to go to sleep!
ON_SECONDS = 60 # how long to stay on if not in always_on mode
# Get wifi details and more from a secrets.py file
@@ -33,7 +33,6 @@ except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
-
# Initialize PyPortal Display
display = board.DISPLAY
@@ -47,7 +46,6 @@ ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR,
),
size=(WIDTH, HEIGHT))
-
# Create a SHA1 Object
SHA1 = hashlib.sha1
@@ -61,6 +59,15 @@ spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
+def set_backlight(val):
+ """Adjust the TFT backlight.
+ :param val: The backlight brightness. Use a value between ``0`` and ``1``, where ``0`` is
+ off, and ``1`` is 100% brightness.
+ """
+ val = max(0, min(1.0, val))
+ board.DISPLAY.auto_brightness = False
+ board.DISPLAY.brightness = val
+
# HMAC implementation, as hashlib/hmac wouldn't fit
# From https://en.wikipedia.org/wiki/Hash-based_message_authentication_code
def HMAC(k, m):
@@ -141,7 +148,6 @@ print("===========================================")
# GFX Font
font = terminalio.FONT
-
# Initialize new PyPortal object
pyportal = PyPortal(esp=esp,
external_spi=spi)
@@ -235,6 +241,8 @@ countdown = ON_SECONDS
# current button state, defaults to first item in totp_keys
current_button = secrets['totp_keys'][0][0]
+# fill the first button
+buttons[0].selected = True
while ALWAYS_ON or (countdown > 0):
# Calculate current time based on NTP + monotonic
