2020-02-19 20:37:31 +01:00
|
|
|
import fonts.clock as digits
|
2020-02-03 23:35:16 +01:00
|
|
|
import widgets
|
2020-02-03 20:24:09 +01:00
|
|
|
|
2020-02-19 20:54:27 +01:00
|
|
|
from draw565 import Draw565
|
|
|
|
|
2020-02-03 20:24:09 +01:00
|
|
|
DIGITS = (
|
2020-02-19 20:37:31 +01:00
|
|
|
digits.clock_0,
|
|
|
|
digits.clock_1,
|
|
|
|
digits.clock_2,
|
|
|
|
digits.clock_3,
|
|
|
|
digits.clock_4,
|
|
|
|
digits.clock_5,
|
|
|
|
digits.clock_6,
|
|
|
|
digits.clock_7,
|
|
|
|
digits.clock_8,
|
|
|
|
digits.clock_9
|
2020-02-03 20:24:09 +01:00
|
|
|
)
|
|
|
|
|
2020-02-19 20:54:27 +01:00
|
|
|
MONTH = 'JanFebMarAprMayJunJulAugSepOctNovDec'
|
|
|
|
|
2020-02-03 20:24:09 +01:00
|
|
|
class ClockApp(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
2020-02-19 20:54:27 +01:00
|
|
|
self.on_screen = ( -1, -1, -1, -1, -1, -1 )
|
2020-02-03 23:35:16 +01:00
|
|
|
self.meter = widgets.BatteryMeter()
|
2020-02-03 20:24:09 +01:00
|
|
|
|
|
|
|
def draw(self, watch):
|
|
|
|
display = watch.display
|
|
|
|
|
|
|
|
display.fill(0)
|
2020-02-19 20:54:27 +01:00
|
|
|
display.rleblit(digits.clock_colon, pos=(2*48, 80), fg=0xb5b6)
|
|
|
|
self.on_screen = ( -1, -1, -1, -1, -1, -1 )
|
2020-02-03 20:24:09 +01:00
|
|
|
self.update(watch)
|
2020-02-03 23:35:16 +01:00
|
|
|
self.meter.draw()
|
|
|
|
|
2020-02-03 20:24:09 +01:00
|
|
|
def update(self, watch):
|
2020-02-19 20:54:27 +01:00
|
|
|
now = watch.rtc.get_localtime()
|
|
|
|
if now[3] == self.on_screen[3] and now[4] == self.on_screen[4]:
|
|
|
|
if now[5] % 2 == 0:
|
2020-02-04 09:47:14 +01:00
|
|
|
self.meter.update()
|
|
|
|
return False
|
2020-02-03 20:24:09 +01:00
|
|
|
|
|
|
|
display = watch.display
|
2020-02-19 20:54:27 +01:00
|
|
|
display.rleblit(DIGITS[now[4] % 10], pos=(4*48, 80))
|
|
|
|
display.rleblit(DIGITS[now[4] // 10], pos=(3*48, 80), fg=0xbdb6)
|
|
|
|
display.rleblit(DIGITS[now[3] % 10], pos=(1*48, 80))
|
|
|
|
display.rleblit(DIGITS[now[3] // 10], pos=(0*48, 80), fg=0xbdb6)
|
2020-02-03 20:24:09 +01:00
|
|
|
self.on_screen = now
|
|
|
|
|
2020-02-19 20:54:27 +01:00
|
|
|
draw = Draw565(display)
|
|
|
|
month = now[1] - 1
|
|
|
|
month = MONTH[month*3:(month+1)*3]
|
|
|
|
draw.string('{}-{}-{}'.format(now[2], month, now[0]),
|
|
|
|
0, 180, width=240)
|
|
|
|
|
2020-02-03 23:35:16 +01:00
|
|
|
self.meter.update()
|
2020-02-04 09:47:14 +01:00
|
|
|
return True
|