summaryrefslogtreecommitdiff
path: root/wasp/boards/simulator/watch.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-02-23 20:19:37 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-02-23 20:19:37 (GMT)
commit41647556c1e4e7c4303967e513b7d4e7e87a1313 (patch)
tree90623ed5cc81a9a1d4113f29fc106287f06c7d28 /wasp/boards/simulator/watch.py
parent3ba356f6c4a1b823444dd45138f46976ab252f66 (diff)
clock: Reduce the update rate of the battery meter
In addition to the fix (which is simple) we also modify the button handling of the simulator because, rather by acident, it relies on the bugs in the battery meter redraw to ensure the simulator stays active.
Diffstat (limited to 'wasp/boards/simulator/watch.py')
-rw-r--r--wasp/boards/simulator/watch.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py
index 6e7fcee..9c45902 100644
--- a/wasp/boards/simulator/watch.py
+++ b/wasp/boards/simulator/watch.py
@@ -9,6 +9,8 @@ from machine import SPI
from drivers.st7789 import ST7789_SPI
from drivers.vibrator import Vibrator
+button = Pin('BUTTON', Pin.IN, quiet=True)
+
class Backlight(object):
def __init__(self, level=1):
self.set(level)
@@ -16,6 +18,8 @@ class Backlight(object):
def set(self, level):
print(f'BACKLIGHT: {level}')
+ button.value(bool(level))
+
class Display(ST7789_SPI):
def __init__(self):
spi = SPI(0)
@@ -45,10 +49,10 @@ class Battery(object):
def voltage_mv(self):
if self.voltage > 4:
- self.step = -0.005
+ self.step = -0.01
self.powered = False
elif self.voltage < 3.4:
- self.step = 0.01
+ self.step = 0.04
self.powered = True
self.voltage += self.step
@@ -89,5 +93,4 @@ backlight = Backlight()
battery = Battery()
rtc = RTC()
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
-button = Pin('BUTTON', Pin.IN, quiet=True)