From 4a6271de0731a163e143bbefdb51f94323fee152 Mon Sep 17 00:00:00 2001 From: Kimball Johnson Date: Sat, 15 Sep 2018 09:53:09 +0100 Subject: [PATCH] Add homescreen for PyCon --- home_pycon/main.py | 93 +++++++++++++++++++++++++++++++++++ home_pycon/python_single.png | Bin 0 -> 963 bytes 2 files changed, 93 insertions(+) create mode 100644 home_pycon/main.py create mode 100644 home_pycon/python_single.png diff --git a/home_pycon/main.py b/home_pycon/main.py new file mode 100644 index 0000000..bad3158 --- /dev/null +++ b/home_pycon/main.py @@ -0,0 +1,93 @@ +"""Default homescreen + +This is the default homescreen for the Tilda Mk4. +It gets automatically installed when a badge is +newly activated or reset. +""" + +___title___ = "Homescreen (PyCon)" +___license___ = "MIT" +___categories___ = ["Homescreens"] +___dependencies___ = ["homescreen"] +___launchable___ = False +___bootstrapped___ = True + +import ugfx +from homescreen import * +import time +from tilda import Buttons + +init() + +# Padding for name +intro_height = 30 +intro_text = "Hi! I'm" +name_height = 60 +status_height = 20 +info_height = 30 +logo_path = "home_pycon/python_single.png" +logo_height = 82 +logo_width = 55 + +# Maximum length of name before downscaling +max_name = 8 + +# Background stuff +bg_color = 0xfecb2f +ugfx.clear(ugfx.html_color(bg_color)) + +# Colour stuff +style = ugfx.Style() +style.set_enabled([ugfx.BLACK, ugfx.html_color(bg_color), ugfx.html_color(bg_color), ugfx.html_color(bg_color)]) +style.set_background(ugfx.html_color(bg_color)) +ugfx.set_default_style(style) + +# Draw for people to see +ugfx.orientation(90) + +# Logo stuff +ugfx.display_image( + int((ugfx.width() - logo_width) / 2), + int((ugfx.height() - logo_height) / 2), + logo_path +) + + + + +# 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) +# Title +ugfx.set_default_font(ugfx.FONT_TITLE) +ugfx.Label(0, ugfx.height() - info_height * 2, ugfx.width(), info_height, "TiLDA Mk4", justification=ugfx.Label.CENTER) +# info +ugfx.Label(0, ugfx.height() - info_height, ugfx.width(), info_height, "Long Press MENU", justification=ugfx.Label.CENTER) + +ugfx.set_default_font(ugfx.FONT_SMALL) +status = ugfx.Label(0, ugfx.height() - info_height * 2 - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.CENTER) + +# update loop +while True: + text = ""; + value_wifi_strength = wifi_strength() + value_battery = battery() + if value_wifi_strength: + text += "Wi-Fi: %s%%, " % int(value_wifi_strength) + if value_battery: + text += "Battery: %s%%" % int(value_battery) + status.text(text) + sleep_or_exit(0.5) diff --git a/home_pycon/python_single.png b/home_pycon/python_single.png new file mode 100644 index 0000000000000000000000000000000000000000..1eaae1ce92c48eb8ec84bf65f3e2d4ac7f0734dc GIT binary patch literal 963 zcmeAS@N?(olHy`uVBq!ia0vp^=0F_8!3HEhJn~r&q*#ibJVQ8upoSx*1IXtr@Q5sC zVBk9f!i-b3`J{n@k|nMYCBgY=CFO}lsSM@i<$9TU*~Q6;1*v-ZMd`EO*+?-kFgtj< zIEGZrc{|%bCnQv)eSh)&*IN|k+Iy`LS|O;SxTGzCBXOzFg)s4~9@Ruor$y2c4hSGIE8hWqoSso6f@_wR>mn8KCF+3T9BG{Ys=-CmU;;tqQCB4;9FmO z^6#|g^NQcU_kOp>e6vL2vL(hFk9h3y_1e-{>DX(hf66I=aRSpvhsO;JC#!=k7jXD6 zR4VAdu>$d+BuJ@89o0YN~Z}1#CH-$08D0OlBrr5X3o1~hb zUYZ$UBz~W1Q}6EUYxW7$g?)K!9V@FYx6g)k-q z`(M9YHn$No+2-NBbnk(0yRRGFy*uTM*gvO?UZoOK8}a-nAC^sB6C*M|L|%W|&Dt+E z?Df0FOyq!l;+oXUQLL8|s}`g{HKyPJMGMxT*BdHk9L!_=bZ z$)_xJ@5Np`beenC@)+?(+1KLjxt|~HW$#+EDsq$5hhLY{ovOohdLGYgFrWHJ(#lxw zLeTCEHJZT{h?kiW?5D?AvvAh^K9;dohO&)SM&r$uAa9(dncFkVqumdK II;Vst0KFE#jsO4v literal 0 HcmV?d00001