summaryrefslogtreecommitdiff
path: root/wasp/apps
diff options
context:
space:
mode:
authorKozova1 <mug66kk@gmail.com>2020-12-11 08:12:09 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-12 18:18:01 (GMT)
commitc17abd1728ff02e83a348688d288869c42097232 (patch)
tree0bc8954199b59367e8ecaecd8e3434aa8918ef0f /wasp/apps
parent339b8357824b35cf1a4fb03732acdccd7ef5805e (diff)
draw565: Added line drawing function
This is the API: drawable.line(x1, y1, x2, y2, color) The function has optimizations for the case of vertical or horizontal lines. Signed-off-by: Kozova1 <mug66kk@gmail.com> [daniel@redfelineninja.org.uk: Minor update to commit message] Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/apps')
-rw-r--r--wasp/apps/testapp.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py
index 69cb1a3..81aaaf8 100644
--- a/wasp/apps/testapp.py
+++ b/wasp/apps/testapp.py
@@ -23,7 +23,7 @@ class TestApp():
ICON = icons.app
def __init__(self):
- self.tests = ('Alarm', 'Button', 'Crash', 'Colours', 'Fill', 'Fill-H', 'Fill-V', 'Notifications', 'RLE', 'String', 'Touch', 'Wrap')
+ self.tests = ('Alarm', 'Button', 'Crash', 'Colours', 'Fill', 'Fill-H', 'Fill-V', 'Line', 'Notifications', 'RLE', 'String', 'Touch', 'Wrap')
self.test = self.tests[0]
self.scroll = wasp.widgets.ScrollIndicator()
@@ -101,6 +101,8 @@ class TestApp():
event[1], event[2]), 0, 108, width=240)
elif self.test == 'Wrap':
self._benchmark_wrap()
+ elif self.test == 'Line':
+ self._benchmark_line()
def _alarm(self):
wasp.system.wake()
@@ -169,6 +171,23 @@ class TestApp():
del t
draw.string('{}s'.format(elapsed / 1000000), 12, 24+192)
+ def _benchmark_line(self):
+ draw = wasp.watch.drawable
+ # instead of calculating by trig functions, use LUT
+ points = ((120, 170), (139, 166), (155, 155), (166, 139), (170, 120), (166, 101), (155, 85), (139, 74), (120, 70))
+
+
+ draw.fill(0, 120, 120, 50, 50)
+ self.scroll.draw()
+ t = machine.Timer(id=1, period=8000000)
+ t.start()
+ for x, y in points:
+ draw.line(120, 120, x, y, 0x1f)
+ elapsed = t.time()
+ t.stop()
+ del t
+ draw.string('{}s'.format(elapsed / 1000000), 12, 24+192)
+
def _benchmark_wrap(self):
draw = wasp.watch.drawable
draw.fill(0, 0, 30, 240, 240-30)