added the backlight control and some code for doing repaints
This commit is contained in:
parent
2a5a6dbe4e
commit
59ee61200c
|
@ -2,6 +2,7 @@
|
|||
import upiwin
|
||||
|
||||
# Save off some color values.
|
||||
BLACK = upiwin.rgb(0, 0, 0)
|
||||
WHITE = upiwin.rgb(255, 255, 255)
|
||||
LTGRAY = upiwin.rgb(204, 204, 204)
|
||||
RED = upiwin.rgb(255, 0, 0)
|
||||
|
@ -33,6 +34,21 @@ cmd4_rect = (command_rect[0], 180, command_rect[2], command_rect[3])
|
|||
|
||||
def point_in_rect(rect, x, y):
|
||||
return (x >= rect[0]) and (x < rect[2]) and (y >= rect[1]) and (y < rect[3])
|
||||
|
||||
# --- Backlight control ---
|
||||
|
||||
backlight_level_list = [1023, 768, 512, 256]
|
||||
current_backlight = 0
|
||||
|
||||
def do_backlight():
|
||||
upiwin.set_backlight_level(backlight_level_list[current_backlight])
|
||||
|
||||
def select_next_backlight():
|
||||
global current_backlight
|
||||
current_backlight += 1
|
||||
if (current_backlight == len(backlight_level_list):
|
||||
current_backlight = 0
|
||||
do_backlight()
|
||||
|
||||
# --- Color selections ---
|
||||
|
||||
|
@ -83,6 +99,14 @@ def draw_object(obj):
|
|||
|
||||
objects_drawn = []
|
||||
|
||||
def repaint():
|
||||
global drawing_rect, objects_drawn
|
||||
hdc.text_color = BLACK
|
||||
hdc.rop2 = upiwin.R2_COPYPEN
|
||||
hdc.solid_rectangle(drawing_rect[0], drawing_rect[1], drawing_rect[2], drawing_rect[3])
|
||||
for obj in objects_drawn:
|
||||
draw_object(obj)
|
||||
|
||||
# --- Graphic feedback --
|
||||
|
||||
origin_x = 0
|
||||
|
@ -197,11 +221,15 @@ def on_touchclick(x, y):
|
|||
print("Click command 4")
|
||||
|
||||
def on_button_click(button):
|
||||
if button == 1: # Button 1 = Set backlight level
|
||||
select_next_backlight()
|
||||
if button == 4: # Button 4 = Exit app
|
||||
upiwin.post_quit_message(0)
|
||||
|
||||
# --- Initialize and start message loop ---
|
||||
|
||||
do_backlight()
|
||||
|
||||
# Draw the basic layout.
|
||||
hdc.text_color = LTGRAY
|
||||
hdc.rop2 = upiwin.R2_COPYPEN
|
||||
|
|
Loading…
Reference in New Issue
Block a user