Hi all. I am using the Button2 library found here: GitHub - LennartHennigs/Button2: Arduino/ESP button library that provides callback functions to track single, double, triple and long clicks. It also takes care of debouncing.. I am on Windows10 using PlatformIO in arduino framework. I know everyone has their favorite buttons library, but this one seems to work. The issue I am having is my poor understanding of C and I know many of you are awesome at C ( I'm new to it so please be kind)
So the issue is I have 4 buttons on my project and there are certain instances when I want to change their behavior individually and other instances when I want to change them all at once to the same thing. so what I tried to do was use the constructor to create 4 buttons:
Button2 buttonUp, buttonEnter, buttonDown, buttonBack;
then create an array of buttons containing these 4 buttons
Button2 allButtons[] = {buttonUp, buttonEnter, buttonDown, buttonBack};
I thought for instances when I wanted to address these buttons as a group, I could use the allButtons array and address them that way e.g.
for (int i=0; i < 4; i++){
allButtons[i].setDebounceTime(10);
}
but this doesn't work. I think when I populate the array allButtons[] I am creating a new instance of buttons but accessing allButtons[0] is not the same as accessing buttonUp. Is my understanding of why this does not work correct? I could have only defined the array and done it that way I guess, but I wanted to give each individual button a name to use when I assign the individual behaviors rather than referring to them by their array names e.g. allButtons[1]. So how does one give each object in an array of objects a unique name without creating new objects?
Thanks!
Fish