header

Header bar: data time and next update left, battery right.

Kept apart from layout so that header-only updates only import the small font (the large fonts take a while to import on the board).

A header is described by a dict, which is also what gets stored between wakes to redraw the previous header for partial display updates:

{"data": "HH:MM" or None, "next": "HH:MM" or None,
 "battery": percent (int), "charging": bool, "online": bool,
 "reachable": bool}

“data” is the time of the last data that reached the board, “next” that of the next planned update. The text reads “Stand 09:12 · neu 09:22”; while the data source is unreachable “Stand 09:02 · offline”. A WLAN symbol shows that the board can be reached over the WLAN right now (awake and maintenance mode); a sleeping board is not, even though it was connected while it drew the screen.

Attributes

Functions

make_header(data_time, next_time, battery_percent, ...)

Build a header dict (see the module docstring).

status_text(header)

Return the text on the left: data time and next update, or offline.

draw_header(fb, header)

Draw the header bar at the top of fb (at least WIDTH x HEIGHT).

Module Contents

header.WIDTH = 400
header.HEIGHT = 30
header.MARGIN = 10
header.BLACK = 0
header.WHITE = 1
header.CHARGING_ICON = 'lightning'
header.WLAN_ICON = 'wifi-high'
header.ICON_GAP = 2
header.OFFLINE_TEXT = 'offline'
header.SEPARATOR = ' · '
header.make_header(data_time, next_time, battery_percent, charging, online, reachable=False)

Build a header dict (see the module docstring).

Parameters:
  • data_time – Time of the last data, such as “09:12”, or None.

  • next_time – Time of the next planned update, or None.

  • battery_percent – Battery level, rounded for display.

  • charging – Whether to show the charging symbol.

  • online – Whether the data source was reachable.

  • reachable – Whether to show the WLAN symbol.

Returns:

The header dict.

header.status_text(header)

Return the text on the left: data time and next update, or offline.

header.draw_header(fb, header)

Draw the header bar at the top of fb (at least WIDTH x HEIGHT).