feat(advert): osm úrovní baterie místo dvou stavů, blesk na externím napájení
Dvoustavová ikonka nesla málo informace a ☀️ v ní znamenalo "baterka OK", ne "jsem solár", jak bylo zamýšleno. Teď je ☀ trvalá značka solárního uzlu a za ní jedna z osmi úrovní ▁▂▃▄▅▆▇█. Proč ne emoji: Unicode má přesně DVĚ baterková emoji (U+1F50B, U+1FAAB), žádné "napůl", a po 4 B se dvojice ☀️+🪫 nevejde (7 B suffixu proti 6 B, co jména dovolují). Blokové znaky jsou v BMP, tedy 3 B, a je jich osm -- nejvíc stavů za nejmíň bajtů. Suffix zůstal 6 B, takže se nic nepřejmenovává. ⚡ místo úrovně, když uzel běží na externím napájení. Bere se z VBUS detektu (`MainBoard::isExternalPowered()`, nRF52 to má v hardwaru), ne z heuristiky nad šumem. Řeší to lavici, kde deska bez článku čte plovoucí VBAT a jakákoli úroveň z toho by byla vymyšlená -- a zároveň to na stožáru pozná nabíjení. Hystereze je teď na sedmi hranicích a je asymetrická: úroveň padá hned pod hranicí, stoupá až hyst_mv nad ní. Klesající baterka je ten směr, kde je optimistická ikonka horší než pesimistická. 50 mV pokryje naměřený denní rozkmit 38-46 mV a vejde se do kroku 112 mV. Prefs `bicon_mv` (práh) nahrazeno `bicon_lo`/`bicon_hi` (konce škály), CLI `set batt.icon.lo|.hi`. Default 3300..4200 = táž škála, kterou počítají dashboardy, takže ikonka a Grafana říkají totéž. Ověřeno na lavici svědkem (x4 čte advert z x1): `bench-board☀⚡` opakovaně. Úrovně zatím jen unit testy -- deska na USB vždycky hlásí externí napájení, takže ▁..█ se na lavici ukázat nedá; to ověří až uzel na článku. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78b3c8cce8
commit
c2fb7d1610
5 files changed
+312
-152
No files matched your search
+27
-20
@@ -362,9 +362,9 @@ in order of preference:
|
||||
|
||||
#### Show battery state as an icon on the advertised name
|
||||
|
||||
*(TeTeHacko fork)* Appends a battery icon to the name carried in adverts, so
|
||||
anyone who hears the node can see its state without logging in for telemetry.
|
||||
Off by default.
|
||||
*(TeTeHacko fork)* Appends a solar marker and a charge level to the name
|
||||
carried in adverts, so anyone who hears the node can see its state without
|
||||
logging in for telemetry. Off by default.
|
||||
|
||||
**Usage:**
|
||||
- `get batt.icon`
|
||||
@@ -372,33 +372,40 @@ Off by default.
|
||||
|
||||
**Default:** `off`
|
||||
|
||||
**Icons:** `☀️` above the threshold, `🪫` below it.
|
||||
**Glyphs:** `☀` permanently (solar node), then one of `▁▂▃▄▅▆▇█`
|
||||
for the charge level -- or `⚡` instead of the level while the node runs on
|
||||
external power (USB), where VBAT reads the charger rather than the cell.
|
||||
|
||||
**Note:** The icon costs name bytes, and the LONGER of the two is always
|
||||
budgeted for -- `☀️` is 6 bytes (U+2600 plus an invisible variation
|
||||
selector), `🪫` is 4. With a position in the advert that leaves 17
|
||||
bytes of name. If the name is too long the icon is dropped whole rather than
|
||||
truncated, and `get batt.icon` says so; it also reports the measured voltage
|
||||
and the state the next advert would carry.
|
||||
**Note:** The indicator costs 6 bytes of the name (3 + 3), which with a
|
||||
position in the advert leaves 17. Unicode has only two battery emoji and no
|
||||
"half full" one, and at 4 bytes each they do not fit -- hence block elements,
|
||||
which are 3 bytes and come in eight steps. If the name is too long the whole
|
||||
indicator is dropped rather than truncated, and both `set` and `get` say so.
|
||||
|
||||
**Note:** Switching is hysteretic (`BATT_ICON_HYST_MV`, default 100 mV) so the
|
||||
icon does not follow the daily charge cycle of a solar node. A node drifting at
|
||||
the measured 13 mV/day crosses a threshold about once a month, so the 25 h
|
||||
flood advert interval is not a limitation here.
|
||||
**Note:** Every level is the same byte width on purpose. A name that changed
|
||||
length with the charge would be re-truncated at some steps and not others, and
|
||||
every client that heard it would rewrite the contact.
|
||||
|
||||
**Note:** Switching is hysteretic (`BATT_ICON_HYST_MV`, default 50 mV) and
|
||||
asymmetric -- the level drops as soon as the voltage crosses a boundary but
|
||||
climbs only once clear of it. The measured daily swing of a solar node under
|
||||
weak sun is 38-46 mV and the drift 13 mV/day, so at eight levels the name
|
||||
changes roughly once a week.
|
||||
|
||||
---
|
||||
|
||||
#### Battery threshold for the name icon
|
||||
#### Battery scale for the name icon
|
||||
**Usage:**
|
||||
- `get batt.icon.mv`
|
||||
- `set batt.icon.mv <millivolts>`
|
||||
- `get batt.icon.lo` / `set batt.icon.lo <millivolts>`
|
||||
- `get batt.icon.hi` / `set batt.icon.hi <millivolts>`
|
||||
|
||||
**Set by build flag:** `BATT_ICON_LOW_MV`
|
||||
**Set by build flag:** `BATT_ICON_LO_MV`, `BATT_ICON_HI_MV`
|
||||
|
||||
**Default:** `3700` (roughly 44 % of a 1S Li-Ion cell)
|
||||
**Default:** `3300` and `4200` -- the same 1S Li-Ion scale the dashboards use,
|
||||
so the icon and the Grafana percentage tell one story.
|
||||
|
||||
**Parameters:**
|
||||
- `millivolts`: `3000`..`4200`, or `0` to use the build default
|
||||
- `millivolts`: `2500`..`4500`, or `0` to use the build default
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user