Battery icon
A battery that shows how full it is: an outline and a nub in a colour of their own, and a fill as long as its level in a colour you choose for each state it can be in - charged, low, critical or charging - with a lightning bolt over it while it charges. It is an icon and nothing else. Its Level and Charging are bound to variables, usually ones read from the board's power chip; the figure in per cent is a label of your own, bound to the same variable. It is drawn from plain boxes and lines, so it is sharp at any size: its width and height are its size. It is free.


| Fill | When | Colour to start with |
|---|---|---|
| Charging | Charging is on, whatever the level. With Bolt while charging ticked, a bolt in the bolt colour is drawn over the middle. | Blue |
| Critical | The level is at or below Critical at. | Red |
| Low | The level is at or below Low at. | Orange |
| Charged | Above Low at. | Green |
The level is a whole per cent, 0 to 100. Below 0 it shows empty, which is what a power chip with no battery fitted reads (-1); above 100 it shows full. The outline and the nub are the Outline colour, grey to start with, whatever the level. Orientation lays it down with the nub on the right, or stands it up with the nub on top and the fill rising from the bottom.
Two of its properties can be bound, under Data bindings: Level (0-100 %) and Charging. On a board with a power chip (an AXP2101 or an AXP192), add two variables on the Data tab with their Source set to the chip's Battery charge and Charging, and bind one to each. A battery read on an analog pin works too: a variable with that pin as its source and a formula that turns its reading into a per cent. The board redraws the icon only when what it is told differs from what it shows. Arduino and ESP-IDF exports; MicroPython and ESPHome do not have it, and a Bar bound to the same reading shows the level there.
Example: the charge, from a variable
- On the Data tab, add a variable
battery, an Integer starting at20, and a variablecharging, a Boolean. On a board with a power chip, set their Source to its Battery charge and Charging. - Drag a Battery icon onto the screen, name it
Chargeand make it80×40. - Under Data bindings, add a binding from
batterythat drives Level (0-100 %), and one fromchargingthat drives Charging. - Drag a Label beside it with a font size of
20 px, and bind it tobatterydriving Text, with%after it. - Press Preview: at 20 the battery is low, and its fill orange.

