Skip to content

Commit

Permalink
Add hold_flick macro
Browse files Browse the repository at this point in the history
  • Loading branch information
mzyy94 committed Mar 12, 2024
1 parent fa8b071 commit db93add
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 32 deletions.
17 changes: 10 additions & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
34 changes: 9 additions & 25 deletions src/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,17 @@ inline void stop_timer(esp_timer_handle_t timer)

#define TOUCH_TAG "TOUCH"

#define check_touch_begin(t, st) \
if (t.state == st) \
{ \
ESP_LOGI(TOUCH_TAG, "Touch event " #st ": %d (%d,%d)", t.state, t.x, t.y); \
esp_event_post_to(loop_handle, TOUCH_EVENT, TOUCH_EVENT_TOUCH_BEGIN, &t, sizeof(t), 0); \
#define check_touch_hold_flick(t, st, event_id) \
if (t.state == st) \
{ \
ESP_LOGI(TOUCH_TAG, "Touch event " #st ": %d (%d,%d)", t.state, t.x, t.y); \
esp_event_post_to(loop_handle, TOUCH_EVENT, event_id, &t, sizeof(t), 0); \
}

#define check_hold_begin(t, st) \
if (t.state == st) \
{ \
ESP_LOGI(TOUCH_TAG, "Touch event " #st ": %d (%d,%d)", t.state, t.x, t.y); \
esp_event_post_to(loop_handle, TOUCH_EVENT, TOUCH_EVENT_HOLD_BEGIN, &t, sizeof(t), 0); \
}

#define check_touch_end(t, st) \
if (t.state == st) \
{ \
ESP_LOGI(TOUCH_TAG, "Touch event " #st ": %d (%d,%d)", t.state, t.x, t.y); \
esp_event_post_to(loop_handle, TOUCH_EVENT, TOUCH_EVENT_TOUCH_END, &t, sizeof(t), 0); \
}

#define check_flick_end(t, st) \
if (t.state == st) \
{ \
ESP_LOGI(TOUCH_TAG, "Touch event " #st ": %d (%d,%d)", t.state, t.x, t.y); \
esp_event_post_to(loop_handle, TOUCH_EVENT, TOUCH_EVENT_FLICK_END, &t, sizeof(t), 0); \
}
#define check_touch_begin(t, st) check_touch_hold_flick(t, st, TOUCH_EVENT_TOUCH_BEGIN)
#define check_hold_begin(t, st) check_touch_hold_flick(t, st, TOUCH_EVENT_HOLD_BEGIN)
#define check_touch_end(t, st) check_touch_hold_flick(t, st, TOUCH_EVENT_TOUCH_END)
#define check_flick_end(t, st) check_touch_hold_flick(t, st, TOUCH_EVENT_FLICK_END)

inline void update_device_event()
{
Expand Down

0 comments on commit db93add

Please sign in to comment.