#ifndef BUTTON_HANDLER_H #define BUTTON_HANDLER_H #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" #include "esp_timer.h" #define LONG_PRESS 500 #define BUTTON_PIN CONFIG_BUTTON_PIN #define ESP_INTR_FLAG_DEFAULT 0 struct Button { uint8_t pin; int64_t time; int64_t p_time; uint16_t dt; }; static QueueHandle_t uinput_evt_queue = NULL; void setup_button(struct Button* b); void button_task(void* arg); bool is_pressed(struct Button* b); bool was_pressed(struct Button* b, int64_t since); bool was_pressed_and_released(struct Button* b, int64_t since); bool was_short_pressed(struct Button* b, int64_t since); bool was_long_pressed(struct Button* b, int64_t since); bool was_short_pressed_and_released(struct Button* b, int64_t since); bool was_long_pressed_and_released(struct Button* b, int64_t since); #endif // BUTTON_HANDLER_H