88 lines
2.7 KiB
C
88 lines
2.7 KiB
C
#include <stdio.h>
|
|
#include "iot_button.h"
|
|
#include "button_gpio.h"
|
|
#include "esp_log.h"
|
|
#include "esp_err.h"
|
|
#include "esp_check.h"
|
|
#include "buttons/buttons.h"
|
|
|
|
static const char* TAG = "TrainThing";
|
|
|
|
|
|
|
|
/*
|
|
|
|
static void button_single_click_cb(void *arg,void *usr_data)
|
|
{
|
|
ESP_LOGI(TAG, "BUTTON_SINGLE_CLICK");
|
|
}
|
|
static void button_long_press_1_cb(void *arg,void *usr_data)
|
|
{
|
|
ESP_LOGI(TAG, "BUTTON_LONG_PRESS_START_1");
|
|
}
|
|
|
|
static void button_long_press_2_cb(void *arg,void *usr_data)
|
|
{
|
|
ESP_LOGI(TAG, "BUTTON_LONG_PRESS_START_2");
|
|
}
|
|
|
|
static void button_click_2_cb(void *arg,void *usr_data)
|
|
{
|
|
ESP_LOGI(TAG, "BUTTON 2 click");
|
|
}
|
|
*/
|
|
|
|
|
|
void app_main(void)
|
|
{
|
|
initialize_buttons();
|
|
/*
|
|
for (size_t i = 0; i < sizeof(btn_name_table) / sizeof(btn_name_table[0]); ++i) {
|
|
ESP_LOGI(TAG, "%s %d %c", btn_name_table[i].name, btn_name_table[i].btnAcc, btn_name_table[i].shortcut );
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
//ESP_RETURN_VOID_ON_ERROR(iot_button_new_gpio_device(&btn_cfg, &btn_gpio_cfg, &btn), TAG, "");
|
|
|
|
|
|
/*ESP_RETURN_VOID_ON_ERROR(iot_button_register_cb(gpio_btn, BUTTON_SINGLE_CLICK, NULL, button_event_cb,NULL), TAG, "");
|
|
|
|
button_event_args_t args ={.long_press.press_time = 2000};
|
|
ESP_RETURN_VOID_ON_ERROR(iot_button_register_cb(gpio_btn, BUTTON_LONG_PRESS_UP, NULL, button_event_cb, NULL), TAG, "");
|
|
|
|
args.long_press.press_time = 5000;
|
|
//ESP_RETURN_VOID_ON_ERROR(iot_button_register_cb(gpio_btn, BUTTON_LONG_PRESS_UP, &args, button_long_press_2_cb, NULL), TAG, "");
|
|
|
|
ESP_RETURN_VOID_ON_ERROR(iot_button_register_cb(gpio_btn, BUTTON_DOUBLE_CLICK, NULL, button_event_cb, NULL), TAG, "");
|
|
*/
|
|
|
|
|
|
/*
|
|
iot_button_register_cb(btn, BUTTON_PRESS_DOWN, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_PRESS_UP, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_PRESS_REPEAT, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_PRESS_REPEAT_DONE, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_SINGLE_CLICK, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_DOUBLE_CLICK, NULL, button_event_cb, NULL);
|
|
|
|
|
|
button_event_args_t args = {
|
|
.multiple_clicks.clicks = 2,
|
|
};
|
|
iot_button_register_cb(btn, BUTTON_MULTIPLE_CLICK, &args, button_event_cb, (void *)2);
|
|
args.multiple_clicks.clicks = 3;
|
|
iot_button_register_cb(btn, BUTTON_MULTIPLE_CLICK, &args, button_event_cb, (void *)3);
|
|
|
|
iot_button_register_cb(btn, BUTTON_LONG_PRESS_START, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_LONG_PRESS_HOLD, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_LONG_PRESS_UP, NULL, button_event_cb, NULL);
|
|
iot_button_register_cb(btn, BUTTON_PRESS_END, NULL, button_event_cb, NULL);
|
|
*/
|
|
}
|
|
|
|
|