Skip to content

Commit

Permalink
Merge pull request #212 from espressif2022/feature/esp_lcd_touch_low_…
Browse files Browse the repository at this point in the history
…power

esp_lcd_touch: add low power interface. (BSP-374)
  • Loading branch information
espzav authored Aug 31, 2023
2 parents 0771193 + 5b0adc5 commit 118800d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/lcd_touch/esp_lcd_touch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ menu "ESP LCD TOUCH"
int "Maximum count of the touch buttons supported"
range 0 10
default 1
endmenu

endmenu
1 change: 1 addition & 0 deletions components/lcd_touch/esp_lcd_touch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ This componnent is main esp_lcd_touch component which defines main functions and
- [x] Mirror X
- [x] Mirror Y
- [x] Interrupt callback
- [x] Sleep mode
- [ ] Calibration

24 changes: 23 additions & 1 deletion components/lcd_touch/esp_lcd_touch/esp_lcd_touch.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -28,6 +28,28 @@ static const char *TAG = "TP";
* Public API functions
*******************************************************************************/

esp_err_t esp_lcd_touch_enter_sleep(esp_lcd_touch_handle_t tp)
{
assert(tp != NULL);
if (tp->enter_sleep == NULL) {
ESP_LOGE(TAG, "Sleep mode not supported!");
return ESP_FAIL;
} else {
return tp->enter_sleep(tp);
}
}

esp_err_t esp_lcd_touch_exit_sleep(esp_lcd_touch_handle_t tp)
{
assert(tp != NULL);
if (tp->exit_sleep == NULL) {
ESP_LOGE(TAG, "Sleep mode not supported!");
return ESP_FAIL;
} else {
return tp->exit_sleep(tp);
}
}

esp_err_t esp_lcd_touch_read_data(esp_lcd_touch_handle_t tp)
{
assert(tp != NULL);
Expand Down
2 changes: 1 addition & 1 deletion components/lcd_touch/esp_lcd_touch/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.0.4"
version: "1.1.0"
description: ESP LCD Touch - main component for using touch screen controllers
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch
dependencies:
Expand Down
48 changes: 47 additions & 1 deletion components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -90,6 +90,30 @@ typedef struct {
*/
struct esp_lcd_touch_s {

/**
* @brief set touch controller into sleep mode
*
* @note This function is usually blocking.
*
* @param tp: Touch handler
*
* @return
* - ESP_OK on success, otherwise returns ESP_ERR_xxx
*/
esp_err_t (*enter_sleep)(esp_lcd_touch_handle_t tp);

/**
* @brief set touch controller into normal mode
*
* @note This function is usually blocking.
*
* @param tp: Touch handler
*
* @return
* - ESP_OK on success, otherwise returns ESP_ERR_xxx
*/
esp_err_t (*exit_sleep)(esp_lcd_touch_handle_t tp);

/**
* @brief Read data from touch controller (mandatory)
*
Expand Down Expand Up @@ -362,6 +386,28 @@ esp_err_t esp_lcd_touch_del(esp_lcd_touch_handle_t tp);
*/
esp_err_t esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_handle_t tp, esp_lcd_touch_interrupt_callback_t callback);

/**
* @brief Enter sleep mode
*
* @param tp: Touch handler
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if parameter is invalid
*/
esp_err_t esp_lcd_touch_enter_sleep(esp_lcd_touch_handle_t tp);

/**
* @brief Exit sleep mode
*
* @param tp: Touch handler
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if parameter is invalid
*/
esp_err_t esp_lcd_touch_exit_sleep(esp_lcd_touch_handle_t tp);

#ifdef __cplusplus
}
#endif

0 comments on commit 118800d

Please sign in to comment.