Skip to content

make relay post-switching delay a config parameter#5738

Open
DedeHai wants to merge 2 commits into
wled:mainfrom
DedeHai:relay_delay_cfg
Open

make relay post-switching delay a config parameter#5738
DedeHai wants to merge 2 commits into
wled:mainfrom
DedeHai:relay_delay_cfg

Conversation

@DedeHai

@DedeHai DedeHai commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Can be set in relay configuration, stored in cfg.

Summary by CodeRabbit

  • New Features

    • Added a configurable relay activation delay in the LED settings.
    • The relay delay (in milliseconds) can be adjusted via the Relay controls and is persisted in configuration.
    • Settings import/export now include the relay delay value.
  • Bug Fixes

    • Relay activation timing now uses the configured relay delay consistently instead of a fixed default value.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d4296623-8370-41e0-b313-418a5052033a

📥 Commits

Reviewing files that changed from the base of the PR and between cd9ae4b and dadd53c.

📒 Files selected for processing (1)
  • wled00/data/settings_leds.htm
🚧 Files skipped from review as they are similar to previous changes (1)
  • wled00/data/settings_leds.htm

Walkthrough

Adds a configurable relay-to-LED stabilization delay, exposes it in LED settings, persists it as relay.del, supports build-time defaults, and uses the configured value during relay activation.

Changes

Configurable relay delay

Layer / File(s) Summary
Relay delay contract
wled00/const.h, wled00/wled.h
Defines an overridable 50 ms default and introduces the relayDelay global initialized from it.
Settings and persistence
wled00/data/settings_leds.htm, wled00/xml.cpp, wled00/set.cpp, wled00/cfg.cpp
Adds the RLD form field, parses submitted values, and reads or writes the value as relay.del.
Relay activation timing
wled00/button.cpp
Uses relayDelay instead of the fixed RELAY_DELAY during relay activation.

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

Sequence Diagram(s)

sequenceDiagram
  participant settings_leds.htm
  participant getSettingsJS
  participant handleSettingsSet
  participant cfg.cpp
  participant handleOnOff
  participant LEDs

  settings_leds.htm->>getSettingsJS: Display RLD from relayDelay
  settings_leds.htm->>handleSettingsSet: Submit RLD
  handleSettingsSet->>cfg.cpp: Store relayDelay as relay.del
  cfg.cpp-->>settings_leds.htm: Load relay.del into RLD
  handleOnOff->>handleOnOff: Wait relayDelay
  handleOnOff->>LEDs: Send LED data
Loading

Possibly related PRs

  • wled/WLED#5315: Both changes modify relay control timing or handling in wled00/button.cpp.
  • wled/WLED#5737: Both changes modify settings JavaScript generation in wled00/xml.cpp.

Suggested labels: enhancement

Suggested reviewers: netmindz, softhack007

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making the relay post-switching delay configurable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@wled00/data/settings_leds.htm`:
- Line 814: Update the relay-delay assignment in loadCfg() to read the persisted
hw.relay.del configuration key, matching the key written by cfg.json, while
preserving the existing RLD field update behavior.

In `@wled00/set.cpp`:
- Line 311: Clamp or reject relay-delay values to the valid 0..65535 range
before storing them in relayDelay. Update the RLD assignment in
wled00/set.cpp:311 and the relay.del assignment in wled00/cfg.cpp:464,
preserving valid inputs while preventing malformed values from reaching
delay(relayDelay).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 44eb97e5-6f7d-482d-b53d-a54d3b64c0c1

📥 Commits

Reviewing files that changed from the base of the PR and between e391183 and cd9ae4b.

📒 Files selected for processing (7)
  • wled00/button.cpp
  • wled00/cfg.cpp
  • wled00/const.h
  • wled00/data/settings_leds.htm
  • wled00/set.cpp
  • wled00/wled.h
  • wled00/xml.cpp

Comment thread wled00/data/settings_leds.htm Outdated
Comment thread wled00/set.cpp
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.

1 participant