summaryrefslogtreecommitdiff
path: root/wasp/boards/simulator/machine.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-03-08 21:22:54 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-03-08 21:22:54 (GMT)
commitd236db68dc9526b17c89bc3e27d6fc50c8c45817 (patch)
treeb24302f2d21b300fa4b3bbd91c12018bceb409ab /wasp/boards/simulator/machine.py
parentcfffeddd774774a14cbb77ad899d047a259f16f3 (diff)
testapp: Show the render time for the string test
Diffstat (limited to 'wasp/boards/simulator/machine.py')
-rw-r--r--wasp/boards/simulator/machine.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/wasp/boards/simulator/machine.py b/wasp/boards/simulator/machine.py
index dd462bb..62a95c5 100644
--- a/wasp/boards/simulator/machine.py
+++ b/wasp/boards/simulator/machine.py
@@ -82,6 +82,27 @@ class I2C():
else:
raise OSError
+class Timer():
+ def __init__(self, id, period=1000000):
+ self.then = None
+ self.period = period
+
+ def start(self):
+ self.then = time.time()
+
+ def stop(self):
+ self.then = None
+
+ def time(self):
+ now = time.time()
+ elapsed_sec = now - self.then
+ elapsed_us = int(elapsed_sec * 1000000)
+
+ return elapsed_us % self.period
+
+ def period(self):
+ self.time()
+
def lightsleep(ms=10):
display.tick()
time.sleep(ms / 1000)