Skip to content

Commit 3574be7

Browse files
committed
fix(lcd_touch): Align all touch drivers to the same syntax and argument checking
1 parent 1d5ffbc commit 3574be7

File tree

11 files changed

+127
-112
lines changed

11 files changed

+127
-112
lines changed

components/lcd_touch/esp_lcd_touch/esp_lcd_touch.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static const char *TAG = "TP";
3131

3232
esp_err_t esp_lcd_touch_enter_sleep(esp_lcd_touch_handle_t tp)
3333
{
34-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
34+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
3535
if (tp->enter_sleep == NULL) {
3636
ESP_LOGE(TAG, "Sleep mode not supported!");
3737
return ESP_FAIL;
@@ -42,7 +42,7 @@ esp_err_t esp_lcd_touch_enter_sleep(esp_lcd_touch_handle_t tp)
4242

4343
esp_err_t esp_lcd_touch_exit_sleep(esp_lcd_touch_handle_t tp)
4444
{
45-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
45+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
4646
if (tp->exit_sleep == NULL) {
4747
ESP_LOGE(TAG, "Sleep mode not supported!");
4848
return ESP_FAIL;
@@ -53,8 +53,8 @@ esp_err_t esp_lcd_touch_exit_sleep(esp_lcd_touch_handle_t tp)
5353

5454
esp_err_t esp_lcd_touch_read_data(esp_lcd_touch_handle_t tp)
5555
{
56-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
57-
assert(tp->read_data != NULL);
56+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
57+
ESP_RETURN_ON_FALSE(tp->read_data != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller must be initialized");
5858

5959
return tp->read_data(tp);
6060
}
@@ -63,10 +63,12 @@ bool esp_lcd_touch_get_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint1
6363
{
6464
bool touched = false;
6565

66-
ESP_RETURN_ON_FALSE(tp != NULL, false, TAG, "Touch point handler can't be NULL");
67-
ESP_RETURN_ON_FALSE(x != NULL, false, TAG, "X coordinates data array can't be NULL");
68-
ESP_RETURN_ON_FALSE(y != NULL, false, TAG, "Y coordinates data array can't be NULL");
69-
ESP_RETURN_ON_FALSE(tp->get_xy != NULL, false, TAG, "Touch driver must be initialized");
66+
ESP_RETURN_ON_FALSE(tp != NULL, false, TAG, "Touch controller handle can't be NULL");
67+
ESP_RETURN_ON_FALSE(x != NULL, false, TAG, "Pointer to the x coordinates array can't be NULL");
68+
ESP_RETURN_ON_FALSE(y != NULL, false, TAG, "Pointer to the y coordinates array can't be NULL");
69+
ESP_RETURN_ON_FALSE(point_num != NULL, false, TAG, "Pointer to number of touch points can't be NULL");
70+
ESP_RETURN_ON_FALSE(max_point_num > 0, false, TAG, "Array size must be equal or larger than 1");
71+
ESP_RETURN_ON_FALSE(tp->get_xy != NULL, false, TAG, "Touch controller must be initialized");
7072

7173
touched = tp->get_xy(tp, x, y, strength, point_num, max_point_num);
7274
if (!touched) {
@@ -109,11 +111,11 @@ bool esp_lcd_touch_get_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint1
109111

110112
esp_err_t esp_lcd_touch_get_data(esp_lcd_touch_handle_t tp, esp_lcd_touch_point_data_t *data, uint8_t *point_cnt, uint8_t max_point_cnt)
111113
{
112-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
113-
ESP_RETURN_ON_FALSE(data != NULL, ESP_ERR_INVALID_ARG, TAG, "Data array can't be NULL");
114-
ESP_RETURN_ON_FALSE(point_cnt != NULL, ESP_ERR_INVALID_ARG, TAG, "Point count pointer can't be NULL");
115-
ESP_RETURN_ON_FALSE(tp->get_xy != NULL, ESP_ERR_INVALID_STATE, TAG, "Touch driver must be initialized");
116-
ESP_RETURN_ON_FALSE(max_point_cnt > 0, ESP_ERR_INVALID_ARG, TAG, "Array size must be at least 1");
114+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
115+
ESP_RETURN_ON_FALSE(data != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the data array can't be NULL");
116+
ESP_RETURN_ON_FALSE(point_cnt != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the count of touch points can't be NULL");
117+
ESP_RETURN_ON_FALSE(tp->get_xy != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller must be initialized");
118+
ESP_RETURN_ON_FALSE(max_point_cnt > 0, ESP_ERR_INVALID_ARG, TAG, "Array size must be equal or larger than 1");
117119

118120
uint16_t x[max_point_cnt];
119121
uint16_t y[max_point_cnt];
@@ -180,8 +182,8 @@ esp_err_t esp_lcd_touch_get_data(esp_lcd_touch_handle_t tp, esp_lcd_touch_point_
180182
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
181183
esp_err_t esp_lcd_touch_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state)
182184
{
183-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
184-
ESP_RETURN_ON_FALSE(state != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL");
185+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
186+
ESP_RETURN_ON_FALSE(state != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the state array can't be NULL");
185187

186188
*state = 0;
187189

@@ -197,7 +199,7 @@ esp_err_t esp_lcd_touch_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, u
197199

198200
esp_err_t esp_lcd_touch_set_swap_xy(esp_lcd_touch_handle_t tp, bool swap)
199201
{
200-
assert(tp != NULL);
202+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
201203

202204
tp->config.flags.swap_xy = swap;
203205

@@ -211,8 +213,8 @@ esp_err_t esp_lcd_touch_set_swap_xy(esp_lcd_touch_handle_t tp, bool swap)
211213

212214
esp_err_t esp_lcd_touch_get_swap_xy(esp_lcd_touch_handle_t tp, bool *swap)
213215
{
214-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
215-
ESP_RETURN_ON_FALSE(swap != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL");
216+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
217+
ESP_RETURN_ON_FALSE(swap != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the swap variable can't be NULL");
216218

217219
/* Is swap supported by HW? */
218220
if (tp->get_swap_xy) {
@@ -226,7 +228,7 @@ esp_err_t esp_lcd_touch_get_swap_xy(esp_lcd_touch_handle_t tp, bool *swap)
226228

227229
esp_err_t esp_lcd_touch_set_mirror_x(esp_lcd_touch_handle_t tp, bool mirror)
228230
{
229-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
231+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
230232

231233
tp->config.flags.mirror_x = mirror;
232234

@@ -240,8 +242,8 @@ esp_err_t esp_lcd_touch_set_mirror_x(esp_lcd_touch_handle_t tp, bool mirror)
240242

241243
esp_err_t esp_lcd_touch_get_mirror_x(esp_lcd_touch_handle_t tp, bool *mirror)
242244
{
243-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
244-
ESP_RETURN_ON_FALSE(mirror != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL");
245+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
246+
ESP_RETURN_ON_FALSE(mirror != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the mirror variable can't be NULL");
245247

246248
/* Is swap supported by HW? */
247249
if (tp->get_mirror_x) {
@@ -255,7 +257,7 @@ esp_err_t esp_lcd_touch_get_mirror_x(esp_lcd_touch_handle_t tp, bool *mirror)
255257

256258
esp_err_t esp_lcd_touch_set_mirror_y(esp_lcd_touch_handle_t tp, bool mirror)
257259
{
258-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
260+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
259261

260262
tp->config.flags.mirror_y = mirror;
261263

@@ -269,8 +271,8 @@ esp_err_t esp_lcd_touch_set_mirror_y(esp_lcd_touch_handle_t tp, bool mirror)
269271

270272
esp_err_t esp_lcd_touch_get_mirror_y(esp_lcd_touch_handle_t tp, bool *mirror)
271273
{
272-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
273-
ESP_RETURN_ON_FALSE(mirror != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL");
274+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
275+
ESP_RETURN_ON_FALSE(mirror != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the mirror variable can't be NULL");
274276

275277
/* Is swap supported by HW? */
276278
if (tp->get_mirror_y) {
@@ -296,7 +298,7 @@ esp_err_t esp_lcd_touch_del(esp_lcd_touch_handle_t tp)
296298
esp_err_t esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_handle_t tp, esp_lcd_touch_interrupt_callback_t callback)
297299
{
298300
esp_err_t ret = ESP_OK;
299-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
301+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
300302

301303
/* Interrupt pin is not selected */
302304
if (tp->config.int_gpio_num == GPIO_NUM_NC) {
@@ -330,7 +332,7 @@ esp_err_t esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_handle_t tp, e
330332

331333
esp_err_t esp_lcd_touch_register_interrupt_callback_with_data(esp_lcd_touch_handle_t tp, esp_lcd_touch_interrupt_callback_t callback, void *user_data)
332334
{
333-
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL");
335+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
334336

335337
tp->config.user_data = user_data;
336338
return esp_lcd_touch_register_interrupt_callback(tp, callback);

components/lcd_touch/esp_lcd_touch/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.2.0"
1+
version: "1.2.1"
22
description: ESP LCD Touch - main component for using touch screen controllers
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch
44
dependencies:

components/lcd_touch/esp_lcd_touch_cst816s/README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void touch_callback(esp_lcd_touch_handle_t tp)
5050

5151
Initialization of the touch component.
5252

53-
```
53+
``` c
5454
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
5555

5656
esp_lcd_touch_config_t tp_cfg = {
@@ -76,19 +76,17 @@ Initialization of the touch component.
7676
7777
Read data from the touch controller and store it in RAM memory. It should be called regularly in poll.
7878
79-
```
79+
``` c
8080
if (xSemaphoreTake(touch_mux, 0) == pdTRUE) {
8181
esp_lcd_touch_read_data(tp); // read only when ISR was triggled
8282
}
8383
```
8484

85-
Get one X and Y coordinates with strength of touch.
85+
Get attributes of a single touch point.
8686

87-
```
88-
uint16_t touch_x[1];
89-
uint16_t touch_y[1];
90-
uint16_t touch_strength[1];
87+
``` c
88+
esp_lcd_touch_point_data_t touch_point_data[1];
9189
uint8_t touch_cnt = 0;
9290

93-
bool touchpad_pressed = esp_lcd_touch_get_coordinates(tp, touch_x, touch_y, touch_strength, &touch_cnt, 1);
91+
ESP_ERROR_CHECK(esp_lcd_touch_get_data(tp, touch_point_data, &touch_cnt, 1));
9492
```

components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@
2424

2525
static const char *TAG = "CST816S";
2626

27-
static esp_err_t read_data(esp_lcd_touch_handle_t tp);
28-
static bool get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num);
29-
static esp_err_t del(esp_lcd_touch_handle_t tp);
27+
static esp_err_t esp_lcd_touch_cst816s_read_data(esp_lcd_touch_handle_t tp);
28+
static bool esp_lcd_touch_cst816s_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num);
29+
static esp_err_t esp_lcd_touch_cst816s_del(esp_lcd_touch_handle_t tp);
3030

31-
static esp_err_t i2c_read_bytes(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len);
31+
static esp_err_t touch_cst816s_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len);
3232

33-
static esp_err_t reset(esp_lcd_touch_handle_t tp);
34-
static esp_err_t read_id(esp_lcd_touch_handle_t tp);
33+
static esp_err_t touch_cst816s_reset(esp_lcd_touch_handle_t tp);
34+
static esp_err_t touch_cst816s_read_id(esp_lcd_touch_handle_t tp);
3535

3636
esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *tp)
3737
{
38-
ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_ARG, TAG, "Invalid io");
39-
ESP_RETURN_ON_FALSE(config, ESP_ERR_INVALID_ARG, TAG, "Invalid config");
40-
ESP_RETURN_ON_FALSE(tp, ESP_ERR_INVALID_ARG, TAG, "Invalid touch handle");
38+
ESP_RETURN_ON_FALSE(io != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller io handle can't be NULL");
39+
ESP_RETURN_ON_FALSE(config != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the touch controller configuration can't be NULL");
40+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the touch controller handle can't be NULL");
4141

4242
/* Prepare main structure */
4343
esp_err_t ret = ESP_OK;
@@ -47,9 +47,9 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
4747
/* Communication interface */
4848
cst816s->io = io;
4949
/* Only supported callbacks are set */
50-
cst816s->read_data = read_data;
51-
cst816s->get_xy = get_xy;
52-
cst816s->del = del;
50+
cst816s->read_data = esp_lcd_touch_cst816s_read_data;
51+
cst816s->get_xy = esp_lcd_touch_cst816s_get_xy;
52+
cst816s->del = esp_lcd_touch_cst816s_del;
5353
/* Mutex */
5454
cst816s->data.lock.owner = portMUX_FREE_VAL;
5555
/* Save config */
@@ -78,26 +78,28 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
7878
ESP_GOTO_ON_ERROR(gpio_config(&rst_gpio_config), err, TAG, "GPIO reset config failed");
7979
}
8080
/* Reset controller */
81-
ESP_GOTO_ON_ERROR(reset(cst816s), err, TAG, "Reset failed");
81+
ESP_GOTO_ON_ERROR(touch_cst816s_reset(cst816s), err, TAG, "Reset failed");
8282
/* Read product id */
8383
#ifdef CONFIG_ESP_LCD_TOUCH_CST816S_DISABLE_READ_ID
8484
ESP_LOGI(TAG, "Read ID disabled");
8585
#else
86-
ESP_GOTO_ON_ERROR(read_id(cst816s), err, TAG, "Read ID failed");
86+
ESP_GOTO_ON_ERROR(touch_cst816s_read_id(cst816s), err, TAG, "Read ID failed");
8787
#endif
8888
*tp = cst816s;
8989

9090
return ESP_OK;
9191
err:
9292
if (cst816s) {
93-
del(cst816s);
93+
esp_lcd_touch_cst816s_del(cst816s);
9494
}
9595
ESP_LOGE(TAG, "Initialization failed!");
9696
return ret;
9797
}
9898

99-
static esp_err_t read_data(esp_lcd_touch_handle_t tp)
99+
static esp_err_t esp_lcd_touch_cst816s_read_data(esp_lcd_touch_handle_t tp)
100100
{
101+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
102+
101103
typedef struct {
102104
uint8_t num;
103105
uint8_t x_h : 4;
@@ -109,7 +111,7 @@ static esp_err_t read_data(esp_lcd_touch_handle_t tp)
109111
} data_t;
110112

111113
data_t point;
112-
ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, DATA_START_REG, (uint8_t *)&point, sizeof(data_t)), TAG, "I2C read failed");
114+
ESP_RETURN_ON_ERROR(touch_cst816s_i2c_read(tp, DATA_START_REG, (uint8_t *)&point, sizeof(data_t)), TAG, "I2C read failed");
113115

114116
portENTER_CRITICAL(&tp->data.lock);
115117
point.num = (point.num > POINT_NUM_MAX ? POINT_NUM_MAX : point.num);
@@ -124,8 +126,14 @@ static esp_err_t read_data(esp_lcd_touch_handle_t tp)
124126
return ESP_OK;
125127
}
126128

127-
static bool get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num)
129+
static bool esp_lcd_touch_cst816s_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num)
128130
{
131+
ESP_RETURN_ON_FALSE(tp != NULL, false, TAG, "Touch controller handle can't be NULL");
132+
ESP_RETURN_ON_FALSE(x != NULL, false, TAG, "Pointer to the x coordinates array can't be NULL");
133+
ESP_RETURN_ON_FALSE(y != NULL, false, TAG, "Pointer to the y coordinates array can't be NULL");
134+
ESP_RETURN_ON_FALSE(point_num != NULL, false, TAG, "Pointer to number of touch points can't be NULL");
135+
ESP_RETURN_ON_FALSE(max_point_num > 0, false, TAG, "Array size must be equal or larger than 1");
136+
129137
portENTER_CRITICAL(&tp->data.lock);
130138
/* Count of points */
131139
*point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points);
@@ -144,8 +152,10 @@ static bool get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t
144152
return (*point_num > 0);
145153
}
146154

147-
static esp_err_t del(esp_lcd_touch_handle_t tp)
155+
static esp_err_t esp_lcd_touch_cst816s_del(esp_lcd_touch_handle_t tp)
148156
{
157+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
158+
149159
/* Reset GPIO pin settings */
150160
if (tp->config.int_gpio_num != GPIO_NUM_NC) {
151161
gpio_reset_pin(tp->config.int_gpio_num);
@@ -162,8 +172,10 @@ static esp_err_t del(esp_lcd_touch_handle_t tp)
162172
return ESP_OK;
163173
}
164174

165-
static esp_err_t reset(esp_lcd_touch_handle_t tp)
175+
static esp_err_t touch_cst816s_reset(esp_lcd_touch_handle_t tp)
166176
{
177+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
178+
167179
if (tp->config.rst_gpio_num != GPIO_NUM_NC) {
168180
ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, tp->config.levels.reset), TAG, "GPIO set level failed");
169181
vTaskDelay(pdMS_TO_TICKS(200));
@@ -175,18 +187,21 @@ static esp_err_t reset(esp_lcd_touch_handle_t tp)
175187
}
176188

177189
#ifndef CONFIG_ESP_LCD_TOUCH_CST816S_DISABLE_READ_ID
178-
static esp_err_t read_id(esp_lcd_touch_handle_t tp)
190+
static esp_err_t touch_cst816s_read_id(esp_lcd_touch_handle_t tp)
179191
{
192+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
193+
180194
uint8_t id;
181-
ESP_RETURN_ON_ERROR(i2c_read_bytes(tp, CHIP_ID_REG, &id, 1), TAG, "I2C read failed");
195+
ESP_RETURN_ON_ERROR(touch_cst816s_i2c_read(tp, CHIP_ID_REG, &id, 1), TAG, "I2C read failed");
182196
ESP_LOGI(TAG, "IC id: %d", id);
183197
return ESP_OK;
184198
}
185199
#endif
186200

187-
static esp_err_t i2c_read_bytes(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len)
201+
static esp_err_t touch_cst816s_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len)
188202
{
189-
ESP_RETURN_ON_FALSE(data, ESP_ERR_INVALID_ARG, TAG, "Invalid data");
203+
ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch controller handle can't be NULL");
204+
ESP_RETURN_ON_FALSE(data != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to the data array can't be NULL");
190205

191206
return esp_lcd_panel_io_rx_param(tp->io, reg, data, len);
192207
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
version: "1.1.0"
1+
version: "1.1.1"
22
description: ESP LCD Touch CST816S - touch controller CST816S
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_cst816s
44
dependencies:
55
idf: ">=4.4.2"
66
esp_lcd_touch:
7-
version: "^1.0.4"
7+
version: "^1.2.0"
88
public: true
99
override_path: ../esp_lcd_touch

components/lcd_touch/esp_lcd_touch_gt911/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
2222

2323
Initialization of the touch component.
2424

25-
```
25+
``` c
2626
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
2727

2828
esp_lcd_touch_io_gt911_config_t tp_gt911_config = {
@@ -52,13 +52,13 @@ Initialization of the touch component.
5252
5353
Read data from the touch controller and store it in RAM memory. It should be called regularly in poll.
5454
55-
```
55+
``` c
5656
esp_lcd_touch_read_data(tp);
5757
```
5858

5959
Get attributes of a single touch point.
6060

61-
```
61+
``` c
6262
esp_lcd_touch_point_data_t touch_point_data[1];
6363
uint8_t touch_cnt = 0;
6464

0 commit comments

Comments
 (0)