Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
14.54k stars 3.11k forks source link

Button 0 press would erase configuration and presets #4062

Open flux242 opened 1 month ago

flux242 commented 1 month ago

I have soldered a touch button to the ESP01. As I configured the pin and Push type. The first time I touched the button it erased all my stored settings. After some research is was clear to me that I should have used PushInverted type of button because wled expects that a button would pull pin to the ground. But after restoring configuration I tried to change the button type to Inverted and upon saving it would still erase my settings again because I couldn't switch into the settings screen within 12 seconds after wled booting!!! So, it is not possible to restore configuration from a file and change button setting in the GUI! And this is anything but well defined UI

So, to prevent this from happening one could reset the button timer upon configuration changes Alternatively one could expose button timers in the GUI, so that one could disable/enable 6/12 sec timers or even redefine its actions

blazoncek commented 1 month ago

Assign your GPIO to button 1.

flux242 commented 1 month ago

really? How should it help in the situation described?

blazoncek commented 1 month ago

Use custom compilation.

EDIT: Disconnect button, boot WLED, reconfigure, reconnect button.

flux242 commented 1 month ago

really? Desolder the button instead of resetting the timer in software? Sounds like a plan

blazoncek commented 1 month ago

Do some prototyping 1st, then solder.

Or use my other proposal.

softhack007 commented 1 month ago

really? Desolder the button instead of resetting the timer in software? Sounds like a plan

In fact, it is. Especially when considering this:

flux242 commented 1 month ago

really? Have I ever mentioned GPIO0? And no timer exists they say huh? What's that then


      if (b == 0 && dur > WLED_LONG_AP) { // long press on button 0 (when released)
        if (dur > WLED_LONG_FACTORY_RESET) { // factory reset if pressed > 10 seconds
          WLED_FS.format();
          #ifdef WLED_ADD_EEPROM_SUPPORT
          clearEEPROM();
          #endif
          doReboot = true;
        } else {
          WLED::instance().initAP(true);
        }
      } else if (!buttonLongPressed[b]) { //short press
        //NOTE: this interferes with double click handling in usermods so usermod needs to implement full button handling
        if (b != 1 && !macroDoublePress[b]) { //don't wait for double press on buttons without a default action if no double press macro set
          shortPressAction(b);
        } else { //double press if less than 350 ms between current press and previous short press release (buttonWaitTime!=0)
flux242 commented 1 month ago

if you still don't get it, I'll reiterate: Having a function of erasing EEPROM on a button is dangerous because it happens without any warning! And nobody should be punished by loosing all the settings simply because buttons aren't properly configured. Resetting AP pass is OK and that's why I don't want to use Button1 which lacks this functionality. Even if there's a timer reset for a button before applying new settings, the buttons itself could stuck because of some mechanical issue or because of overheating.

softhack007 commented 1 month ago

if you still don't get it, I'll reiterate:

I don't need a teacher who reiterates lessons. And I don't need someone who beliefs he can read the source code to me. PERIOD.

flux242 commented 1 month ago

if you still don't get it, I'll reiterate:

I don't need a teacher. And I don't need some dabbler who beliefs he can read the source code to me. PERIOD.

I wasn't even referencing you with that one because it would make no sense

softhack007 commented 1 month ago

correct. And it does not make sense for any other maintainer here, too.

blazoncek commented 1 month ago

I do not get why are you so fussed about a clearly described button 0 functionality.

Note: Button 0 has two, built-in functions. 1. Hold it down for >6 seconds and the Wi-Fi settings will be reset to default. 2. Hold it down for >12 seconds and flash memory is erased.

Taken from KB.

If you've soldered your button to a default GPIO (0, which is also a strapping pin) prior to flashing you wouldn't have lost anything as you wouldn't be able to save anything.

If you did it afterwards (or changed GPIO) you were notified about its functionality in the KB.

RTFM as they say.

flux242 commented 1 month ago

its amazing you still not getting what i'm talking about but insist that i wrongly soldered something to something! I care less too, because i simply removed that erase timer completely locally and i'm fine. RTFM huh? Keep telling this to everyone for better user experience

akluchnikov commented 3 weeks ago

Hi all. The same problem on wemos d1 mini with esp8266 and touch button (ttp223). ttp223 is connected to a 3.3 V supply. Actions: 1) connect the board and download the firmware WLEDMM_0.14.1-b32.41_esp8266_4MB_S using flash_download_tool_3.9.5 2) I connect to the wled in AP mode, assign a button to port 4, and an output to the LEDs to port 5. and connect to the WIFI network. I save the settings. 3) Turn off the power and solder the button 4) I connect again, the LEDs light up yellow. 5) I press the touch button: the blue LED on the board blinks, the board reboots, all settings are empty. I tried assigning a button to ports 0, 2, 4, 5, 1, 13, 15, 16 - the result is the same. I tried disconnecting the pull-up resistors - the result was the same. I tried the inverted mode on ttp223 and on ESP - the settings also went off. I tried to watch the signals with an oscilloscope - without pressing 0V, with pressing 3.3V, there was no noise. Tried 2 different copies of the board - same problem What else can you think of to solve the problem?

flux242 commented 3 weeks ago

buttons interface is fubar. First of all they attached some dangerous effects to button0 without mentioning that in the gui! Now they say use other buttons but that isn't working either because on all buttons except button0 action is repeated automatically for long presses. So if I would want to cycle through presets with short press and switch on/off with long one it wouldn't work. And the only way to get it working is to remove all hidden actions from button0 and then use it

softhack007 commented 3 weeks ago

buttons interface is fubar. First of all they [...]

Who is "they" ? As my grandpa used to say - "they" are selling cucumbers on the market 😉 .

🆒 cool down ... no need to get emotional. This is a community project, not a product made by a professional company. So no need to fight for your right.

flux242 commented 3 weeks ago

those who don't even admit that there's a problem with buttons

blazoncek commented 3 weeks ago

those who don't even admit that there's a problem with buttons

There isn't. 🤣 That is a core functionality built into WLED since 0.12.

softhack007 commented 3 weeks ago

The behaviour is explained already in our KB https://kno.wled.ge/features/macros/#buttons

Note: Button 0 has two, built-in functions. 1. Hold it down for >6 seconds and the Wi-Fi settings will be reset to default. 2. Hold it down for >12 seconds and flash memory is erased.

akluchnikov commented 3 weeks ago

thanks for the answers! Yes, I already realized that this is not a bug, but a feature. But for some reason I have never encountered this, although I have already assembled 20+ devices using the same scheme...