Skip to content

test(color): measure what irregular dwell costs the dither (#4347) - #4393

Merged
zackees merged 1 commit into
masterfrom
test/4347-irregular-dwell
Sep 12, 2026
Merged

zackees merged 1 commit into
masterfrom
test/4347-irregular-dwell

Conversation

@zackees

@zackees zackees commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Completes the test half of R8's contract sentence. Part of #4034.

State advances on presentation according to the documented driver contract, with explicit tests for dropped submissions and irregular dwell.

#4348 and #4361 did dropped submissions. This is dwell — and it is a separate defect on a separate axis, because dither correctness is a time-weighted mean: a phase held twice as long counts twice, whether or not anything was dropped.

Measured

1/4 brightness, source code 9:

dwell rendered
even 2.38
low-offset phases held 3:1 2.19
high-offset phases held 3:1 2.57

Nothing is dropped; every phase still reaches the wire.

0.38 codes of swing against the drop case's 0.75, and that ratio is not coincidence — dropping a parity gives the survivors 100% of the weight, holding 3:1 gives them 75%, so the displacement from the even-dwell mean is half as far. Dwell reaches the same place as dropping, by degrees.

Why it needs its own test

An implementation that advanced the phase on presentation — the fix R8 defers — would close the drop half of that sentence and leave this half exactly as it is. Dwell is about how long a presented frame stays up, not whether it was presented.

Control

Dwell that is irregular against the frame clock but uniform against the phase: every frame twice as long, mean unmoved. Correlation is the fault, not jitter — the same distinction the drop test draws.

One thing I got wrong first

The helper weights by the phase's own parity, not by position in the loop. Indexing by position is what I wrote initially, and it silently reversed the sign of the whole measurement: the cycle starts wherever the global counter happens to be, so a fixed array lands on whichever parity it lands on. It is recorded in the helper so the next reader does not repeat it.

I also set the swing bound before measuring and had to correct it — 0.38, not the >0.5 I assumed by analogy with the drop case.

Verification

Making the weighting uniform fails three assertions.

bash lint clean; 305/305 unit, 84/84 examples.

Test-only; no src/ change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9

Summary by CodeRabbit

  • Tests
    • Added coverage for irregular timing during dithering.
    • Verified that phase-correlated dwell durations shift rendered averages, while uniform dwell preserves them.

The contract sentence R8 is about asks for two tests: "with explicit tests for
dropped submissions and irregular dwell." #4348 and #4361 did drops. This is
dwell, and it is a separate defect on a separate axis -- dither correctness is
a time-weighted mean, so a phase held twice as long counts twice, whether or
not anything was dropped.

Measured at 1/4 brightness, source code 9. Holding the phases that carry the
low half of the bit-reversed offsets three times as long renders 2.19 against
2.57 for the opposite weighting, either side of the 2.38 that even dwell
gives. Nothing is dropped; every phase still reaches the wire.

0.38 codes of swing against the drop case's 0.75, and that ratio is not
coincidence: dropping a parity gives the survivors 100% of the weight while
holding 3:1 gives them 75%, so the displacement is half as far. Dwell reaches
the same place as dropping, by degrees.

Which is why it wants its own test. An implementation that advanced the phase
on presentation -- the fix R8 defers -- would close the drop half of that
sentence and leave this half exactly as it is, because dwell is about how long
a presented frame stays up, not whether it was presented.

The control is dwell that is irregular against the frame clock but uniform
against the phase: every frame twice as long, mean unmoved. Correlation is the
fault, not jitter.

The helper weights by the phase's own parity rather than by position in the
loop. Indexing by position is what I wrote first, and it silently reversed the
sign -- the cycle starts wherever the global counter is, so a fixed array
lands on whichever parity it lands on. Recorded in the helper so the next
reader does not repeat it.

Verified by making the weighting uniform, which fails three assertions.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
@zackees
zackees merged commit eda0dc7 into master Sep 12, 2026
4 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Sep 12, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 12, 2026
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 26a44954-74df-413a-a47d-45ee841e9a57

📥 Commits

Reviewing files that changed from the base of the PR and between 83ab204 and 82c040c.

📒 Files selected for processing (1)
  • tests/pixel_controller.cpp

📝 Walkthrough

Walkthrough

The test suite adds a time-weighted mean helper and covers irregular and uniform temporal dwell across dither phases.

Changes

Dither dwell tests

Layer / File(s) Summary
Weighted mean calculation
tests/pixel_controller.cpp
Adds dwellWeightedMean to weight each dither phase by its parity-specific hold duration.
Dwell behavior coverage
tests/pixel_controller.cpp
Verifies that phase-correlated 3:1 dwell shifts the mean in opposite directions, while uniform dwell preserves the mean.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/4347-irregular-dwell

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

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees deleted the test/4347-irregular-dwell branch November 5, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant