layout

Dashboard layout: draws readings as a grid of tiles below a header bar.

Knows nothing about where readings come from (see datasource); tiles say which reading keys to show and how. Draws onto any framebuf-like object (see text).

Attributes

Functions

format_value(value[, decimals, states])

Display text for a reading value (German decimal comma).

pick_value_font(value, unit, space)

Large font if value and unit fit into space pixels, else medium.

icon_for(value, icons)

Name of the icon for a string value, or None to show text.

draw_tile(fb, tile, reading, x, y, w, h)

One tile: label on top, value with unit below, trend arrow top right.

draw_value(fb, value, unit, left, space, baseline)

Value in the large (or, if too wide, medium) font with its unit.

link_tile_index(tile_count)

The bottom-left tile, which shows the web interface's QR code.

draw_link_tile(fb, url, x, y, w, h)

QR code for url with a short caption right of it.

draw_notice_tile(fb, lines, x, y, w, h)

Warning symbol with up to two lines of text, e.g. to charge the board.

draw_alerts(fb, active, top)

Draw the warning screen below top.

render(fb, readings, tiles, header[, link, notice, ...])

Draw the whole screen.

Module Contents

layout.WIDTH = 400
layout.HEIGHT = 300
layout.COLUMNS = 2
layout.MARGIN = 10
layout.NO_VALUE = '?'
layout.format_value(value, decimals=None, states=None)

Display text for a reading value (German decimal comma).

layout.pick_value_font(value, unit, space)

Large font if value and unit fit into space pixels, else medium.

layout.icon_for(value, icons)

Name of the icon for a string value, or None to show text.

layout.TREND_ICONS
layout.draw_tile(fb, tile, reading, x, y, w, h)

One tile: label on top, value with unit below, trend arrow top right.

layout.draw_value(fb, value, unit, left, space, baseline)

Value in the large (or, if too wide, medium) font with its unit.

layout.QR_MODULE_PX = 3

The bottom-left tile, which shows the web interface’s QR code.

QR code for url with a short caption right of it.

layout.NOTICE_ICON = 'battery-warning'
layout.draw_notice_tile(fb, lines, x, y, w, h)

Warning symbol with up to two lines of text, e.g. to charge the board.

layout.ALERT_ICON = 'warning-circle'
layout.ALERT_TITLE_LINES = 3
layout.draw_alerts(fb, active, top)

Draw the warning screen below top.

Shows the first (most severe) alert with icon, title, as much text as fits and a facts line; further alerts are counted.

layout.render(fb, readings, tiles, header, link=None, notice=None, active_alerts=None)

Draw the whole screen.

readings is what a data source’s read() returns, tiles a list of {“key”, “label”[, “decimals”, “unit”, “states”, “icons”]} dicts in display order, header a header dict (see header). Tiles whose key is missing from readings show no value. “icons” maps string values to icon names in icons_large; values without an icon are shown as text. With link (a URL), the bottom-left tile shows it as QR code instead of its reading; otherwise notice (a list of up to two text lines) shows a warning there. active_alerts (see alerts, most severe first) replace all tiles with a warning screen.