Skip to content

Keep a dimmed colour's zero channels at zero - #82

Merged
AndreasBur merged 1 commit into
masterfrom
dimmed-colour-keeps-its-zero-channels
Oct 27, 2026
Merged

AndreasBur merged 1 commit into
masterfrom
dimmed-colour-keeps-its-zero-channels

Conversation

@theAndreas

Copy link
Copy Markdown
Collaborator

DisplayColor::dimmColor lifted every channel that rounded down to 0 back up to 1. That included channels the colour does not have at all. A pure red (255, 0, 0) therefore reached the strip as (127, 1, 1) at half brightness: a red with a trace of green and blue. Black came out as a faint white.

The lift has been there since DisplayColor was added in 2021, with no reason given. The test from September recorded the behaviour exactly as it was, zero channels included.

What changed

  • A channel the colour does not have stays at 0. This now matches the other dimming path, Pixel::dimmColor, which already left zero channels at 0.
  • A channel the colour has still never rounds down to nothing. That is what keeps a lit word visible at the lowest brightness.

Measured

  • testColourDimmingAcrossByteRange now expects 0 for a 0 channel. A new check dims a pure red at brightness 0 and 128. Made to fail on purpose: against the old code, exactly these three expectations fail.
  • AVR flash: unchanged at 48 116 bytes.
  • Built: simulator with ctest, AVR, ESP32, RP2350, and both host-test suites. tools/documented-sizes.py passes, and clang-tidy is clean on all four builds.

This touches neither the gamma correction nor #81. The two branches are independent of each other.

DisplayColor::dimmColor lifted every channel that rounded to 0 up to 1,
including the ones the colour does not have at all - so a pure red
(255, 0, 0) reached the strip as (127, 1, 1) at half brightness, a red
with a trace of green and blue, and black came out as a faint white.
The lift has been there since the class was added in 2021, without a
reason given; the test from September pinned the whole behaviour as it
was, zero channels included.

A channel the colour has still never rounds down to nothing, which is
what keeps a lit word visible at the lowest brightness. A channel it
does not have stays off, as it already did where the strip dims
(Pixel::dimmColor).

The byte-pair test now expects 0 for a 0 channel, and a new check
dims a pure red at brightness 0 and 128. Against the old code exactly
those three expectations fail.

AVR flash unchanged at 48116 bytes. Built: simulator with ctest, AVR,
ESP32, RP2350, both host suites; clang-tidy clean on all four builds.
@AndreasBur
AndreasBur merged commit b0812cb into master Oct 27, 2026
11 checks passed
@theAndreas
theAndreas deleted the dimmed-colour-keeps-its-zero-channels branch October 27, 2026 12:30
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.

3 participants