From e4ba01098ca93698ea551ab08850c26f98ef1fbc Mon Sep 17 00:00:00 2001 From: frogg Date: Sun, 2 Sep 2018 15:01:31 +0100 Subject: [PATCH 1/4] message --- enby/main.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 enby/main.py diff --git a/enby/main.py b/enby/main.py new file mode 100644 index 0000000..60f7eb5 --- /dev/null +++ b/enby/main.py @@ -0,0 +1,80 @@ +"""Pride flag homescreen + +Similar to the default homescreen, but the +background is the pride flag. +""" + +___name___ = "Enby" +___license___ = "MIT" +___categories___ = ["Homescreens"] +___dependencies___ = ["homescreen", "app"] + + +from app import restart_to_default +import ugfx +import homescreen + + +homescreen.init() +ugfx.clear(ugfx.html_color(0xFF0000)) + +# Used for placement around text +name_height = 55 +info_height = 20 + +# Maximum length of name before downscaling +max_name = 8 + +# Orientation for other people to see +ugfx.orientation(90) + +# Pride flag colours +colours = [0xfff433, 0xffffff, 0x9b59d0, 0x000000] + +# 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)) + +# Message to display +prefix_message = "Hi I'm" + +ugfx.set_default_font(ugfx.FONT_NAME) + +# Calc center of screen +center = (int(ugfx.width() / 2), int(ugfx.height() / 2)) +# Can't use label since the background covers the flag +ugfx.text(50, center[1] + name_height, prefix_message, ugfx.WHITE) + +# 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) + +# 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() + if wifi_strength_value: + wifi_message = 'WiFi: %s%%' % int(wifi_strength_value) + wifi_text = ugfx.text(center[0], ugfx.height() - info_height, wifi_message, ugfx.BLACK) + + battery_value = homescreen.battery() + if battery_value: + battery_message = 'Battery: %s%%' % int(battery_value) + battery_text = ugfx.text(0, ugfx.height() - info_height, battery_message, ugfx.BLACK) + + homescreen.sleep_or_exit(1.5) + +restart_to_default() From 87085cb1f69e9539cc1ae35fa9130ca394dfebfa Mon Sep 17 00:00:00 2001 From: frogg Date: Sun, 2 Sep 2018 16:36:37 +0100 Subject: [PATCH 2/4] Update color --- enby/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/enby/main.py b/enby/main.py index 60f7eb5..9f366cf 100644 --- a/enby/main.py +++ b/enby/main.py @@ -1,7 +1,7 @@ -"""Pride flag homescreen +"""enby flag homescreen Similar to the default homescreen, but the -background is the pride flag. +background is the enby flag. Based on Pride Flag Homescreen by marekventur """ ___name___ = "Enby" @@ -28,7 +28,7 @@ max_name = 8 # Orientation for other people to see ugfx.orientation(90) -# Pride flag colours +# enby flag colours colours = [0xfff433, 0xffffff, 0x9b59d0, 0x000000] # Draw each "band" of colour in the flag @@ -39,13 +39,14 @@ for num, colour in enumerate(colours): # Message to display prefix_message = "Hi I'm" +prefix_color = 0x3c701b ugfx.set_default_font(ugfx.FONT_NAME) # Calc center of screen center = (int(ugfx.width() / 2), int(ugfx.height() / 2)) # Can't use label since the background covers the flag -ugfx.text(50, center[1] + name_height, prefix_message, ugfx.WHITE) +ugfx.text(50, center[1] + name_height, prefix_message, ugfx.html_color(prefix_color)) # Process name given_name = homescreen.name("Set your name in the settings app") From ca4e2c84fdad44cac1b035f24d9109629d3337a8 Mon Sep 17 00:00:00 2001 From: frogg Date: Sun, 2 Sep 2018 16:44:03 +0100 Subject: [PATCH 3/4] update text --- enby/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enby/main.py b/enby/main.py index 9f366cf..80fb889 100644 --- a/enby/main.py +++ b/enby/main.py @@ -46,7 +46,7 @@ ugfx.set_default_font(ugfx.FONT_NAME) # Calc center of screen center = (int(ugfx.width() / 2), int(ugfx.height() / 2)) # Can't use label since the background covers the flag -ugfx.text(50, center[1] + name_height, prefix_message, ugfx.html_color(prefix_color)) +ugfx.text(10, center[1] + name_height, prefix_message, ugfx.html_color(prefix_color)) # Process name given_name = homescreen.name("Set your name in the settings app") From 168fe8caca2b4c9321704a62f5e2513c9532979e Mon Sep 17 00:00:00 2001 From: frogg Date: Sun, 2 Sep 2018 16:49:33 +0100 Subject: [PATCH 4/4] Remove Hi I'm --- enby/main.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/enby/main.py b/enby/main.py index 80fb889..de07335 100644 --- a/enby/main.py +++ b/enby/main.py @@ -37,16 +37,10 @@ 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)) -# Message to display -prefix_message = "Hi I'm" -prefix_color = 0x3c701b - ugfx.set_default_font(ugfx.FONT_NAME) # Calc center of screen center = (int(ugfx.width() / 2), int(ugfx.height() / 2)) -# Can't use label since the background covers the flag -ugfx.text(10, center[1] + name_height, prefix_message, ugfx.html_color(prefix_color)) # Process name given_name = homescreen.name("Set your name in the settings app")