moved the main message loop entirely into Python

This commit is contained in:
Amy Bowersox
2019-12-09 13:29:37 -07:00
parent f74e663658
commit a96a427e49
9 changed files with 133 additions and 57 deletions

View File

@@ -1,6 +1,9 @@
# Initial test script
import upiwin_tmp
def log_touch(event, x, y):
print("Touch {0} at ({1), {2})\n".format(event, x, y))
upiwin_tmp.filled_rectangle(10, 10, 50, 50, upiwin_tmp.FBPRIMCLR_RED, False)
upiwin_tmp.filled_rectangle(60, 10, 100, 50, upiwin_tmp.FBPRIMCLR_GREEN, False)
upiwin_tmp.filled_rectangle(110, 10, 150, 50, upiwin_tmp.FBPRIMCLR_BLUE, False)
@@ -14,3 +17,26 @@ upiwin_tmp.line(10, 150, 150, 110, upiwin_tmp.FBPRIMCLR_WHITE, False)
upiwin_tmp.line(0, 180, 319, 180, upiwin_tmp.FBPRIMCLR_RED, False);
upiwin_tmp.line(0, 196, 319, 196, upiwin_tmp.FBPRIMCLR_RED, False);
upiwin_tmp.textout(10, 180, 'Amy was here!!!')
msg = {}
while upiwin.get_message(msg):
if msg['message'] == upiwin.WM_HWBUTTONDOWN:
print("Button {0} was pressed.\n".format(msg['attrs'][0])
elif msg['message'] == upiwin.WM_HWBUTTONUP:
print("Button {0} was released.\n".format(msg['attrs'][0])
bn = msg['attrs'][0]
if bn == 1:
print("Backlight ON.\n")
upiwin.set_backlight(True)
elif bn == 2:
print("Backlight OFF.\n")
upiwin.set_backlight(True)
elif bn == 4:
print("Quitting the application.\n")
upiwin.post_quit_message(0)
elif msg['message'] == upiwin.WM_TOUCHDOWN:
log_touch('DOWN', msg['attrs'][0], msg['attrs'][1])
elif msg['message'] == upiwin.WM_TOUCHMOVE:
log_touch('MOVE', msg['attrs'][0], msg['attrs'][1])
elif msg['message'] == upiwin.WM_TOUCHUP:
log_touch('UP', msg['attrs'][0], msg['attrs'][1])