testapp: Show the render time for the string test
This commit is contained in:
parent
cfffeddd77
commit
d236db68dc
2 changed files with 29 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import watch
|
import watch
|
||||||
import widgets
|
import widgets
|
||||||
import manager
|
import manager
|
||||||
|
import machine
|
||||||
|
|
||||||
from draw565 import Draw565
|
from draw565 import Draw565
|
||||||
|
|
||||||
|
@ -38,14 +39,20 @@ class TestApp():
|
||||||
draw = self.drawable
|
draw = self.drawable
|
||||||
if self.test == 'Touch':
|
if self.test == 'Touch':
|
||||||
draw.string('({}, {})'.format(event[1], event[2]),
|
draw.string('({}, {})'.format(event[1], event[2]),
|
||||||
0, 180, width=240)
|
0, 108, width=240)
|
||||||
elif self.test == 'String':
|
elif self.test == 'String':
|
||||||
watch.display.fill(0, 0, 30, 240, 240-30)
|
watch.display.fill(0, 0, 30, 240, 240-30)
|
||||||
|
t = machine.Timer(id=1, period=8000000)
|
||||||
|
t.start()
|
||||||
draw.string("The quick brown", 12, 24+24)
|
draw.string("The quick brown", 12, 24+24)
|
||||||
draw.string("fox jumped over", 12, 24+48)
|
draw.string("fox jumped over", 12, 24+48)
|
||||||
draw.string("the lazy dog.", 12, 24+72)
|
draw.string("the lazy dog.", 12, 24+72)
|
||||||
draw.string("0123456789", 12, 24+120)
|
draw.string("0123456789", 12, 24+120)
|
||||||
draw.string('!"£$%^&*()', 12, 24+144)
|
draw.string('!"£$%^&*()', 12, 24+144)
|
||||||
|
elapsed = t.time()
|
||||||
|
t.stop()
|
||||||
|
del t
|
||||||
|
draw.string('{}s'.format(elapsed / 1000000), 12, 24+192)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,27 @@ class I2C():
|
||||||
else:
|
else:
|
||||||
raise OSError
|
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):
|
def lightsleep(ms=10):
|
||||||
display.tick()
|
display.tick()
|
||||||
time.sleep(ms / 1000)
|
time.sleep(ms / 1000)
|
||||||
|
|
Loading…
Reference in a new issue