registering a function for callback is not working
ripred opened this issue · 1 comments
ripred commented
/*\ Example use of the ButtonGestures library
|*|
|*| This example shows how to register different functions to be
|*| called for different gestures.
|*|
|*| If a function has been registered to a gesture then the function
|*| will automatically be called for that gesture.
\*/
#include <ButtonGestures.h>
// NOTE: change/define the following pin(s) based on your project/connections
#define BUTTON_PIN 2
ButtonGestures button(BUTTON_PIN);
//
// These functions will be registered and called for the various gestures:
//
void function1(const uint8_t /*pin*/, const uint8_t /*state*/) {
Serial.println("function 1 has been called");
}
void function2(const uint8_t /*pin*/, const uint8_t /*state*/) {
Serial.println("function 2 has been called");
}
void function3(const uint8_t /*pin*/, const uint8_t /*state*/) {
Serial.println("function 3 has been called");
}
void function4(const uint8_t /*pin*/, const uint8_t /*state*/) {
Serial.println("function 4 has been called");
}
void function5(const uint8_t /*pin*/, const uint8_t /*state*/) {
Serial.println("function 5 has been called");
}
void function6(const uint8_t /*pin*/, const uint8_t /*state*/) {
Serial.println("function 6 has been called");
}
void setup(void) {
Serial.begin(2000000);
uint32_t timer = millis() + 2000;
while (!Serial && millis() < timer);
Serial.flush();
Serial.println(F("\n\nArduino Core Library - ButtonGestures Library Test"));
if (!button.set_callback(SHORT1, function1))
Serial.println("Error registering callback for SHORT1");
if (!button.set_callback(LONG1, function2))
Serial.println("Error registering callback for LONG1");
if (!button.set_callback(SHORT2, function3))
Serial.println("Error registering callback for SHORT2");
if (!button.set_callback(LONG2, function4))
Serial.println("Error registering callback for LONG2");
if (!button.set_callback(SHORT3, function5))
Serial.println("Error registering callback for SHORT3");
if (!button.set_callback(LONG3, function6))
Serial.println("Error registering callback for LONG3");
}
void loop(void) {
button.check_button();
}
This example should display the appropriate debug output when each registered function is invoked by making the associated gesture with the push button.
ripred commented
fixed in v2.0.1