diff --git a/components/button/include/iot_button.h b/components/button/include/iot_button.h index 8c7f8f088..ec548c8d9 100644 --- a/components/button/include/iot_button.h +++ b/components/button/include/iot_button.h @@ -29,8 +29,14 @@ typedef void *button_handle_t; * @brief Button events * */ -typedef enum { - BUTTON_PRESS_DOWN = 0, +#ifdef __cplusplus +typedef enum button_event_e : int { //C++ Definition +#else +typedef enum button_event_e { //C Definition +#endif + BUTTON_PRESS_INVALID = -1, //to enforce signed int also in C. + BUTTON_PRESS_NORMAL = 0, + BUTTON_PRESS_DOWN, BUTTON_PRESS_UP, BUTTON_PRESS_REPEAT, BUTTON_PRESS_REPEAT_DONE, @@ -110,6 +116,7 @@ esp_err_t iot_button_delete(button_handle_t btn_handle); * @return * - ESP_OK on success * - ESP_ERR_INVALID_ARG Arguments is invalid. + * - ESP_ERR_INVALID_STATE the Callback is already registered. No free Space for another Callback. */ esp_err_t iot_button_register_cb(button_handle_t btn_handle, button_event_t event, button_cb_t cb, void *usr_data); diff --git a/components/button/iot_button.c b/components/button/iot_button.c index 0b4d4e3a0..69794b449 100644 --- a/components/button/iot_button.c +++ b/components/button/iot_button.c @@ -97,6 +97,7 @@ static void button_handler(button_dev_t *btn) if (btn->button_level == btn->active_level) { btn->event = (uint8_t)BUTTON_PRESS_DOWN; CALL_EVENT_CB(BUTTON_PRESS_DOWN); + CALL_EVENT_CB(BUTTON_PRESS_NORMAL); btn->ticks = 0; btn->repeat = 1; btn->state = 1; @@ -109,6 +110,7 @@ static void button_handler(button_dev_t *btn) if (btn->button_level != btn->active_level) { btn->event = (uint8_t)BUTTON_PRESS_UP; CALL_EVENT_CB(BUTTON_PRESS_UP); + CALL_EVENT_CB(BUTTON_PRESS_NORMAL); btn->ticks = 0; btn->state = 2; @@ -123,6 +125,7 @@ static void button_handler(button_dev_t *btn) if (btn->button_level == btn->active_level) { btn->event = (uint8_t)BUTTON_PRESS_DOWN; CALL_EVENT_CB(BUTTON_PRESS_DOWN); + CALL_EVENT_CB(BUTTON_PRESS_NORMAL); btn->repeat++; CALL_EVENT_CB(BUTTON_PRESS_REPEAT); // repeat hit btn->ticks = 0; @@ -145,6 +148,7 @@ static void button_handler(button_dev_t *btn) if (btn->button_level != btn->active_level) { btn->event = (uint8_t)BUTTON_PRESS_UP; CALL_EVENT_CB(BUTTON_PRESS_UP); + CALL_EVENT_CB(BUTTON_PRESS_NORMAL); if (btn->ticks < SHORT_TICKS) { btn->ticks = 0; btn->state = 2; //repeat press @@ -165,6 +169,7 @@ static void button_handler(button_dev_t *btn) } else { //releasd btn->event = (uint8_t)BUTTON_PRESS_UP; CALL_EVENT_CB(BUTTON_PRESS_UP); + CALL_EVENT_CB(BUTTON_PRESS_NORMAL); btn->state = 0; //reset btn->long_press_hold_cnt = 0; } @@ -326,6 +331,7 @@ esp_err_t iot_button_register_cb(button_handle_t btn_handle, button_event_t even BTN_CHECK(NULL != btn_handle, "Pointer of handle is invalid", ESP_ERR_INVALID_ARG); BTN_CHECK(event < BUTTON_EVENT_MAX, "event is invalid", ESP_ERR_INVALID_ARG); button_dev_t *btn = (button_dev_t *) btn_handle; + BTN_CHECK(NULL == btn->cb[event], "Callback is already registered", ESP_ERR_INVALID_STATE); btn->cb[event] = cb; btn->usr_data[event] = usr_data; return ESP_OK; diff --git a/examples/camera/camera_components/esp32-camera b/examples/camera/camera_components/esp32-camera new file mode 160000 index 000000000..108a33014 --- /dev/null +++ b/examples/camera/camera_components/esp32-camera @@ -0,0 +1 @@ +Subproject commit 108a33014902d2cc1b4e4523f6b14818288cb45e