Improvements Wishlist

Plugin API: the tones of 0.8 for bars and dots too, and a green one

Completed

StofLESuggested this wish Β·

Plugin API 0.8 gives a plugin ui::set_tone() with ACCENT, BUSY (amber) and ALERT (red) for a tile's labels and icons. A plugin that shows a level (CO2, a battery, a price) also draws bars and dots, and needs the same colours for those, plus a green one for "good". Today a plugin can only reach them through theme::key_swatch() and theme::rgb(), which is not part of the plugin API.

A ui::tone_color(Tone) (or set_tone for a block's fill) and a Tone::GOOD from Home Assistant's green would cover it, in light and dark alike.

Stefan

Discussion 2

Add a comment
MaxGramser Admin

Thanks Stefan, this is on dev now, in plugin API 0.9:

  • Tone::GOOD is Home Assistant's green. It sits beside ACCENT, BUSY (amber) and ALERT (red), and is made readable on the card in light and dark like the others.
  • ui::set_fill(block, tone, normal) gives a block (a bar, a dot, a badge) the colour of a tone. ui::tone_color(tone, normal) returns the colour itself, for a part those two don't reach, such as a line of a chart. normal is the theme role for NORMAL. So a level that is good, moderate or bad is GOOD, BUSY and ALERT, with no key_swatch or rgb needed.
  • One fix came along: ui::label promised one line cut with dots, but kept LVGL's own height, so a long text wrapped onto a second line under the tile. A label is now one line of its font high, and ui::set_font keeps it so.

Tested with the core's host probe plugin on the CYD and the Guition, with and without kept pages: the four tones come out as 4CAF50, FFC107, F44336 and the ink, a block filled with GOOD is green, and a label is exactly one line high. The existing plugins render pixel for pixel as before. A plugin that uses these names api: "0.9"; that comes with the next release, usually within a week, and Tessera's dev firmware has it now. docs/FIRMWARE_API.md in the plugins repository describes them.

The new bench in the plugins repository (tools/preview.py, docs/PREVIEW.md) shows such a tile on every kind of screen in light and dark. It also says when a word or a bar is too faint to read on its ground.

MaxGramser Admin

A correction to my last line: the bench's contrast check looks at text only, not at bars. It reports a word too faint to read on its ground, in light and dark. A bar or a dot in a colour that doesn't stand out shows in the bench's pictures, but no finding names it.

Add your thoughts, a screenshot or a useful link.

Markdown & basic HTML
Paste or drop images Β· URLs on their own line become previews0 / 10,000
Create your account to join in

We need a verified email address to reach you about your contribution. Your address stays private.

Continue with GitHub

Your draft stays in this tab. Return here after verification.