Sectioned code into functions
parent
f1ff8bef60
commit
17d40f9c62
|
@ -28,37 +28,38 @@ max_name = 8
|
|||
# Orientation for other people to see
|
||||
ugfx.orientation(90)
|
||||
|
||||
# Pride flag colours
|
||||
colours = [0xE70000, 0xFF8C00, 0xFFEF00, 0x00811F, 0x0044FF, 0x760089]
|
||||
|
||||
# Draw each "band" of colour in the flag
|
||||
colour_width = ugfx.width() / len(colours)
|
||||
for num, colour in enumerate(colours):
|
||||
width_loc = int(num * colour_width)
|
||||
ugfx.area(width_loc, 0, int(colour_width), 320, ugfx.html_color(colour))
|
||||
def draw_flag():
|
||||
# Pride flag colours
|
||||
colours = [0xE70000, 0xFF8C00, 0xFFEF00, 0x00811F, 0x0044FF, 0x760089]
|
||||
|
||||
# Draw each "band" of colour in the flag
|
||||
colour_width = ugfx.width() / len(colours)
|
||||
for num, colour in enumerate(colours):
|
||||
width_loc = int(num * colour_width)
|
||||
ugfx.area(width_loc, 0, int(colour_width), 320, ugfx.html_color(colour))
|
||||
|
||||
|
||||
ugfx.set_default_font(ugfx.FONT_NAME)
|
||||
|
||||
# Calc width center of screen
|
||||
center_width = int(ugfx.width() / 2)
|
||||
|
||||
# Process name
|
||||
given_name = homescreen.name("Set your name in the settings app")
|
||||
if len(given_name) <= max_name:
|
||||
def draw_name():
|
||||
ugfx.set_default_font(ugfx.FONT_NAME)
|
||||
else:
|
||||
ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
|
||||
# Draw name
|
||||
ugfx.Label(0, ugfx.height() - name_height, ugfx.width(), name_height, given_name, justification=ugfx.Label.CENTER)
|
||||
|
||||
# Process name
|
||||
given_name = homescreen.name("Set your name in the settings app")
|
||||
if len(given_name) <= max_name:
|
||||
ugfx.set_default_font(ugfx.FONT_NAME)
|
||||
else:
|
||||
ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
|
||||
# Draw name
|
||||
ugfx.Label(0, ugfx.height() - name_height, ugfx.width(), name_height, given_name, justification=ugfx.Label.CENTER)
|
||||
|
||||
|
||||
# Draw for the user to see
|
||||
ugfx.orientation(270)
|
||||
ugfx.set_default_font(ugfx.FONT_SMALL)
|
||||
def draw_user_info():
|
||||
# Draw for the user to see
|
||||
ugfx.orientation(270)
|
||||
# Calc width center of screen
|
||||
center_width = int(ugfx.width() / 2)
|
||||
ugfx.set_default_font(ugfx.FONT_SMALL)
|
||||
|
||||
# WiFi/Battery update loop
|
||||
while True:
|
||||
ugfx.area(0, ugfx.height() - info_height, ugfx.width(), info_height, ugfx.WHITE)
|
||||
|
||||
wifi_strength_value = homescreen.wifi_strength()
|
||||
|
@ -71,6 +72,14 @@ while True:
|
|||
battery_message = 'Battery: %s%%' % int(battery_value)
|
||||
battery_text = ugfx.text(0, ugfx.height() - info_height, battery_message, ugfx.BLACK)
|
||||
|
||||
|
||||
draw_flag()
|
||||
draw_name()
|
||||
|
||||
# WiFi/Battery update loop
|
||||
while True:
|
||||
draw_user_info()
|
||||
|
||||
homescreen.sleep_or_exit(1.5)
|
||||
|
||||
restart_to_default()
|
||||
|
|
Loading…
Reference in New Issue