summaryrefslogtreecommitdiff
path: root/wasp/boards/simulator
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-06-12 07:49:54 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-06-12 07:49:54 (GMT)
commit93b3c2bf1ad19153daf9df3174a4076d97ac68bf (patch)
treec10bd12e3f095d7fe15a059d82d7a699fe7f039a /wasp/boards/simulator
parent7cb9f4f2ebfd029ebfadc9722f80e54e8b6b3666 (diff)
wasp: simulator: Improve the RTC
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/boards/simulator')
-rw-r--r--wasp/boards/simulator/watch.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py
index b12ec94..48d7122 100644
--- a/wasp/boards/simulator/watch.py
+++ b/wasp/boards/simulator/watch.py
@@ -97,27 +97,32 @@ class Battery(object):
class RTC(object):
def __init__(self):
- self.uptime = 0
+ self._epoch = time.time()
+ self._lasttime = 0
def update(self):
now = time.time()
- if now == self.uptime:
+ if now == self._lasttime:
return False
- self.uptime = now
+ self._lasttime = now
return True
def get_localtime(self):
+ #if self.uptime < 60:
+ # # Jump back a little over a day
+ # return time.localtime(time.time() - 100000)
return time.localtime()
def get_time(self):
- now = time.localtime()
+ now = self.get_localtime()
return (now[3], now[4], now[5])
+ @property
def uptime(self):
- return time.time()
+ return time.time() - self._epoch
def get_uptime_ms(self):
- return int(time.time() * 1000)
+ return int(self.uptime * 1000)
backlight = Backlight()
spi = SPI(0)