Creating a class which allows more bank settings than buttons #1019
Unanswered
talipscomb
asked this question in
Q&A
Replies: 1 comment
-
If you have |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on a project which requires bankable buttons whose function can be changed by holding down a modifier key. I would like the bank to revert to zero when nothing is pressed and change to 1, 2, 3, 4 etc depending on the button pressed. I modified the "ManyButtonsSelector" class to function as momentary rather than latching. However this means the number of banks N will be equal to the number of buttons plus one. When i tried to modify the class so that the for loop in update() sets the bank to i+1, the program will crash if I select the last button. Also if I change the number of banks to be greater than the number of buttons declared the code will not compile.
I sort of "cheated" to get it working, by declaring a button on a pin which doesnt exist on my Teensy, allowing my real buttons to start from 1. It didnt sit well with me that I couldnt figure out how to modify the class so this is not necessary. Is there a more proper way to modify my class so it doesnt require this fake button?
Beta Was this translation helpful? Give feedback.
All reactions