Skip to content

Commit 82e3202

Browse files
committed
feat(st1633): update
1 parent efda82e commit 82e3202

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/touch/base/esp_lcd_touch_st1633.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,27 @@ static esp_err_t read_data(esp_lcd_touch_handle_t tp)
125125
uint8_t keys;
126126
xy_coord_t xy_coord[MAX_TOUCH_NUM];
127127
} 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");
129129

130130
tp_report_t tp_report = { 0 };
131131
ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, ADVANCED_INFO_REG, (uint8_t *)&tp_report, sizeof(tp_report)), TAG, "Read advanced info failed");
132132

133+
uint16_t x = 0;
134+
uint16_t y = 0;
133135
portENTER_CRITICAL(&tp->data.lock);
134136
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;
143143
}
144-
/* Expect Number of touched points */
144+
tp->data.coords[j].x = x;
145+
tp->data.coords[j].y = y;
146+
j++;
145147
}
148+
/* Expect Number of touched points */
146149
tp->data.points = j;
147150
portEXIT_CRITICAL(&tp->data.lock);
148151

@@ -215,20 +218,21 @@ static esp_err_t read_fw_info(esp_lcd_touch_handle_t tp)
215218
uint8_t revision[4] = { 0 };
216219
struct {
217220
uint8_t y_res_h: 3;
218-
uint8_t reserved_3_7: 5;
221+
uint8_t reserved_3: 1;
219222
uint8_t x_res_h: 3;
220-
uint8_t reserved_11_15: 5;
223+
uint8_t reserved_7: 1;
221224
uint8_t x_res_l;
222225
uint8_t y_res_l;
223226
} xy_res;
224-
static_assert(sizeof(xy_res) == 4, "Invalid size of info");
227+
static_assert(sizeof(xy_res) == 3, "Invalid size of info");
225228

226229
ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, FW_VERSION_REG, &version, 1), TAG, "Read version failed");
227230
ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, FW_REVISION_REG, (uint8_t *)&revision[0], sizeof(revision)), TAG, "Read revision failed");
228231
ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, XY_RES_H_REG, (uint8_t *)&xy_res, sizeof(xy_res)), TAG, "Read XY Resolution failed");
229232

230233
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);
232236

233237
return ESP_OK;
234238
}

0 commit comments

Comments
 (0)