For a portable application I want to toggle the WiFi with a physical switch that the user can initiate a WiFi connection only when the lighting has to be modfied.
In this post I wanted to implement a debounce library but @tonyno told me that there already is a debounce routine.
So upon searching this forum and the web and looking through the button.cpp I couldn’t find a hint how to get the pressed state of a button. There is neither an explanation of the functions in the file nor an example code, so I’m left helpless now
You can do that as of right now with disabling AP mode and re-enable AP when you want change something. To do so just press default button (GPIO0) for 6 sec. When Wi-Fi network will be present controller will automatically connect to network.
Thanks for the hint.
But I need it to be switched off quickly by a rocking or a latching pressure switch. Also I want to properly understand how to integrate custom code into the usermod.cpp.
Yes I know that tutorial.
My problem is, that I need either an additional debounce library (which isn’t recognized by the IDE/the WLED-project at the moment) or a source that tells me how to apply the button.cpp routines to my own button.
Yes, somebody else told me that debounce is already implemented but HOW do I initiate a custom button then? I found no tutorials.
And what I want to achieve I already described after you gave me the hint with the default button. So I don’t know how I can be more precise with my problem.
I am looking for something similar also. It will help to secure my local network if I can (temporarily) turn off the WIFI via a hardware interface (read: switch). Only to switch it on again for maintenance purposes.
The reason is to reduce attack vectors on the local network. The esp board are fun to use, but security is not a prio in their design and applications. And with WLED increasingly adding hardware UI options, the use for WIFI as primary input - ignoring setup - is not always required anymore.
Of course I have, but I don’t find an instruction how to use the functions in button.cpp.
First I must tell the esp, where my button is connected and so far I couldn’t identify a spot in the code where I can add a new button in the pinmanager class allocatePin-function
Have you done it as you say that everything I need is in button.cp?
Definition of GPIOs used by buttons is in the hardware settings (LED settings) where you define a GPIO pin used by the button and a button type (pushbutton, switch, PIR sensor, analog, etc).
What happens when you press a button is defined in Time & Macros settings, where you can apply certain preset to a short, long or double press (for push button type, etc).
All of the information about buttons can be found in knowledge base.
BTW, do not bother with pin manager. It does nothing regarding buttons.
No. I was refering on where to look for pin definitions and actions assigned to buttons.
But as you suggested a JSON API can be enhanced to allow AP/WiFi to be switched on or off without changing any of behaviour of other components of the code.
Hey @blazoncek,
Yes, I can change the type of button there in the LED settings, but for these I can only assign LED presets but no behaviour regarding what I want.
I need a way to add a GPIO for my switch and then integrate my functionality as a regular usermod.
The other important question is, if I can somehow use the button.cpp functions for the debounce handling of my switch or if I need to implement a separate debounce functionality.