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.
This commit is contained in:
parent
3ba356f6c4
commit
41647556c1
2 changed files with 8 additions and 4 deletions
|
@ -9,6 +9,8 @@ from machine import SPI
|
||||||
from drivers.st7789 import ST7789_SPI
|
from drivers.st7789 import ST7789_SPI
|
||||||
from drivers.vibrator import Vibrator
|
from drivers.vibrator import Vibrator
|
||||||
|
|
||||||
|
button = Pin('BUTTON', Pin.IN, quiet=True)
|
||||||
|
|
||||||
class Backlight(object):
|
class Backlight(object):
|
||||||
def __init__(self, level=1):
|
def __init__(self, level=1):
|
||||||
self.set(level)
|
self.set(level)
|
||||||
|
@ -16,6 +18,8 @@ class Backlight(object):
|
||||||
def set(self, level):
|
def set(self, level):
|
||||||
print(f'BACKLIGHT: {level}')
|
print(f'BACKLIGHT: {level}')
|
||||||
|
|
||||||
|
button.value(bool(level))
|
||||||
|
|
||||||
class Display(ST7789_SPI):
|
class Display(ST7789_SPI):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
spi = SPI(0)
|
spi = SPI(0)
|
||||||
|
@ -45,10 +49,10 @@ class Battery(object):
|
||||||
|
|
||||||
def voltage_mv(self):
|
def voltage_mv(self):
|
||||||
if self.voltage > 4:
|
if self.voltage > 4:
|
||||||
self.step = -0.005
|
self.step = -0.01
|
||||||
self.powered = False
|
self.powered = False
|
||||||
elif self.voltage < 3.4:
|
elif self.voltage < 3.4:
|
||||||
self.step = 0.01
|
self.step = 0.04
|
||||||
self.powered = True
|
self.powered = True
|
||||||
self.voltage += self.step
|
self.voltage += self.step
|
||||||
|
|
||||||
|
@ -89,5 +93,4 @@ backlight = Backlight()
|
||||||
battery = Battery()
|
battery = Battery()
|
||||||
rtc = RTC()
|
rtc = RTC()
|
||||||
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
|
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
|
||||||
button = Pin('BUTTON', Pin.IN, quiet=True)
|
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,9 @@ class ClockApp(object):
|
||||||
def update(self, watch):
|
def update(self, watch):
|
||||||
now = watch.rtc.get_localtime()
|
now = watch.rtc.get_localtime()
|
||||||
if now[3] == self.on_screen[3] and now[4] == self.on_screen[4]:
|
if now[3] == self.on_screen[3] and now[4] == self.on_screen[4]:
|
||||||
if now[5] % 2 == 0:
|
if now[5] != self.on_screen[5]:
|
||||||
self.meter.update()
|
self.meter.update()
|
||||||
|
self.on_screen = now
|
||||||
return False
|
return False
|
||||||
|
|
||||||
display = watch.display
|
display = watch.display
|
||||||
|
|
Loading…
Reference in a new issue