Separate out StatusLED so it can be used for repeater#1667
Separate out StatusLED so it can be used for repeater#1667andyshinn wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extracts the status LED blink logic into a reusable StatusLED helper class so it can be used across multiple example applications (including repeater testing), and updates companion radio UIs and the simple repeater example to use it.
Changes:
- Added
src/helpers/StatusLED.hencapsulating status LED timing and alert/blink behavior. - Updated
examples/companion_radio(ui-orig and ui-new) to replace inlined LED handler code withStatusLED. - Updated
examples/simple_repeater/main.cppto optionally initialize and runStatusLEDwhenPIN_STATUS_LEDis defined.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/helpers/StatusLED.h | Introduces a reusable status LED blinker/alert helper. |
| examples/simple_repeater/main.cpp | Wires StatusLED into the repeater example’s setup/loop. |
| examples/companion_radio/ui-orig/UITask.h | Adds StatusLED member and initializes it when enabled. |
| examples/companion_radio/ui-orig/UITask.cpp | Removes old LED timing code and uses StatusLED in begin()/loop(). |
| examples/companion_radio/ui-new/UITask.h | Adds StatusLED member and removes old LED state fields. |
| examples/companion_radio/ui-new/UITask.cpp | Removes old LED handler and uses StatusLED in begin()/loop(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| void loop() { | ||
| unsigned long now = millis(); | ||
| if (now > _next_change) { |
There was a problem hiding this comment.
millis() rollover isn’t handled safely here: if (now > _next_change) will break after wraparound (~49 days). Use a wrap-safe comparison like (long)(now - _next_change) >= 0 (and keep _next_change as unsigned long) so the blink timing continues working across rollovers (see VolatileRTCClock::tick using unsigned subtraction in src/helpers/ArduinoHelpers.h).
| if (now > _next_change) { | |
| if ((long)(now - _next_change) >= 0) { |
02c5f33 to
caa9a4b
Compare
Separates out the StatusLED to its own class so it can be used with repeaters for testing.