@@ -31,7 +31,7 @@ static const char *TAG = "TP";
3131
3232esp_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
4343esp_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
5454esp_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
110112esp_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 )
181183esp_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
198200esp_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
212214esp_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
227229esp_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
241243esp_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
256258esp_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
270272esp_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)
296298esp_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
331333esp_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 );
0 commit comments