Exemplo n.º 1
0
def test_touch(v):
    d.clear()
    c, t = int(v[0]), int(v[1])
    deadline = utime.ticks_add(utime.ticks_us(), t * 1000000)
    if c == 1:
        d.bar(0, 0, 120, 120, 0xFFFF)
    elif c == 2:
        d.bar(120, 0, 120, 120, 0xFFFF)
    elif c == 3:
        d.bar(120, 120, 120, 120, 0xFFFF)
    else:
        d.bar(0, 120, 120, 120, 0xFFFF)
    d.refresh()
    r = [0, 0]
    # flush all events
    while io.poll([io.TOUCH], r, 10000):
        pass
    # wait for event
    touch = False
    while True:
        if not touch:
            if io.poll(
                [io.TOUCH], r,
                    10000) and r[0] == io.TOUCH and r[1][0] == io.TOUCH_START:
                touch = True
        else:
            if io.poll([io.TOUCH], r,
                       10000) and r[0] == io.TOUCH and r[1][0] == io.TOUCH_END:
                print('OK %d %d' % (r[1][1], r[1][2]))
                break
        if utime.ticks_us() > deadline:
            print('ERROR TIMEOUT')
            break
    # flush all events
    while io.poll([io.TOUCH], r, 10000):
        pass
    d.clear()
    d.refresh()
Exemplo n.º 2
0
import usb

usb.bus.open()

import trezorio as io
from trezorui import Display

d = Display()

d.clear()
d.backlight(255)

i = 0

while True:
    d.print('Loop %d\n' % i)
    i += 1
    r = [0, 0]
    if io.poll([io.TOUCH], r, 1000000):
        print('TOUCH', r)
    else:
        print('NOTOUCH')