K1Guitar/APP/app_touch.h

37 lines
1.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef APP_TOUCH_H
#define APP_TOUCH_H
#include <stdint.h>
/* ==================== 手势类型 ==================== */
typedef enum {
GESTURE_NONE = 0, /* 无手势(状态机未产出) */
GESTURE_TAP, /* 单击:稳定按下 + 释放(位移小) */
GESTURE_LONG_PRESS, /* 长按:稳定按下超过 1000ms */
GESTURE_REPEAT, /* 长按后的重复触发:每 120ms */
GESTURE_DRAG, /* 拖动:按下后位移超过阈值 */
GESTURE_RELEASE, /* 释放:从按下到抬起(无位移或未触发长按) */
} app_touch_gesture_t;
/* ==================== 手势结果 ==================== */
typedef struct {
app_touch_gesture_t gesture; /* 产出的手势 */
uint16_t x, y; /* 当前坐标 */
uint16_t down_x, down_y; /* 按下起点DRAG/RELEASE 判断用) */
} app_touch_result_t;
/* ==================== 对外 API ==================== */
/* 重置状态机(页面切换/开机时可选调用) */
void app_touch_reset(void);
/* 切页后短暂忽略触摸,避免手指未抬起/ADC 抖动误触底栏设置 Tab */
void app_touch_suppress(uint32_t ms);
/* 核心:喂一个采样点,产出手势。
* 由 touch_task 每 20ms 调用一次。
* 有手势返回对应 gesture无手势返回 GESTURE_NONE。 */
app_touch_result_t app_touch_process(uint16_t x, uint16_t y, uint8_t pressed);
#endif /* APP_TOUCH_H */