diff --git a/README.md b/README.md index ee9fae1..1883e61 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Arduino Lint](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/[xxx]/actions/workflows/pre-commit.yml) +[![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_Button/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Button/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_Button/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_Button/actions/workflows/pre-commit.yml) # ESP32_Button diff --git a/examples/AllEvents/AllEvents.ino b/examples/AllEvents/AllEvents.ino deleted file mode 100644 index 981c073..0000000 --- a/examples/AllEvents/AllEvents.ino +++ /dev/null @@ -1,41 +0,0 @@ -#include "Button.h" - -void setup() -{ - // put your setup code here, to run once: - Serial.begin(115200); - - // initializing a button - Button *btn = new Button(9, false); //incase of ADC button "Button *btn = new Button(9, false, 0, 0, 100, 400);" - - btn->attachPressDown(&onButtonPressDownCb, NULL); - btn->attachPressUp(&onButtonPressUpCb, NULL); - btn->attachPressDown(&onButtonPressDownRepeatCb, NULL); - btn->attachSingleClick(&onButtonSingleClickCb,NULL); - btn->attachSingleClick(&onButtonSingleClickRepeatCb,NULL); - btn->unregisterPressDownEvent(&onButtonPressDownCb); - btn->detachSingleClick(); -} - -void loop() -{ - delay(10); -} - -static void onButtonPressDownCb(void *button_handle, void *usr_data) { - Serial.println("Button pressed down"); -} -static void onButtonPressDownRepeatCb(void *button_handle, void *usr_data) -{ - Serial.println("Button press down repeat"); -} -static void onButtonPressUpCb(void *button_handle, void *usr_data) { - Serial.println("Button press Up"); -} -static void onButtonSingleClickCb(void *button_handle, void *usr_data) { - Serial.println("Button single click"); -} -static void onButtonSingleClickRepeatCb(void *button_handle, void *usr_data) -{ - Serial.println("Button single click repeat"); -} diff --git a/examples/AllEvents/AllEvents/AllEvents.ino b/examples/AllEvents/AllEvents/AllEvents.ino deleted file mode 100644 index ab96d12..0000000 --- a/examples/AllEvents/AllEvents/AllEvents.ino +++ /dev/null @@ -1,75 +0,0 @@ -#include "Button.h" - -void setup() -{ - // put your setup code here, to run once: - Serial.begin(115200); - - // initializing a button - Button *btn = new Button(9, false); //incase of ADC button "Button *btn = new Button(9, false, 0, 0, 100, 400);" - - esp_err_t resultDown = btn->attachPressDown(&onButtonPressDownCb, NULL); - attachButtonCallback(btn, resultDown, "Button press down callback attached successfully", "Failed to attach button press down callback"); - - esp_err_t resultUp = btn->attachPressUp(&onButtonPressUpCb, NULL); - attachButtonCallback(btn, resultUp, "Button press up callback attached successfully", "Failed to attach button press up callback"); - - esp_err_t resultDownRepeat = btn->attachPressDown(&onButtonPressDownRepeatCb, NULL); - attachButtonCallback(btn, resultDownRepeat, "Button press down repeat callback attached successfully", "Failed to attach button press down repeat callback"); - - esp_err_t resultSingleClick = btn->attachSingleClick(&onButtonSingleClickCb,NULL); - attachButtonCallback(btn, resultSingleClick, "Button single click callback attached successfully", "Failed to attach single click callback"); - - esp_err_t resultSingleClickRepeat = btn->attachSingleClick(&onButtonSingleClickRepeatCb,NULL); - attachButtonCallback(btn, resultSingleClickRepeat, "Button single click repeat callback attached successfully", "Failed to attach single click repeat callback"); - - esp_err_t resultunregisterPressDown = btn->unregisterPressDownEvent(&onButtonPressDownCb); - if (resultunregisterPressDown == ESP_OK) { - Serial.println("Detach the callback on press down event"); - } else { - Serial.print("Failed to unregister callback on press down event"); - Serial.println(resultunregisterPressDown); - } - - esp_err_t resultDetechsingleClick = btn->detachSingleClick(); - if (resultDetechsingleClick == ESP_OK) { - Serial.println("Detach all the callback on single click event"); - } else { - Serial.print("Failed to detach all the callback on single click event"); - Serial.println(resultDetechsingleClick); - } - - -} - -void loop() -{ - delay(10); -} - -static void attachButtonCallback(Button *btn, esp_err_t result, const char *successMessage, const char *failureMessage) { - if (result == ESP_OK) { - Serial.println(successMessage); - } else { - Serial.print(failureMessage); - Serial.println(result); - } -} - -static void onButtonPressDownCb(void *button_handle, void *usr_data) { - Serial.println("Button pressed down"); -} -static void onButtonPressDownRepeatCb(void *button_handle, void *usr_data) -{ - Serial.println("Button press down repeat"); -} -static void onButtonPressUpCb(void *button_handle, void *usr_data) { - Serial.println("Button press Up"); -} -static void onButtonSingleClickCb(void *button_handle, void *usr_data) { - Serial.println("Button single click"); -} -static void onButtonSingleClickRepeatCb(void *button_handle, void *usr_data) -{ - Serial.println("Button single click repeat"); -}