Skip to content

Analog button fix#5659

Open
benjamw wants to merge 3 commits into
wled:mainfrom
benjamw:analog_button_fix
Open

Analog button fix#5659
benjamw wants to merge 3 commits into
wled:mainfrom
benjamw:analog_button_fix

Conversation

@benjamw

@benjamw benjamw commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This fixes the issues noted in #5613 (comment)

This also adds clarification for the differences between analog and digital inputs. Showing and hiding dropdowns as needed to make those selections clearer.

Summary by CodeRabbit

Release Notes

  • New Features
    • Enhanced button action preset configuration with type-specific UI rendering for analog, switch, and standard pushbutton types.
    • Updated preset labeling to display "Default Action (0)" for improved clarity.
    • Simplified section heading for button action presets.

@coderabbitai

coderabbitai Bot commented Jun 1, 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: 247e5f33-b5e6-4cfb-be94-b2b2bddb776d

📥 Commits

Reviewing files that changed from the base of the PR and between 47026f5 and 63cc355.

📒 Files selected for processing (1)
  • wled00/data/settings_time.htm

Walkthrough

This PR changes the Button Action Presets UI to be button-type-aware: it adds helpers to generate analog-specific options and to detect button types, updates the default preset label to “Default Action (0)”, extends addRow(...) to accept a button type and render per-type selectors, and updates getSettingsJS() to emit the new double-press and type arguments.

Changes

Analog Button Type Support

Layer / File(s) Summary
Preset labels and button type helpers
wled00/data/settings_time.htm
Default action preset option now shows “Default Action (0)”. New functions bAO(), isAnalogBtn(), isSwitchBtn(), and btnTypeName() generate analog/segment-opacity options and classify button types; rBPO() chooses preset vs analog option lists per-row using data-btype.
Button row rendering by type
wled00/data/settings_time.htm
addRow() signature extended to accept button-type t; rendering branches by type: analog rows render only analog-function/segment selector, switch rows render MP/ML (On→Off / Off→On), other pushbuttons render MP/ML/MD selectors using the updated default label; rows receive data-btype for rBPO().
Backend emission for new row signature
wled00/xml.cpp
getSettingsJS() now passes button.macroDoublePress (double-press) alongside existing macro and long-press fields and button.type when emitting addRow(...) calls.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • wled/WLED#4757: Also updates addRow(...) usage and macro double-press handling in settings UI.
  • wled/WLED#5636: Related changes to Button Action Presets UI labels and rendering in settings_time.htm.

Suggested labels

bug

Suggested reviewers

  • DedeHai
  • softhack007
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Analog button fix' is vague and doesn't clearly convey the scope of changes. While the PR does address analog button handling, it also includes broader refactoring (new helpers, UI branching for multiple button types, label updates) that extends beyond just fixing analog buttons. Consider a more specific title like 'Refactor button handling for analog and switch types' or 'Add button type-specific UI rendering for analog and switch buttons' to better reflect the comprehensive changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@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: 1

🤖 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_time.htm`:
- Around line 309-311: The label "Double press (n/a)" is misleading because the
select named "MD${b}" is actually hydrated from button.macroDoublePress in
wled00/xml.cpp; either rename the label to "Double press" to reflect it's
functional or make the control non-editable/disabled if the firmware still
ignores the value. Update the HTML in settings_time.htm to change the <label>
text for the select with name "MD${b}" (or add the disabled attribute/class) and
ensure consistency with the button.macroDoublePress usage in wled00/xml.cpp so
the UI accurately represents whether the value is applied.
🪄 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: 8bec5088-0633-4560-b48a-0fece4a75f8f

📥 Commits

Reviewing files that changed from the base of the PR and between 0a1a7fc and 47026f5.

📒 Files selected for processing (2)
  • wled00/data/settings_time.htm
  • wled00/xml.cpp

Comment thread wled00/data/settings_time.htm
Comment thread wled00/data/settings_time.htm Outdated
buttonBlock.innerHTML = `
<div class="bh">Button ${i} - ${typeName}</div>
<div class="bs">
<input type="hidden" name="MP${b}" value="0">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we require the hidden values? i.e. they are set to default zero in firmware if missing, see set.cpp

Comment thread wled00/data/settings_time.htm Outdated
if (t===undefined) t = 0;
var b = String.fromCharCode((i<10?48:55)+i);
var presetOpts = '<option value="0">Default Action</option>' + sortedPresetOptions;
var analog = isAnalogBtn(t);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

single use variable adds code for no benefit

@DedeHai

DedeHai commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

thanks, looks good to me, just two minor things.

edit:
the rabbit has a point about the button vs. switch: since now the page knows the button type and you already went through the effort of labelling the buttons, the function labels could be type specific. Is that something that can be done by adding a few more lines without duplicating the whole block?

@softhack007 softhack007 added this to the 16.0.0 release + bugfixes milestone Jun 9, 2026
@benjamw

benjamw commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

I agree. I didn't want to scope creep the PR, but had thought of making the labels dynamic.

@benjamw

benjamw commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

I've added functionality to make each button type have its own options available as well as remove anything that needs to default to 0.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants