-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lcd_touch): support trank id (BSP-536) #369
base: master
Are you sure you want to change the base?
feat(lcd_touch): support trank id (BSP-536) #369
Conversation
@@ -58,7 +58,7 @@ esp_err_t esp_lcd_touch_read_data(esp_lcd_touch_handle_t tp) | |||
return tp->read_data(tp); | |||
} | |||
|
|||
bool esp_lcd_touch_get_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num) | |||
bool esp_lcd_touch_get_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *track_id, uint8_t *point_num, uint8_t max_point_num) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot change API. We can create another function with similar API.
@@ -59,7 +59,7 @@ typedef struct { | |||
} flags; | |||
|
|||
/*!< User callback called after get coordinates from touch controller for apply user adjusting */ | |||
void (*process_coordinates)(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num); | |||
void (*process_coordinates)(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *track_id, uint8_t *point_num, uint8_t max_point_num); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot change API. We can create another function with similar API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be a good name for the new function?
The current function name is static bool esp_lcd_touch_ft5x06_get_xy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have two options for it:
bool esp_lcd_touch_get_coordinates_track_id(esp_lcd_touch_handle_t tp, uint8_t *track_id);
bool esp_lcd_touch_get_coordinates_track_id(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *track_id, uint8_t *point_num, uint8_t max_point_num)
Same for bool (*get_xy)(...)
and callback void (*process_coordinates)(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, the touch chip actually supports some additional special features. For example, the FT5x06 can indicate whether a swipe is to the left or right, and whether each touch point is currently being pressed or swiped, among other things. It would be best to address these issues all at once and lay the groundwork for future requirements.
bool esp_lcd_touch_get_coordinates_data(esp_lcd_touch_handle_t tp, void *data)
{
ft5x06_data_t *ft_data = (ft5x06_data_t *)data;
// ft_data->x[i]
// ft_data->trank_id
//...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good idea, but it looks little dangerous use void type and we don't know const count of touches.
We can do something like this:
typedef struct {
uint16_t x;
uint16_t y;
uint16_t strength;
uint16_t track_id;
void * user_data;
} esp_lcd_touch_coordinates_data_t;
bool esp_lcd_touch_get_coordinates_data(esp_lcd_touch_handle_t tp, esp_lcd_touch_coordinates_data_t * data, uint8_t *point_num, uint8_t max_point_num);
Usage:
esp_lcd_touch_coordinates_data_t data[4];
uint8_t points = 0;
esp_lcd_touch_get_coordinates_data(tp, data, &points, sizeof(data)/sizeof(esp_lcd_touch_coordinates_data_t));
Note: This structure can be very easily extended in future. And any driver can use user_data
for specific strusture. There should be any data type check (I don't know, if it is possible in C - something like compare typeof()
)
@igrr @tore-espressif What do you think about this solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about handling everything within a struct?
typedef struct {
uint16_t x;
uint16_t y;
uint16_t strength;
uint16_t track_id;
} point_data_t;
typedef struct {
esp_lcd_touch_gesture_t gesture_id;
point_data_t *data;
uint32_t num_points;
} esp_lcd_touch_coordinates_data_t;
However, it's important to note that not every chip has all of this information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you said, some features are not supported in all chips, I think the gestures should be in own function and we can return NOT_SUPPORTED error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And any driver can use user_data for specific structure. There should be any data type check (I don't know, if it is possible in C - something like compare typeof())
If we want to return device specific data, this should be handled in the specific touch driver eg. esp_lcd_touch_ft5x06
and NOT in esp_lcd_touch
base component. C language does not have runtime type information
So there are 2 types of returned data
- somewhat common across different touch controllers (eg. track_id). These could be added to base
esp_lcd_touch
with a function similar toesp_lcd_touch_get_coordinates_data
- Specific to the touch driver e.g. gestures. These function should be added to the specific touch driver eg.
esp_lcd_touch_ft5x06_gesture()
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Specific to the touch driver e.g. gestures. These function should be added to the specific touch driver eg.
esp_lcd_touch_ft5x06_gesture()
Are gestures
specific for touch driver? Aren't it more common over lot of drivers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are gestures specific for touch driver? Aren't it more common over lot of drivers?
🤷♂️ :D
If yes, let's make it all common
ESP-BSP Pull Request checklist
Change description
Please describe your change here
link #358