Skip to content

fix(led): stop WS2812 refresh when frame is unchanged so 'off' stays dark#66

Open
mitchross wants to merge 2 commits into
StuckAtPrototype:masterfrom
mitchross:fix/led-blink-when-off
Open

fix(led): stop WS2812 refresh when frame is unchanged so 'off' stays dark#66
mitchross wants to merge 2 commits into
StuckAtPrototype:masterfrom
mitchross:fix/led-blink-when-off

Conversation

@mitchross

Copy link
Copy Markdown

Fixes #65

Problem

With brightness set to off, the LEDs blink faintly every ~10 seconds (visible in a dark room). The cadence matches the Zigbee + BLE sensor push in main.c.

led_task rewrites an identical frame to the WS2812 pixels every 20 ms, keeping the data line permanently active. A frame that coincides with the 10-second radio TX burst can get corrupted, so the pixels briefly latch a random color even at intensity 0.

Fix

In led_task:

  • Only write when the frame changes. Smooth hue transitions still update at 50 Hz exactly as before, since the color changes each cycle while animating.
  • Repeat writes for 500 ms after a change so a corrupted transition frame self-heals instead of sticking.
  • Refresh at 1 Hz while visibly lit as a safety net against a latched glitch.
  • Keep the data line fully idle once settled at off — nothing left to corrupt, so off stays dark.

Also restructures the duplicated mutex/fallback branches into a single read-then-write path.

Testing

  • Code-reviewed against the existing task structure; not yet flashed to hardware (will report back after running it overnight on my unit).

🤖 Generated with Claude Code

mitchross and others added 2 commits July 11, 2026 00:55
…dark

The LED task rewrote an identical frame to the WS2812 strip every 20ms,
keeping the data line permanently active. The Zigbee + BLE sensor push
every 10 seconds (radio TX burst, with DFS enabled) can corrupt one of
those frames, so the pixels briefly latch a random color - visible as a
blink every ~10s even with brightness set to off.

Only write to the strip when the frame actually changes. After a change,
repeat the frame for 500ms so a corrupted transition write self-heals.
While visibly lit, refresh once per second as a safety net. Once settled
at off, keep the data line fully idle so nothing can flash at night.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A commissioned device that cannot reach its coordinator (powered off,
out of range, network gone) failed initialization 5 times and then
called esp_restart() - which changes nothing, so the device boot-looped
every ~17 seconds forever. Each boot also flashed the LED before the
saved brightness loaded from NVS, so a device with brightness set to
off blinked all night.

- Reboot at most once per power cycle (skip when the last reset was
  already our own SW restart), then keep retrying initialization with
  exponential backoff capped at REJOIN_BACKOFF_MAX_MS (5 min).
- Start led_intensity at 0 so boots stay dark until button_init() loads
  the saved brightness.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

LED blinks every ~10s when brightness is set to off

1 participant