How to handle physical buttons #617
-
Greetings to all who read me, How do I add a phyiscal button, wired to a GPIO pin and use this to cycle through effects? Searching through the code and searching through other discussions has left me empty handed so far, some notes: I think this shows I did my homework. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
OK, after some pondering, I realized I was neglecting Bounce2 library. I'm starting with latching buttons. Will test soon and post results. |
Beta Was this translation helpful? Give feedback.
-
Running in DEMO mode, having two effects in the effectslist (effects.cpp). HOWEVER the auto-cycling throught the effects is in place and I'm not getting it disabled (yet). So, to be continued. In the meantime, pointers welcome! 🙂
|
Beta Was this translation helpful? Give feedback.
-
So setting the DEFAULT_EFFECT_INTERVAL in globals.h doesn't set this value. I'm expecting it has to do with the order of things... at some point the SetInterval method of the EffectsManager is called, may be before setting the parameter... need to look into this more. So me asking a question turned into some dear-diary-moments.
|
Beta Was this translation helpful? Give feedback.
-
You encouraged us to ignore you, but I'll admit I was reading enough that
I'd have nudged you back onto course if you were wandering off into the
weeds. You seemed to be making good progress on your own, so I was content
to just let you go as it seemed more educational this way.
setup() in arduino land is only run on system boot. Unless you're looking
at button presses when the system starts (which is a thing) that button
code is probably dead.
I think you've learned the value of a reasoned hack and IMO, a custom
one-off lighting project based around code like NightDriver is a good place
for those.
Trying to extend that to be useful in the general case so that buttons
could be triggered from the JSON API and state reflect in the Web UI and
having an arbitrary number of effects, including wraparound at the ends,
and the hundred other things to actually product-ize something like this
enough to check in would be non-trivial.
You didn't need a lot of computer science-y programming skills. You needed
time and determination ... and the source code of a project that _almost_
did what you wanted. THIS is the value of open source and I wish more
people would take advantage of that.
Congrats for leveling up.
Fun Fact: Most ESP32 boards have a "BOOT" button attached to GPIO0. If
you've hosed flash enough that you can't download new code, holding that
down at boot forces the bootloader to stay in the bootloader, never jumping
to user code, which allows you to reflash it. USUALLY, that button is
needed when you first flash a new chip (or when it's done on the assembly
line) and is otherwise just a button on the board. [citation needed] After
the first half second or so after the board is powered on, that's just a
plain ole button attached to GPIO that you're free to connect to your
interrupt/polling logic and use. If you attach that to, say, a toggle
switch or otherwise have it grounded when the device reboots, be prepared
for the device to NOT boot into your code, though. But if you're
desperate for GPIOs or want to save $.05 on another button, it can be a
cool trick to remember.
That button is also often about 5mm from a reset button, so fat-fingering
it can sometimes be bad...
[Citation]:
https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/boot-mode-selection.html
…On Fri, Mar 22, 2024 at 12:21 AM Gerben1701 ***@***.***> wrote:
*dear-diary-moments*... should've gone for captain's log...
—
Reply to this email directly, view it on GitHub
<#617 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCSD3ZMZMSO73PB25CVKBTYZO5XDAVCNFSM6AAAAABE2PQRZ2VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DQNZTG44TQ>
.
You are receiving this because you are subscribed to this thread.Message
ID:
<PlummersSoftwareLLC/NightDriverStrip/repo-discussions/617/comments/8873798
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
Comment it out and see if the check at runtime is enough. Maybe I'm wrong.
The interaction with kids and nerdy things seems like a feature, not a bug.
Working as intended. 😉 Seriously, if they learn something and everyone has
fun, that's great.
…On Sat, Mar 23, 2024, 2:20 PM Gerben1701 ***@***.***> wrote:
Hello Robert,
Yes, it was educational! And good to know big brother was watching 😄👍
Thanks for the tip on Boot button! I'm positive this will come in handy.
On the button check in setup(), I've not tested this yet. Background: I
want to use flip switches, so code needs to check after boot (setup()) what
position they're in. But maybe it's caught by the first button.changed...
Will test and hopefully remember to post findings.
First things first though... the kids caught me playing around with LED
strips, so now I got a rainbow lighting project added to my backlog -
highest priority, naturally.
—
Reply to this email directly, view it on GitHub
<#617 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCSD33LRICOSSA5CVMPMT3YZXIYLAVCNFSM6AAAAABE2PQRZ2VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DQOBYHA2DS>
.
You are receiving this because you commented.Message ID:
<PlummersSoftwareLLC/NightDriverStrip/repo-discussions/617/comments/8888849
@github.com>
|
Beta Was this translation helpful? Give feedback.
So setting the DEFAULT_EFFECT_INTERVAL in globals.h doesn't set this value. I'm expecting it has to do with the order of things... at some point the SetInterval method of the EffectsManager is called, may be before setting the parameter... need to look into this more.
Anyway, re-setting it in the setup loop did the trick! No more auto-cycling through effects. Calling it a workaround and calling it a day (for now).
Button is working also, all is well in the kingdom.
As stated, running in DEMO mode, but main thing is having at least two effects in the effectslist (effects.cpp).
Enabled button 1 on pin 5 (globals.h).
Impression of my code below.
So me asking a question turned into some dear-…