@@ -125,24 +125,27 @@ static esp_err_t read_data(esp_lcd_touch_handle_t tp)
125
125
uint8_t keys ;
126
126
xy_coord_t xy_coord [MAX_TOUCH_NUM ];
127
127
} tp_report_t ;
128
- static_assert (sizeof (tp_report_t ) == 42 , "Invalid size of tp_report_t " );
128
+ static_assert (( sizeof (xy_coord_t ) == 4 ) && ( sizeof ( tp_report_t ) == 42 ) , "Invalid size of tp xy_coord_t or_report_t " );
129
129
130
130
tp_report_t tp_report = { 0 };
131
131
ESP_RETURN_ON_ERROR (i2c_read_bytes (tp , ADVANCED_INFO_REG , (uint8_t * )& tp_report , sizeof (tp_report )), TAG , "Read advanced info failed" );
132
132
133
+ uint16_t x = 0 ;
134
+ uint16_t y = 0 ;
133
135
portENTER_CRITICAL (& tp -> data .lock );
134
136
int j = 0 ;
135
- if (tp_report .gesture_type ) {
136
- /* Fill all coordinates */
137
- for (int i = 0 ; (i < MAX_TOUCH_NUM ) && (j < CONFIG_ESP_LCD_TOUCH_MAX_POINTS ); i ++ ) {
138
- if (!tp_report .xy_coord [i ].valid ) {
139
- continue ;
140
- }
141
- tp -> data .coords [j ].x = tp_report .xy_coord [i ].x_h << 8 | tp_report .xy_coord [i ].x_l ;
142
- tp -> data .coords [j ].y = tp_report .xy_coord [i ].y_h << 8 | tp_report .xy_coord [i ].y_l ;
137
+ /* Fill all coordinates */
138
+ for (int i = 0 ; (i < MAX_TOUCH_NUM ) && (j < CONFIG_ESP_LCD_TOUCH_MAX_POINTS ); i ++ ) {
139
+ x = ((uint16_t )tp_report .xy_coord [i ].x_h << 8 ) | tp_report .xy_coord [i ].x_l ;
140
+ y = ((uint16_t )tp_report .xy_coord [i ].y_h << 8 ) | tp_report .xy_coord [i ].y_l ;
141
+ if (((x == 0 ) && (y == 0 )) || (x > tp -> config .x_max ) || (y > tp -> config .y_max )) {
142
+ continue ;
143
143
}
144
- /* Expect Number of touched points */
144
+ tp -> data .coords [j ].x = x ;
145
+ tp -> data .coords [j ].y = y ;
146
+ j ++ ;
145
147
}
148
+ /* Expect Number of touched points */
146
149
tp -> data .points = j ;
147
150
portEXIT_CRITICAL (& tp -> data .lock );
148
151
@@ -215,20 +218,21 @@ static esp_err_t read_fw_info(esp_lcd_touch_handle_t tp)
215
218
uint8_t revision [4 ] = { 0 };
216
219
struct {
217
220
uint8_t y_res_h : 3 ;
218
- uint8_t reserved_3_7 : 5 ;
221
+ uint8_t reserved_3 : 1 ;
219
222
uint8_t x_res_h : 3 ;
220
- uint8_t reserved_11_15 : 5 ;
223
+ uint8_t reserved_7 : 1 ;
221
224
uint8_t x_res_l ;
222
225
uint8_t y_res_l ;
223
226
} xy_res ;
224
- static_assert (sizeof (xy_res ) == 4 , "Invalid size of info" );
227
+ static_assert (sizeof (xy_res ) == 3 , "Invalid size of info" );
225
228
226
229
ESP_RETURN_ON_ERROR (i2c_read_bytes (tp , FW_VERSION_REG , & version , 1 ), TAG , "Read version failed" );
227
230
ESP_RETURN_ON_ERROR (i2c_read_bytes (tp , FW_REVISION_REG , (uint8_t * )& revision [0 ], sizeof (revision )), TAG , "Read revision failed" );
228
231
ESP_RETURN_ON_ERROR (i2c_read_bytes (tp , XY_RES_H_REG , (uint8_t * )& xy_res , sizeof (xy_res )), TAG , "Read XY Resolution failed" );
229
232
230
233
ESP_LOGI (TAG , "Firmware version: %d(%d.%d.%d.%d), Max.X: %d, Max.Y: %d" , version , revision [3 ], revision [2 ],
231
- revision [1 ], revision [0 ], (xy_res .x_res_h << 8 ) | xy_res .x_res_l , (xy_res .y_res_h << 8 ) | xy_res .y_res_l );
234
+ revision [1 ], revision [0 ], (((uint16_t )xy_res .x_res_h ) << 8 ) | xy_res .x_res_l ,
235
+ (((uint16_t )xy_res .y_res_h ) << 8 ) | xy_res .y_res_l );
232
236
233
237
return ESP_OK ;
234
238
}
0 commit comments