improve touch with pooling

This commit is contained in:
Adolfo Reyna
2026-01-29 14:16:19 -05:00
parent d19a2ca639
commit 3a08cb5119
3 changed files with 398 additions and 75 deletions

View File

@@ -37,12 +37,25 @@ extern "C" {
#define FT6336U_REG_P2_WEIGHT 0x0D
#define FT6336U_REG_P2_MISC 0x0E
// Gesture parameter registers (for tuning gesture detection)
#define FT6336U_REG_RADIAN_VALUE 0x91 // Gesture angle threshold
#define FT6336U_REG_OFFSET_LEFT_RIGHT 0x92 // Horizontal gesture offset
#define FT6336U_REG_OFFSET_UP_DOWN 0x93 // Vertical gesture offset
#define FT6336U_REG_DISTANCE_LEFT_RIGHT 0x94 // Horizontal distance threshold
#define FT6336U_REG_DISTANCE_UP_DOWN 0x95 // Vertical distance threshold
#define FT6336U_REG_DISTANCE_ZOOM 0x96 // Zoom gesture distance
#define FT6336U_REG_CTRL 0x86 // Control mode register
#define FT6336U_REG_CHIPID 0xA3 // Chip ID (should read 0x64)
#define FT6336U_REG_G_MODE 0xA4 // Interrupt mode (polling or trigger)
#define FT6336U_REG_POWER_MODE 0xA5 // Power mode
#define FT6336U_REG_FIRMID 0xA6
#define FT6336U_REG_VENDID 0xA8
// CTRL_MODE values
#define FT6336U_CTRL_KEEP_ACTIVE_MODE 0x00 // Stay in active mode (better for interrupts)
#define FT6336U_CTRL_SWITCH_TO_MONITOR 0x01 // Auto-enter monitor mode (lower power)
// G_MODE values
#define FT6336U_G_MODE_POLLING 0x00
#define FT6336U_G_MODE_TRIGGER 0x01
@@ -150,6 +163,63 @@ uint8_t ft6336u_get_g_mode(void);
*/
uint8_t ft6336u_get_power_mode(void);
/**
* Set CTRL mode (active vs monitor mode)
* @param mode FT6336U_CTRL_KEEP_ACTIVE_MODE or FT6336U_CTRL_SWITCH_TO_MONITOR
* @return true if successful
*/
bool ft6336u_set_ctrl_mode(uint8_t mode);
/**
* Get current CTRL mode
* @return Current CTRL mode or 0xFF on error
*/
uint8_t ft6336u_get_ctrl_mode(void);
/**
* Read the INT pin state directly
* @return true if HIGH (no touch), false if LOW (touch active)
* Note: In trigger mode, INT pin is active LOW
*/
bool ft6336u_get_int_pin_state(void);
// Gesture parameter configuration (for tuning gesture detection)
/**
* Get/Set radian value (gesture angle threshold)
*/
uint8_t ft6336u_get_radian_value(void);
bool ft6336u_set_radian_value(uint8_t value);
/**
* Get/Set horizontal gesture offset
*/
uint8_t ft6336u_get_offset_left_right(void);
bool ft6336u_set_offset_left_right(uint8_t value);
/**
* Get/Set vertical gesture offset
*/
uint8_t ft6336u_get_offset_up_down(void);
bool ft6336u_set_offset_up_down(uint8_t value);
/**
* Get/Set horizontal distance threshold for gestures
*/
uint8_t ft6336u_get_distance_left_right(void);
bool ft6336u_set_distance_left_right(uint8_t value);
/**
* Get/Set vertical distance threshold for gestures
*/
uint8_t ft6336u_get_distance_up_down(void);
bool ft6336u_set_distance_up_down(uint8_t value);
/**
* Get/Set zoom gesture distance threshold
*/
uint8_t ft6336u_get_distance_zoom(void);
bool ft6336u_set_distance_zoom(uint8_t value);
#ifdef __cplusplus
}
#endif