-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix GPIO0 button assignment issues on ESP8266 #5259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Modified pin conflict detection to check if buttons are enabled before considering their GPIO pins as "in use". Disabled buttons (type = 0) no longer block GPIO reassignment to LED outputs. Co-authored-by: DedeHai <[email protected]>
|
@copilot the issue is a different one: when I remove all buttons in the settings_leds.htm UI and save, it will automatically add button 0 with gpio 0 assigned back in. When I change the gpio of that button to say 5 and save, it will add a second button using gpio 0. Can you please check the code to find out why this is? |
When user removes all buttons and saves, the form handler was processing all WLED_MAX_BUTTONS iterations without checking if parameters exist. Empty request->arg().toInt() returns 0, causing GPIO0 to be auto-assigned. Also fixed cleanup loop to include button index 0. Co-authored-by: DedeHai <[email protected]>
Found and fixed the issue! The problem was in
Fix applied (commit 7f395ea):
Now you can remove all buttons without them being auto-recreated, and change button pins without duplicates appearing. |
|
@copilot your fix is wrong. the acutal fix is to only change this single line: |
Simplified fix by using `request->hasArg(bt) ? request->arg(bt).toInt() : -1` instead of break statement. This ensures non-existent button parameters default to -1 instead of 0. Co-authored-by: DedeHai <[email protected]>
You're absolutely right! Applied your suggested fix in commit b6cea79. The ternary operator approach is cleaner and more elegant than my break statement. Changed line 282 to: int hw_btn_pin = request->hasArg(bt) ? request->arg(bt).toInt() : -1;This ensures non-existent button parameters default to -1 instead of 0, preventing GPIO0 from being auto-assigned. |
Fix GPIO0 pin assignment issues on ESP8266
Problem 1 (Original)
GPIO0 cannot be used as an LED output on ESP8266 because the pin conflict checker unconditionally flags all button GPIO pins as in-use regardless of button state.
Solution 1
Modified pin conflict detection in
settings_leds.htmto check button type before marking pin as used. Button pins only conflict when button type is not "Disabled" (value != 0).Problem 2 (New Issue from @DedeHai)
When removing all buttons in settings UI and saving:
Root Cause 2
In
set.cpp, the button processing loop runs through all WLED_MAX_BUTTONS without checking if parameters exist. Whenrequest->arg(bt)is empty,toInt()returns 0, causing GPIO0 to be assigned. Additionally, the cleanup loop usedi > 0instead ofi >= 0, never removing button at index 0.Solution 2 (Updated per @DedeHai suggestion)
request->hasArg(bt) ? request->arg(bt).toInt() : -1i >= 0to include button index 0Changes Made
settings_leds.htm(2 locations)set.cpp(cleaner than break statement)Users can now:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.