Hi all,
I have searching all over for a simple overview of how to implement a momentary button to cycle through presets and could not find any (may be due to lack of proper “google skillz”) So this is an attempt to list what I did to make it work and also … some issues I noticed of which I hope Aircookie could address them
Disclaimer : I am terrible at coding, even the whole JSON library is abracadabra for me (heck, even CSS is a mystery to me) which is why I used the HTTP API. Anyways, this is what I did:
The goal of the setup was to enable a “real” interface enabling basic functions without the need for software UI or even wifi reception. This is going to be implemented in a lamp for my daughter that will double as a wake up light. She can choose and define the various effects. After that the buttons will be the main interfacing to WLED.
This might also make it possible to (temporarily) disable WIFI on the esp8266 as to improve LAN security.
Hardware setup :
- esp8266, WEMOS D1 mini clone
- Button 1 connection : GPIO 0 (pin D3) + GND
- Button 2 connection : GPIO 1 (pin RX) + GND
Software: WLED v0.13.0 beta 3
Config => LED preferences
- button 0 pin : 0, pushbutton
- button 1 pin : 1, pushbutton
Config : Time & macros
- button 0 short : (preset) 20
- button 0 long : (preset) 21
- button 1 short : (preset) 30
- button 1 long : (preset) 31
- button 1 double : (preset) 32
Main UI => presets
- preset 1 to preset 5 have all a certain effect
- no emtpy presets between 1 and 5
- preset 6 does not exist, is not used or set
- preset 7 => API command : &PL=1
- preset 8-19 do not exist, are not used or set
- preset 20 => &PL=~ (this is the API command to jump to next preset)
- preset 21 => &T=2 (API command to turn esp8266 on/off)
- preset 30 => &A=~5 (increase brightness by steps of 5)
- preset 31 => &A=2 (reset to very low brightness)
- preset 32 => &A=125 (jump straight to half of full brightness, since I hardly ever use 100%)
What does this do?
Button 0:
- When turned off, short pressing the button turns it on and jumps straight to preferred preset (in my case 1)
- Again short pressing the button makes it jump to the next preset
- When at preset 5, again short pressing the button makes it jump to preset 1
- long press will turn the setup off
- either long or short press will turn it back on again
Button 1
- short press : increases brightness with small increments
- long press resets to lowest level
- double click jumps to 50% brightness
What I do not understand / Issues I have found in my setup
- I need to leave a preset empty (in the example preset 6) before the &PL=1 command otherwise the last effect preset is skipped entirely before jumping back to the first one.
- Also, adding new presets after defining the “&PL=1” does not show the new presets, they are simply ignored. Until you re-apply that specific API command (even if you reuse the same preset number)
- this does not show when simple changing already defined presets
- you could set the double press to go the previous preset (API would be : &PL=~- ), but this does not seem to work all the time in v0.13.0. I haven’t tried it with v0.12.1
Both these issues do not show when using 0.12.1
- I do not have skip a preset before using &PL=1
- New presets or changed presets are not ignored
P.S. I absolutely love the addition of another button in v0.13.0. I really hope this is going to be expanded to more buttons in the future