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