2019-12-12 09:24:58 -07:00
|
|
|
# UPIWIN - Micro Pi Windowing Framework Kernel
|
|
|
|
# Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
# Initial test script
|
2019-12-09 13:38:01 -07:00
|
|
|
import upiwin
|
2019-12-07 22:09:27 -07:00
|
|
|
import upiwin_tmp
|
|
|
|
|
2019-12-09 13:29:37 -07:00
|
|
|
def log_touch(event, x, y):
|
2019-12-09 13:42:55 -07:00
|
|
|
print("Touch {0} at ({1}, {2})".format(event, x, y))
|
2019-12-09 13:29:37 -07:00
|
|
|
|
2019-12-09 12:28:28 -07:00
|
|
|
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)
|
|
|
|
upiwin_tmp.filled_rectangle(10, 60, 50, 100, upiwin_tmp.FBPRIMCLR_CYAN, False)
|
|
|
|
upiwin_tmp.filled_rectangle(60, 60, 100, 100, upiwin_tmp.FBPRIMCLR_MAGENTA, False)
|
|
|
|
upiwin_tmp.filled_rectangle(110, 60, 150, 100, upiwin_tmp.FBPRIMCLR_YELLOW, False)
|
|
|
|
upiwin_tmp.rectangle(10, 110, 150, 150, upiwin_tmp.FBPRIMCLR_WHITE, False)
|
|
|
|
upiwin_tmp.line(10, 110, 150, 150, upiwin_tmp.FBPRIMCLR_WHITE, False)
|
|
|
|
upiwin_tmp.line(10, 150, 150, 110, upiwin_tmp.FBPRIMCLR_WHITE, False)
|
2019-12-07 22:05:31 -07:00
|
|
|
|
2019-12-09 12:28:28 -07:00
|
|
|
upiwin_tmp.line(0, 180, 319, 180, upiwin_tmp.FBPRIMCLR_RED, False);
|
|
|
|
upiwin_tmp.line(0, 196, 319, 196, upiwin_tmp.FBPRIMCLR_RED, False);
|
2019-12-07 23:30:05 -07:00
|
|
|
upiwin_tmp.textout(10, 180, 'Amy was here!!!')
|
2019-12-09 13:29:37 -07:00
|
|
|
|
|
|
|
msg = {}
|
|
|
|
while upiwin.get_message(msg):
|
|
|
|
if msg['message'] == upiwin.WM_HWBUTTONDOWN:
|
2019-12-09 13:42:55 -07:00
|
|
|
print("Button {0} was pressed.".format(msg['attrs'][0]))
|
2019-12-09 13:29:37 -07:00
|
|
|
elif msg['message'] == upiwin.WM_HWBUTTONUP:
|
2019-12-09 13:42:55 -07:00
|
|
|
print("Button {0} was released.".format(msg['attrs'][0]))
|
2019-12-11 11:32:19 -07:00
|
|
|
elif msg['message'] == upiwin.WM_HWBUTTONCLICK:
|
|
|
|
print("Button {0} was clicked.".format(msg['attrs'][0]))
|
2019-12-09 13:29:37 -07:00
|
|
|
bn = msg['attrs'][0]
|
|
|
|
if bn == 1:
|
2019-12-09 13:42:55 -07:00
|
|
|
print("Backlight ON.")
|
2019-12-09 13:29:37 -07:00
|
|
|
upiwin.set_backlight(True)
|
|
|
|
elif bn == 2:
|
2019-12-09 13:42:55 -07:00
|
|
|
print("Backlight OFF.")
|
|
|
|
upiwin.set_backlight(False)
|
2019-12-09 13:29:37 -07:00
|
|
|
elif bn == 4:
|
2019-12-09 13:42:55 -07:00
|
|
|
print("Quitting the application.")
|
2019-12-09 13:29:37 -07:00
|
|
|
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])
|
2019-12-11 11:32:19 -07:00
|
|
|
elif msg['message'] == upiwin.WM_TOUCHCLICK:
|
|
|
|
log_touch('CLICK', msg['attrs'][0], msg['attrs'][1])
|