From fc74f7e37b3db9024d6cecf9fabdddf602b88b3c Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Mon, 3 Feb 2020 19:23:10 +0000 Subject: [PATCH] wasp: simulator: Add RTC support --- wasp/boards/simulator/watch.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py index 89faffe..e25d03c 100644 --- a/wasp/boards/simulator/watch.py +++ b/wasp/boards/simulator/watch.py @@ -29,6 +29,27 @@ class Display(ST7789_SPI): super().__init__(240, 240, spi, cs=cs, dc=dc, res=rst) +class RTC(object): + def __init__(self): + self.uptime = 0 + + def update(self): + now = time.time() + if now == self.uptime: + return False + self.uptime = now + return True + + def get_time(self): + now = time.localtime() + return (now[3], now[4], now[5]) + + def uptime(self): + return time.time + display = Display() backlight = Backlight() +rtc = RTC() vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True) +button = Pin('BUTTON', Pin.IN, quiet=True) +