fix(led): stop WS2812 refresh when frame is unchanged so 'off' stays dark - #66
Open
mitchross wants to merge 2 commits into
Open
fix(led): stop WS2812 refresh when frame is unchanged so 'off' stays dark#66mitchross wants to merge 2 commits into
mitchross wants to merge 2 commits into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65
Problem
With brightness set to off, the LEDs blink every ~10-17 seconds (visible in a dark room). Serial console showed the real root cause — a reboot loop:
A commissioned device whose coordinator is unreachable (powered off, out of range, network gone) fails
ESP_ZB_BDB_MODE_INITIALIZATION5 times and then callsesp_restart()— which can't help, so it boot-loops forever. Each boot flashes the LED beforebutton_init()loads the saved brightness from NVS, so a device set to off blinks all night. Likely also related to #54 and #42.Fixes
zigbee.c— stop the reboot loopESP_RST_SW— it didn't help).REJOIN_BACKOFF_MAX_MS= 5 min) instead of restarting.led.c— no boot flash when brightness is offled_intensityat 0 so the LEDs stay dark untilbutton_init()loads the saved brightness.led.c— idle data line when offHardware verification (ESP32-H2, built with IDF v5.5.2)
Flashed and watched serial for 3 minutes with the coordinator unreachable:
Sensors, serial JSON, and BLE keep running throughout. Overnight dark-room test of the off-LED behavior in progress; will report back.
Flashing for testing
Built with
espressif/idf:v5.5.2,idf.py set-target esp32h2 build, then merged to a single image:(Equivalent to the ESP Launchpad DIY flow at address 0x0 from FIRMWARE_UPDATE.md.)
🤖 Generated with Claude Code