Added a selection of flags the user can switch between.
parent
599c504110
commit
f19cffd307
|
@ -7,12 +7,14 @@ background is the pride flag.
|
||||||
___name___ = "Pride"
|
___name___ = "Pride"
|
||||||
___license___ = "MIT"
|
___license___ = "MIT"
|
||||||
___categories___ = ["Homescreens"]
|
___categories___ = ["Homescreens"]
|
||||||
___dependencies___ = ["homescreen", "app"]
|
___dependencies___ = ["homescreen", "app", "buttons"]
|
||||||
|
|
||||||
|
|
||||||
from app import restart_to_default
|
from app import restart_to_default
|
||||||
import ugfx
|
import ugfx
|
||||||
import homescreen
|
import homescreen
|
||||||
|
from tilda import Buttons
|
||||||
|
import buttons
|
||||||
|
|
||||||
|
|
||||||
homescreen.init()
|
homescreen.init()
|
||||||
|
@ -25,13 +27,19 @@ info_height = 20
|
||||||
# Maximum length of name before downscaling
|
# Maximum length of name before downscaling
|
||||||
max_name = 8
|
max_name = 8
|
||||||
|
|
||||||
# Orientation for other people to see
|
flags = {
|
||||||
ugfx.orientation(90)
|
'LGBT': [0xE70000, 0xFF8C00, 0xFFEF00, 0x00811F, 0x0044FF, 0x760089],
|
||||||
|
'Non-Binary': [0xFFF433, 0xFFFFFF, 0x9B59D0, 0x000000],
|
||||||
|
'Trans': [0x5BCEFA, 0xF5A9B8, 0xFFFFFF, 0xF5A9B8, 0x5BCEFA],
|
||||||
|
'Asexual': [0x000000, 0xA3A3A3, 0xFFFFFF, 0x800080],
|
||||||
|
'Bisexual': [0xFF0080, 0xFF0080, 0xA349A4, 0x0000FF, 0x0000FF],
|
||||||
|
'Pansexual': [0xFF218E, 0xFCD800, 0x0194FC]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def draw_flag():
|
def draw_flag(colours):
|
||||||
# Pride flag colours
|
# Orientation for other people to see
|
||||||
colours = [0xE70000, 0xFF8C00, 0xFFEF00, 0x00811F, 0x0044FF, 0x760089]
|
ugfx.orientation(90)
|
||||||
|
|
||||||
# Draw each "band" of colour in the flag
|
# Draw each "band" of colour in the flag
|
||||||
colour_width = ugfx.width() / len(colours)
|
colour_width = ugfx.width() / len(colours)
|
||||||
|
@ -76,13 +84,36 @@ def draw_user_info():
|
||||||
ugfx.text(0, ugfx.height() - info_height, battery_message, ugfx.BLACK)
|
ugfx.text(0, ugfx.height() - info_height, battery_message, ugfx.BLACK)
|
||||||
|
|
||||||
|
|
||||||
draw_flag()
|
# Set variables for WiFi/Battery loop
|
||||||
draw_name()
|
selection_change = True
|
||||||
|
flag_names = list(flags.keys())
|
||||||
|
selection = flag_names.index('LGBT')
|
||||||
|
|
||||||
# WiFi/Battery update loop
|
# WiFi/Battery update loop
|
||||||
|
draw_name()
|
||||||
while True:
|
while True:
|
||||||
draw_user_info()
|
# Buttons will cycle when it reaches either side of the list
|
||||||
|
if buttons.is_pressed(Buttons.JOY_Left):
|
||||||
|
if selection > 0:
|
||||||
|
selection -= 1
|
||||||
|
else:
|
||||||
|
selection = len(flags) - 1
|
||||||
|
selection_change = True
|
||||||
|
|
||||||
|
elif buttons.is_pressed(Buttons.JOY_Right):
|
||||||
|
if selection < len(flags) - 1:
|
||||||
|
selection += 1
|
||||||
|
else:
|
||||||
|
selection = 0
|
||||||
|
selection_change = True
|
||||||
|
|
||||||
|
# Only triggers if the selection has changed
|
||||||
|
if selection_change:
|
||||||
|
draw_flag(flags[flag_names[selection]])
|
||||||
|
selection_change = False
|
||||||
|
|
||||||
|
# Redraw time-sensitive info on each iteration
|
||||||
|
draw_user_info()
|
||||||
homescreen.sleep_or_exit(1.5)
|
homescreen.sleep_or_exit(1.5)
|
||||||
|
|
||||||
restart_to_default()
|
restart_to_default()
|
||||||
|
|
Loading…
Reference in New Issue