def draw_user_info(): # Draw for the user to see ugfx.orientation(270) # Calc width center of screen center_width = int(ugfx.width() / 2) ugfx.set_default_font(ugfx.FONT_SMALL) 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) ugfx.text(center_width, ugfx.height() - info_height, wifi_message, ugfx.BLACK) battery_value = homescreen.battery() if battery_value: battery_message = 'Battery: %s%%' % int(battery_value) ugfx.text(0, ugfx.height() - info_height, battery_message, ugfx.BLACK)
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()
def test_wifi_strength(self): # test that it doesn't throw an exception homescreen.wifi_strength()