Skip to content

Make button timing constants overridable - #5844

Open
adamsthws wants to merge 1 commit into
wled:mainfrom
adamsthws:button-timing-constants-overridable
Open

Make button timing constants overridable#5844
adamsthws wants to merge 1 commit into
wled:mainfrom
adamsthws:button-timing-constants-overridable

Conversation

@adamsthws

@adamsthws adamsthws commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Some buttons are physically awkward to press quickly enough (Buttons with long travel or stiff springs)... Updating the button timing requires editing button.cpp directly. This update allows overriding default button timing via build flags. (E.g., WLED_DEBOUNCE_THRESHOLD, WLED_LONG_PRESS, WLED_DOUBLE_PRESS)
  • This addition guards them with #ifndef (matching the existing WLED_PWM_FREQ pattern), so they can instead be set per-board via build_flags in platformio_override.ini

How I tested...

  • Built with an override for these constants (e.g. -D WLED_LONG_PRESS=2000) via platformio_override.ini and confirmed the new value takes effect
  • Built without any override and confirmed default button timing behavior is unchanged

Usage...

Example override in platformio_override.ini:

[env:myboard]
extends = env:esp32dev
build_flags = ${env:esp32dev.build_flags}
  -D WLED_DEBOUNCE_THRESHOLD=100   ; Default is 50ms
  -D WLED_LONG_PRESS=2000          ; Default is 600ms
  -D WLED_DOUBLE_PRESS=1000        ; Default is 350ms

Summary by CodeRabbit

  • Configuration
    • Existing build configuration can now override button debounce, long-press, and double-press timing values.
    • Default timing values remain unchanged when no overrides are provided.

WLED_DEBOUNCE_THRESHOLD, WLED_LONG_PRESS and WLED_DOUBLE_PRESS were plain
#defines, so a custom value could only be set by editing button.cpp directly. Guard them with
#ifndef, matching the existing WLED_PWM_FREQ pattern, so they can be set
per-board via build_flags in platformio_override.ini instead.
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: Advanced

Run ID: 3a632ec6-dbd6-4213-bbb6-7ae5c9bf8d25

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9f5fd and 4546f84.

📒 Files selected for processing (1)
  • wled00/button.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

The button timing macros now use individual guards. Build-provided values remain unchanged, while defaults remain 50 ms, 600 ms, and 350 ms.

Changes

Button timing configuration

Layer / File(s) Summary
Guard button timing defaults
wled00/button.cpp
The debounce, long-press, and double-press defaults are defined only when the build configuration does not provide values. Defaults remain 50 ms, 600 ms, and 350 ms.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 4546f

The change is limited to configurable button timing defaults and retains existing behavior when no overrides are supplied.

🚥 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 clearly and concisely describes the main change: making button timing constants configurable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.

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