From 09c50dc47f4a6f913c0b3bb0834d005749b68678 Mon Sep 17 00:00:00 2001 From: Skylar MacDonald Date: Sun, 2 Sep 2018 14:59:09 +0100 Subject: [PATCH] Added trans home screen app --- home_trans/logo.png | Bin 0 -> 3619 bytes home_trans/main.py | 175 +++++++++++++++++++++++++++++++++++++++++++ home_trans/trans.png | Bin 0 -> 2688 bytes 3 files changed, 175 insertions(+) create mode 100644 home_trans/logo.png create mode 100644 home_trans/main.py create mode 100644 home_trans/trans.png diff --git a/home_trans/logo.png b/home_trans/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..20dbdb6e09b01ca3bed4da7ce178b1deb4fabe97 GIT binary patch literal 3619 zcmb_f2~<;O7LE#vDOOSm3e`@GGJ^Pc**8Ir37c&&AS$Irc*%Pqk!&OZA_yqBAyT!4 zA|Q(!B8nnPQ4lCo1p&bnthQ#up7N-Ky28SG44Nf(d=Y91n$xkqS_ zWf7h};)q}|8zwGXKycD?PzMS`2NCoNxl+r~I}-=}a?oevXOKu3gy@2uiCkkqg0DbG z;HfkSf$qov#AF(Yz+^j;86+B=JdZ#jk(nTg4w4uEiOeCfI21Br_(w#eXe?Fvo?+la~LJh@!;`<8kIyQN1TaTZ@0w+4;LPT%w{kEiX)jw z_zTEW$yFMG3Py2MV=OgCfa(HaMc^U+T z{S8X?p`bV_hxQ&64I-1Q`5W}VcvWe9R4Vz1E`=jyC-8Vi9kK{^0!S=V8ns|gB*0>h zM5R$cXoh79C`8X4L$kesg)hZ?Ks!FML2L>*xn%%PDX3X8^M10pJw z4bVhv5&*#xDnKX0Fd}AC7&L@2;>Sa&)j>)zGGZ@7?U^u>MrN|f0FA|j0UE+)0U|mB z0VE<4OC(|-WSD`b8;yp})iWI785D0Bp!2!$pASWG$zATeny zm=2NHG$xZsFc#cM3Z()WyTqADHula?5O{yFysS_ zMko&r58HewkDn&Dk5hZEe}`cIyB^-jrm;q#aj_l}9Qb!F4vxLEu#dpe-NN`dx=o=k zqZ=KfL<^-sx3K^qr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P87FK*tr ztJBaCY%!acv=)cMHCp{zU48K6$xFmd%fYi&R#yF8w~ral?Yp^QiD7K^#mD|hj~_qI z%bQ!aYJ1Ym`FW%zLZP9%yMS(Plm6po3+!}U{)*uGmh)c;f4j^4yucG(v?ka$H8llP zL@Syu_pfc|+`8EumP2G2T0J(jX}14E7w|f?@7dCBm&YAE>#Ucug-@SQCKRu|MtPfj z*t>j-P2QP@R#~6Nja!|wrQ{U2`LInht?2a2>Z=Pom!9gVz8b@P!{x@*vKz9^Yd`fk zYSL%>wy>>SmC_RoyeL23av||wT}OA@*;F*%EzfRv`TDcS*^exv8<*G_|HgT^c=C@f H4vhUb)D^5b literal 0 HcmV?d00001 diff --git a/home_trans/main.py b/home_trans/main.py new file mode 100644 index 0000000..6d125a5 --- /dev/null +++ b/home_trans/main.py @@ -0,0 +1,175 @@ +"""Trans homescreen + +A version of the home screen that has a trans flag. +Press 0 to go back to normal or 8 to show the flag. +Hold * to activate all LEDs for use as a torch. +""" + +___name___ = "Homescreen (Trans)" +___license___ = "MIT" +___categories___ = ["Homescreens"] +___dependencies___ = ["homescreen", "shared/logo.png"] +___launchable___ = False +___bootstrapped___ = False + +import ugfx +from homescreen import * +import time +from tilda import Buttons +from machine import Pin +from machine import Neopix + +torch = Pin(Pin.GPIO_FET) +neo = Neopix() + +init() + +# Padding for name +intro_height = 30 +intro_text = "Hi! I'm" +name_height = 64 +status_height = 20 +info_height = 30 +logo_path = "shared/logo.png" +trans_logo_path = "home_magic/logo.png" +logo_height = 150 +logo_width = 56 + +# Maximum length of name before downscaling +max_name = 8 + +torch_on = False + +# Background stuff +ugfx.clear(ugfx.html_color(0x55cdfc)) +# Colour stuff +style = ugfx.Style() +style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)]) +style.set_background(ugfx.html_color(0x55cdfc)) +ugfx.set_default_style(style) +ugfx.display_image(0, 0, "home_magic/trans.png") + +# Logo stuff +ugfx.display_image( + int((ugfx.width() - logo_width) / 2), + int((ugfx.height() - logo_height) / 2)+9, + trans_logo_path +) + +# Draw for people to see +ugfx.orientation(90) +# Draw introduction +style.set_enabled([ugfx.BLACK, ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be)]) +style.set_background(ugfx.html_color(0xf8b0be)) +ugfx.set_default_style(style) +ugfx.set_default_font(ugfx.FONT_TITLE) +ugfx.Label(0, ugfx.height() - name_height - intro_height, ugfx.width(), intro_height, intro_text, justification=ugfx.Label.CENTER) +# Prepare to draw name +style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)]) +style.set_background(ugfx.html_color(0x55cdfc)) +ugfx.set_default_style(style) +# Process name +name_setting = name("Set your name in the settings app") +if len(name_setting) <= 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, name_setting, justification=ugfx.Label.CENTER) + +# Draw for wearer to see +ugfx.orientation(270) +ugfx.set_default_font(ugfx.FONT_SMALL) +status = ugfx.Label(0, ugfx.height() - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.LEFT) + +def draw_badge(): + style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)]) + style.set_background(ugfx.html_color(0x800080)) + ugfx.clear(ugfx.html_color(0x800080)) + ugfx.set_default_style(style) + # Logo stuff + ugfx.display_image( + int((ugfx.width() - logo_width) / 2), + int((ugfx.height() - logo_height) / 2), + logo_path + ) + + # Draw for people to see + ugfx.orientation(90) + # Draw introduction + ugfx.set_default_font(ugfx.FONT_TITLE) + ugfx.Label(0, ugfx.height() - name_height - intro_height, ugfx.width(), intro_height, intro_text, justification=ugfx.Label.CENTER) + # Process name + name_setting = name("Set your name in the settings app") + if len(name_setting) <= 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, name_setting, justification=ugfx.Label.CENTER) + + # Draw for wearer to see + ugfx.orientation(270) + ugfx.set_default_font(ugfx.FONT_SMALL) + status = ugfx.Label(0, ugfx.height() - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.LEFT) + +def draw_trans(): + style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)]) + style.set_background(ugfx.html_color(0x55cdfc)) + ugfx.set_default_style(style) + ugfx.display_image(0, 0, "home_magic/trans.png") + + # Logo stuff + ugfx.display_image( + int((ugfx.width() - logo_width) / 2), + int((ugfx.height() - logo_height) / 2)+9, + trans_logo_path + ) + + # Draw for people to see + ugfx.orientation(90) + # Draw introduction + style.set_enabled([ugfx.BLACK, ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be)]) + style.set_background(ugfx.html_color(0xf8b0be)) + ugfx.set_default_style(style) + ugfx.set_default_font(ugfx.FONT_TITLE) + ugfx.Label(0, ugfx.height() - name_height - intro_height, ugfx.width(), intro_height, intro_text, justification=ugfx.Label.CENTER) + # Prepare to draw name + style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)]) + style.set_background(ugfx.html_color(0x55cdfc)) + ugfx.set_default_style(style) + # Process name + name_setting = name("Set your name in the settings app") + if len(name_setting) <= 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, name_setting, justification=ugfx.Label.CENTER) + + # Draw for wearer to see + ugfx.orientation(270) + ugfx.set_default_font(ugfx.FONT_SMALL) + status = ugfx.Label(0, ugfx.height() - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.LEFT) + +# update loop +while True: + text = ""; + value_battery = battery() + if value_battery: + text += "%s%%" % int(value_battery) + if Buttons.is_pressed(Buttons.BTN_Star): + if torch_on: + torch_on = False + torch.off() + neo.display([0,0]) + else: + torch_on = True + torch.on() + neo.display([0xffffff,0xffffff]) + if Buttons.is_pressed(Buttons.BTN_8): + draw_trans() + if Buttons.is_pressed(Buttons.BTN_0): + draw_badge() + status.text(text) + sleep_or_exit(0.5) diff --git a/home_trans/trans.png b/home_trans/trans.png new file mode 100644 index 0000000000000000000000000000000000000000..e788ac39bd18f483c74fc4f71f5bb42ec93dd096 GIT binary patch literal 2688 zcmbVOZEzFE8D6<9#WV@DX${1a%=wI)825B{(&?e2Ug04(mg-$1j|tVIAI@3Xp< zAwPr=fC>xX3ivhvD)RuF2W;Q^_FM}fR|Z!haM44UWp$?oc=Cax4}wBa0SoaT0Ddlb zv=q4J13n)(?*WxXprQo0OF>nUzx_8?e`^O-^NZ>h0}lo~_XBq!V6R-cN&@eE;Ft$! z7x0n5RRmZDEaQOB&NvDHvwz?IrGPD4T2}hP5BpDD)O3B%p1oaNT`cf&U|B=x$H8Fw z#*G`tj`cmhZrujp@9sL<((?2IhsJSSUUB5a@sklb60FfS3PMN6&c>03v9b5JZQs6R zNy*kNTbsa&)u74_xL8b`OGHoipLV-Fqobo>;f6qUpkU#m{!{19pTBVA$k7DwfBNa) z4!v>c#m-LunW~kb^7{49N}nycZ^43n&-P4Ce#C&~AOG=BFCREyjUR&Bxx zeJUn`_#mgHd%9!oeZ5CUp)ELH5dJ*wWbQtWNX{e*xh$-N(*XmDIx{6%DZi8JOrH zm+U_9Zs>6R8Fv}Xz{1qP{^EyLefNR4F2Z3r0^fY=Uk5iVdU!QH3VUGpH(!PD`n50q zeCass+jD6ztX-XHbT5C9TIZ2A7kvMDRA;bv*Mp0hZLoF|ym|38I8@nQxUi3cUaJG}o%_wl0$%A_1i&1igw_~qf-8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