|
22 | 22 | # Background Color |
23 | 23 | BACKGROUND = 0x059ACE |
24 | 24 |
|
25 | | -TEST = True # if you want to print out the tests the hashers |
26 | | -ALWAYS_ON = False # Set to true if you never want to go to sleep! |
27 | | -ON_SECONDS = 60 # how long to stay on if not in always_on mode |
| 25 | +TEST = True # if you want to print out the tests the hashers |
| 26 | +ALWAYS_ON = True # Set to true if you never want to go to sleep! |
| 27 | +ON_SECONDS = 60 # how long to stay on if not in always_on mode |
28 | 28 |
|
29 | 29 | # Get wifi details and more from a secrets.py file |
30 | 30 | try: |
|
33 | 33 | print("WiFi secrets are kept in secrets.py, please add them there!") |
34 | 34 | raise |
35 | 35 |
|
36 | | - |
37 | 36 | # Initialize PyPortal Display |
38 | 37 | display = board.DISPLAY |
39 | 38 |
|
|
47 | 46 | ), |
48 | 47 | size=(WIDTH, HEIGHT)) |
49 | 48 |
|
50 | | - |
51 | 49 | # Create a SHA1 Object |
52 | 50 | SHA1 = hashlib.sha1 |
53 | 51 |
|
|
61 | 59 | esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) |
62 | 60 |
|
63 | 61 |
|
| 62 | +def set_backlight(val): |
| 63 | + """Adjust the TFT backlight. |
| 64 | + :param val: The backlight brightness. Use a value between ``0`` and ``1``, where ``0`` is |
| 65 | + off, and ``1`` is 100% brightness. |
| 66 | + """ |
| 67 | + val = max(0, min(1.0, val)) |
| 68 | + board.DISPLAY.auto_brightness = False |
| 69 | + board.DISPLAY.brightness = val |
| 70 | + |
64 | 71 | # HMAC implementation, as hashlib/hmac wouldn't fit |
65 | 72 | # From https://en.wikipedia.org/wiki/Hash-based_message_authentication_code |
66 | 73 | def HMAC(k, m): |
@@ -141,7 +148,6 @@ def generate_otp(int_input, secret_key, digits=6): |
141 | 148 | # GFX Font |
142 | 149 | font = terminalio.FONT |
143 | 150 |
|
144 | | - |
145 | 151 | # Initialize new PyPortal object |
146 | 152 | pyportal = PyPortal(esp=esp, |
147 | 153 | external_spi=spi) |
@@ -235,6 +241,8 @@ def generate_otp(int_input, secret_key, digits=6): |
235 | 241 |
|
236 | 242 | # current button state, defaults to first item in totp_keys |
237 | 243 | current_button = secrets['totp_keys'][0][0] |
| 244 | +# fill the first button |
| 245 | +buttons[0].selected = True |
238 | 246 |
|
239 | 247 | while ALWAYS_ON or (countdown > 0): |
240 | 248 | # Calculate current time based on NTP + monotonic |
|
0 commit comments