summaryrefslogtreecommitdiff
path: root/wasp/apps/testapp.py
blob: 2cf34316fca0eabfdcbe054772a68a8b02b53068 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import watch
import widgets
import manager

from draw565 import Draw565

class TouchTestApp(object):
    """Simple application to visualize touch events.
    """

    def __init__(self):
        pass

    def foreground(self, system, effect=None):
        """Activate the application."""
        self.on_screen = ( -1, -1, -1, -1, -1, -1 )
        self.draw(effect)
        system.request_event(manager.EVENT_TOUCH)

    def background(self):
        """De-activate the application (without losing state)."""
        pass

    def sleep(self):
        return False

    def touch(self, event):
        draw = Draw565(watch.display)
        draw.string('({}, {})'.format(event[1], event[2]),
                0, 180, width=240)
        return True

    def draw(self, effect=None):
        """Redraw the display from scratch."""
        watch.display.fill(0)