Skip to content

fix(power): never dim the strip as the budget rises past the baseline (#5139) - #5159

Merged
zackees merged 1 commit into
masterfrom
test/autoresearch-power-limit-5139
Nov 8, 2026
Merged

zackees merged 1 commit into
masterfrom
test/autoresearch-power-limit-5139

Conversation

@zackees

@zackees zackees commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #5153 (#5139). Adds a hardware power-limit test to AutoResearch, and fixes the limiter cliff that test found.

What the hardware found

#5153 works as described for budgets at or under the baseline (MCU + dark current). Those budgets now get the classic ratio instead of a blank strip, on both the legacy addLeds path and the Channel API. Just above the baseline, though, the headroom answer took over and was much smaller:

ESP32-C6, 100 WS2812B over RMT, baseline 625 mW, frame 0 (full demand 13427 mW):

Budget Before After
625 mW 11 11
626 mW 0 (dark) 11
1000 mW 6 11
2000 mW 26 26

Fix

Above the baseline, the limiter returns at least the classic answer for a budget at the baseline, so brightness never falls as the budget rises.

Trade-off: until the headroom answer overtakes the floor, at a budget of about baseline + controllable * baseline / full, the modeled draw exceeds the budget by up to controllable * baseline / full. That is the same excess a budget at the baseline already has. The range can be wide: with fixed = controllable = 5 W, budgets from 5001 to about 7490 mW all return 127. power_mgt.h and the tests now state this bound.

Test harness

  • bash autoresearch <env> --rmt [--legacy] --max-power-mw 50,400,625,626,700,1000,2000,4000,1000000 runs one runSingleTest per budget with dithering off.
  • The device compares every captured wire byte with the source scaled by the limiter's brightness, within ±2.
  • ci/autoresearch/power_check.py checks the policy against the brightness measured on the wire: unlimited is 255; at or under the baseline the classic ratio; above it, never dimmer than at the baseline and within budget once past the floor. It also fails if a budget was sent but the firmware returned no power frames.
  • Restricted to one RGB clockless lane. RGBW legacy chipsets such as WS2814 are rejected with MaxPowerUnsupportedConfig.

Evidence

  • Hardware (ESP32-C6, RMT, GPIO0→GPIO1 loopback), all 9 budgets: legacy API PASS 10/10, Channel API PASS 10/10.
  • bash test power_mgt (quick and --debug, no sanitizer findings), fastled_core, power_prepass, power_estimation: all pass. New test: "raising the budget never dims the strip". The 64-bit reference model is updated to the same rule.
  • bash lint: clean.

Not covered

Summary by CodeRabbit

  • New Features
    • Added optional power-budget limits to single-test runs, with support for running tests across multiple budgets.
    • Test results now report power demand, baseline draw, brightness scaling, and whether each frame meets the configured limit. Power-limited tests are flagged when validation fails.
  • Improvements
    • Power management now maintains a minimum brightness near fixed baseline demand and provides nondecreasing brightness recommendations as budgets increase. This may allow modeled power draw to exceed the budget near the baseline.

…#5139)

#5153 gave budgets at or under the MCU + dark-current baseline the classic
ratio, but one milliwatt above the baseline the headroom answer took over and
was far smaller. On hardware (ESP32-C6, 100 WS2812B, baseline 625 mW) 625 mW
lit the strip at 11 and 626 mW blanked it; 1000 mW gave 6.

The limiter now floors its above-baseline answer at what a budget at the
baseline gets, so brightness is monotone in the budget. Until the headroom
answer overtakes the floor the modeled draw is over budget by up to
controllable * baseline / full, the same excess a baseline budget has; the
public docs and tests state that bound.

AutoResearch gains --max-power-mw (runSingleTest maxPowerMw): one run per
budget with dithering off, comparing every captured wire byte against the
source scaled by the limiter's brightness, plus host checks of the policy on
the measured wire scale.
@zackees
zackees enabled auto-merge November 8, 2026 06:52
@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 8, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The change updates the power limiter’s brightness recommendation and adds power-limited autoresearch runs. The remote test API returns per-frame power data, and the CI workflow can run and validate tests for multiple requested power budgets.

Changes: Power-limited autoresearch

Layer / File(s) Summary
Baseline brightness floor
src/power_mgt.cpp.hpp, src/power_mgt.h, tests/power_mgt.cpp
The limiter applies a baseline-derived floor to its brightness recommendation. Tests check the floor, bounded budget overshoot, and nondecreasing recommendations. The API documentation describes this behavior.
Power-limited capture and comparison
examples/AutoResearch/AutoResearchTest.h, examples/AutoResearch/AutoResearchTest.cpp
AutoResearchConfig and RunResult add power-limit settings and capture fields. Limited-power runs configure the limiter, record power measurements, and compare scaled RGB output with a tolerance.
Remote power-limit API
examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
The remote single-test API accepts and validates maxPowerMw, restricts configurations when a limit is enabled, and includes per-frame power measurements in its response.
CI budget runs and validation
ci/autoresearch/args.py, ci/autoresearch/phases.py, ci/autoresearch/power_check.py
The CLI accepts positive comma-separated power budgets, and CI submits a test for each budget. Response checks validate power-frame data and report failures or display frame details.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AutoresearchPhases
  participant RemoteSingleTest
  participant AutoResearchTest
  participant PowerFrameChecker
  AutoresearchPhases->>RemoteSingleTest: submit runSingleTest with maxPowerMw
  RemoteSingleTest->>AutoResearchTest: run with power limit
  AutoResearchTest-->>RemoteSingleTest: return run results and power measurements
  RemoteSingleTest-->>AutoresearchPhases: return powerFrames
  AutoresearchPhases->>PowerFrameChecker: validate response against requested budget
Loading

Possibly related issues

Merge Risk: Moderate · up to 36595

Resolve the broken phase tests and power-test validation gaps before merging. Requested budgets can be ignored in parallel mode, correct captures can fail validation, and incomplete captures can pass. Large requests also risk exhausting device memory, while nonlinear power models exceed the documented bound.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Nov 8, 2026
@github-actions github-actions Bot added security: unscreened-content and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, 0 is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (0) 136 (0)

Merged via the queue into master with commit 05d9367 Nov 8, 2026
131 of 132 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Nov 8, 2026
@zackees
zackees deleted the test/autoresearch-power-limit-5139 branch November 17, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant