Skip to content
Snippets Groups Projects
Commit 854735a8 authored by Stefan Haun's avatar Stefan Haun
Browse files

Make theme buttons responsive again

parent 44f605af
Branches
Tags
No related merge requests found
Pipeline #3421 passed
......@@ -180,11 +180,24 @@ class Clock:
def loop(self):
colored = False
button_pressed = False
update_counter = 0
new_theme = self.theme
while True:
try:
with display.open() as disp:
if update_counter == 0:
update_counter = 10
with display.open() as disp:
# update the display
self.updateClock(disp)
# check theme
if new_theme != self.theme:
self.setTheme(new_theme)
self.writeConfig()
update_counter = update_counter - 1
if self.run_once:
break
......@@ -195,16 +208,15 @@ class Clock:
if not button_pressed and v & buttons.BOTTOM_LEFT != 0:
button_pressed = True
self.setTheme(self.theme - 1)
self.writeConfig()
new_theme = self.theme - 1
elif not button_pressed and v & buttons.BOTTOM_RIGHT != 0:
button_pressed = True
self.setTheme(self.theme + 1)
self.writeConfig()
new_theme = self.theme + 1
utime.sleep_ms(250)
utime.sleep_ms(25)
except OSError:
# leds.set(1, (255, 0, 0))
pass
except KeyboardInterrupt:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment