Skip to content

Commit

Permalink
feat(esp_lcd): Add API to sleep and wakeup the LCD panel
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGreco authored and movsb committed Dec 1, 2023
1 parent 31aacfc commit a00a63e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
13 changes: 12 additions & 1 deletion components/esp_lcd/include/esp_lcd_panel_ops.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -133,6 +133,17 @@ esp_err_t esp_lcd_panel_disp_on_off(esp_lcd_panel_handle_t panel, bool on_off);
esp_err_t esp_lcd_panel_disp_off(esp_lcd_panel_handle_t panel, bool off)
__attribute__((deprecated("use esp_lcd_panel_disp_on_off instead")));

/**
* @brief Enter or exit sleep mode
*
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
* @param[in] sleep True to enter sleep mode, False to wake up
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
*/
esp_err_t esp_lcd_panel_disp_sleep(esp_lcd_panel_handle_t panel, bool sleep);

#ifdef __cplusplus
}
#endif
13 changes: 12 additions & 1 deletion components/esp_lcd/interface/esp_lcd_panel_interface.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -120,6 +120,17 @@ struct esp_lcd_panel_t {
*/
esp_err_t (*disp_on_off)(esp_lcd_panel_t *panel, bool on_off);

/**
* @brief Enter or exit sleep mode
*
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
* @param[in] sleep True to enter sleep mode, False to wake up
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
*/
esp_err_t (*disp_sleep)(esp_lcd_panel_t *panel, bool sleep);

void *user_data; /*!< User data, used to store externally customized data */
};

Expand Down
9 changes: 8 additions & 1 deletion components/esp_lcd/src/esp_lcd_panel_ops.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -68,3 +68,10 @@ esp_err_t esp_lcd_panel_disp_off(esp_lcd_panel_handle_t panel, bool off)
{
return esp_lcd_panel_disp_on_off(panel, !off);
}

esp_err_t esp_lcd_panel_disp_sleep(esp_lcd_panel_handle_t panel, bool sleep)
{
ESP_RETURN_ON_FALSE(panel, ESP_ERR_INVALID_ARG, TAG, "invalid panel handle");
ESP_RETURN_ON_FALSE(panel->disp_sleep, ESP_ERR_NOT_SUPPORTED, TAG, "sleep is not supported by this panel");
return panel->disp_sleep(panel, sleep);
}

0 comments on commit a00a63e

Please sign in to comment.