def test_name(self): o = database.get("homescreen.name") database.delete("homescreen.name") self.assertEqual(homescreen.name("default"), "default") database.set("homescreen.name", "foo") self.assertEqual(homescreen.name("default"), "foo") database.set("homescreen.name", o)
def draw_name(): # Orientation for other people to see ugfx.orientation(90) ugfx.set_default_font(ugfx.FONT_NAME) # 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)
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)
"""Default homescreen This is the default homescreen for the Tilda Mk4. It gets automatically installed when a badge is newly activated or reset. """ ___name___ = "Homescreen (Default)" ___license___ = "GPL" ___categories___ = ["homescreen"] ___launchable___ = False ___bootstrapped___ = True print("there") import ugfx, homescreen homescreen.init(color=0xe4ffdb) ugfx.display_image(0, 0, "home_default/bg.gif") ugfx.text(20, 20, homescreen.name(), ugfx.BLACK)