Replies: 2 comments
-
In theory, The basic idea is to create 2 (or more) instances of (Edit: Actually, if you use the Once you set up the 2 // create buttons for Ladder 1
uint8_t ANALOG_PIN1 = ...;
AceButton b0(nullptr, 0);
AceButton b1(nullptr, 1);
AceButton b2(nullptr, 2);
AceButton * const BUTTONS1[] = { &b0, &b1, &b2, ... };
const uint16_t LEVELS1[] = { ... }
LadderButtonConfig buttonConfig1(ANALOG_PIN1, NUM_LEVELS1, LEVELS1, NUM_BUTTONS1, BUTTONS1);
// create buttons for Ladder 2
uint8_t ANALOG_PIN2 = ...;
AceButton c0(nullptr, 0);
AceButton c1(nullptr, 1);
AceButton c2(nullptr, 2);
AceButton * const BUTTONS2[] = { &c0, &c1, &c2, .... };
const uint16_t LEVELS2[] = { ... }
LadderButtonConfig buttonConfig2(ANALOG_PIN2, NUM_LEVELS2, LEVELS2, NUM_BUTTONS2, BUTTONS2);
// Define the event handlers.
void handleEvent1(...) {....}
void handleEvent2(...) {...}
void setup() {
...
pinMode(ANALOG_PIN1, INPUT);
pinMode(ANALOG_PIN2, INPUT);
buttonConfig1.setEventHandler(handleEvent1);
buttonConfig2.setEventHandler(handleEvent2);
...
buttonConfig1.setFeature(...);
buttonConfig2.setFeature(...);
...
}
void checkButtons() {
static unsigned long prev = millis();
// DO NOT USE delay(5) to do this.
unsigned long now = millis();
if (now - prev > 5) {
buttonConfig1.checkButtons();
buttonConfig2.checkButtons();
prev = now;
}
}
void loop() {
checkButtons();
} |
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll give it a shot! |
Beta Was this translation helpful? Give feedback.
-
Hi and thanks for AceButton! Does it support multiple ladders - like
multiple analog pins being read? Unfortunately, my application
doesn't lend itself to a matrix.
Beta Was this translation helpful? Give feedback.
All reactions