wasp: clock: Add date indication
This commit is contained in:
parent
a26bfd33ce
commit
019ca1b4ed
|
@ -1,6 +1,8 @@
|
||||||
import fonts.clock as digits
|
import fonts.clock as digits
|
||||||
import widgets
|
import widgets
|
||||||
|
|
||||||
|
from draw565 import Draw565
|
||||||
|
|
||||||
DIGITS = (
|
DIGITS = (
|
||||||
digits.clock_0,
|
digits.clock_0,
|
||||||
digits.clock_1,
|
digits.clock_1,
|
||||||
|
@ -14,34 +16,42 @@ DIGITS = (
|
||||||
digits.clock_9
|
digits.clock_9
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MONTH = 'JanFebMarAprMayJunJulAugSepOctNovDec'
|
||||||
|
|
||||||
class ClockApp(object):
|
class ClockApp(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.on_screen = ( -1, -1 )
|
self.on_screen = ( -1, -1, -1, -1, -1, -1 )
|
||||||
self.meter = widgets.BatteryMeter()
|
self.meter = widgets.BatteryMeter()
|
||||||
|
|
||||||
def draw(self, watch):
|
def draw(self, watch):
|
||||||
display = watch.display
|
display = watch.display
|
||||||
|
|
||||||
display.fill(0)
|
display.fill(0)
|
||||||
display.rleblit(fonts.clock_colon, pos=(2*48, 80), fg=0xb5b6)
|
display.rleblit(digits.clock_colon, pos=(2*48, 80), fg=0xb5b6)
|
||||||
self.on_screen = ( -1, -1 )
|
self.on_screen = ( -1, -1, -1, -1, -1, -1 )
|
||||||
self.update(watch)
|
self.update(watch)
|
||||||
self.meter.draw()
|
self.meter.draw()
|
||||||
|
|
||||||
def update(self, watch):
|
def update(self, watch):
|
||||||
now = watch.rtc.get_time()
|
now = watch.rtc.get_localtime()
|
||||||
if now[0] == self.on_screen[0] and now[1] == self.on_screen[1]:
|
if now[3] == self.on_screen[3] and now[4] == self.on_screen[4]:
|
||||||
if now[1] % 2 == 0:
|
if now[5] % 2 == 0:
|
||||||
self.meter.update()
|
self.meter.update()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
display = watch.display
|
display = watch.display
|
||||||
display.rleblit(DIGITS[now[1] % 10], pos=(4*48, 80))
|
display.rleblit(DIGITS[now[4] % 10], pos=(4*48, 80))
|
||||||
display.rleblit(DIGITS[now[1] // 10], pos=(3*48, 80), fg=0xbdb6)
|
display.rleblit(DIGITS[now[4] // 10], pos=(3*48, 80), fg=0xbdb6)
|
||||||
display.rleblit(DIGITS[now[0] % 10], pos=(1*48, 80))
|
display.rleblit(DIGITS[now[3] % 10], pos=(1*48, 80))
|
||||||
display.rleblit(DIGITS[now[0] // 10], pos=(0*48, 80), fg=0xbdb6)
|
display.rleblit(DIGITS[now[3] // 10], pos=(0*48, 80), fg=0xbdb6)
|
||||||
self.on_screen = now
|
self.on_screen = now
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
self.meter.update()
|
self.meter.update()
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue