Skip to content

Add live estimated LED power draw to the LED Settings page#605

Open
wildemat wants to merge 2 commits into
onlaj:masterfrom
wildemat:feature/led-power-estimate
Open

Add live estimated LED power draw to the LED Settings page#605
wildemat wants to merge 2 commits into
onlaj:masterfrom
wildemat:feature/led-power-estimate

Conversation

@wildemat

@wildemat wildemat commented Jul 17, 2026

Copy link
Copy Markdown

What

Screen.Recording.2026-07-17.at.2.35.05.PM.mov

Adds an Estimated LED draw card to the LED Settings page (#ledsettings) showing the strip's current (A) and power (W), computed live from the pixel buffer PLV is already driving — no external meter or PSU tap required.

current ≈ N·idle_ma + (Σ subpixel/255)·ma_per_channel·(brightness/255)

Since real draw depends on the LED chip/strip, the card has three inputs so each user can match their hardware:

  • mA/ch — per-color-channel current at full (default 20, typical WS2812B)
  • idle mA — per-LED quiescent current (default 1)
  • Volts — supply voltage (default 5)

It also shows the theoretical max (all LEDs full white) as a headroom reference — handy for sizing a PSU or checking you're under budget at a given brightness.

How it works

  • estimate_led_power() in views_api.py reads strip.getPixels() and scales by the strip brightness; exposed on a dedicated GET /api/get_led_power endpoint (kept off the homepage data path so it only runs when the card is visible).
  • The LED Settings page polls that endpoint every 1.5 s while the tab is open; the interval is started when the tab loads and cleared on navigation away (ui.js / index.js).
  • New settings led_ma_per_channel / led_idle_ma / led_supply_voltage (defaults 20 / 1 / 5) in default_settings.xml, persisted via change_setting.
  • Card lives in ledsettings.html; ui.js renders the values and populates the inputs (the input being edited is not clobbered).
  • README FAQ entry.

It's an estimate of commanded output, not a measurement: it ignores per-LED regulation variance, voltage droop and wiring losses.

🤖 Generated with Claude Code

wildemat added 2 commits July 17, 2026 14:05
Shows estimated strip current (A) and power (W) on the homepage, computed
from the live pixel buffer — no physical sensor or PSU connection needed:

    current ≈ N·idle_ma + (Σ subpixel/255)·ma_per_channel·(brightness/255)

Because draw varies by LED chip/strip, three inputs on the card let users
tune it: mA per color channel at full, per-LED idle mA, and supply voltage
(defaults 20 / 1 / 5, matching typical WS2812B @ 5V). The card also shows the
theoretical max (all LEDs full white) as a headroom reference.

- estimate_led_power() in views_api, merged into /api/get_homepage_data
- new settings led_ma_per_channel / led_idle_ma / led_supply_voltage
- change_setting persists them; homepage card + JS render and populate inputs
- README FAQ entry
Reacts live to brightness/color/mode changes, which is where users adjust
them. Adds a dedicated lightweight /api/get_led_power endpoint polled only on
that page (every 1.5s), instead of riding on the heavier homepage payload.
Removes the homepage card and its updater.
@wildemat wildemat changed the title Add live estimated LED power draw to the dashboard Add live estimated LED power draw to the LED Settings page Jul 17, 2026
@wildemat
wildemat marked this pull request as ready for review July 17, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant