From b4bcb5cc5c442481497c3aa81ca2e99df8b2e158 Mon Sep 17 00:00:00 2001 From: morris Date: Mon, 9 Oct 2023 15:04:40 +0800 Subject: [PATCH] test(esp_lcd): test lcd sleep function --- .../spi_lcd/main/test_spi_lcd_panel.c | 23 ++++++++++++++++--- docs/en/api-reference/peripherals/lcd.rst | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/components/esp_lcd/test_apps/spi_lcd/main/test_spi_lcd_panel.c b/components/esp_lcd/test_apps/spi_lcd/main/test_spi_lcd_panel.c index 092f9abb0c..eb40f3dcf9 100644 --- a/components/esp_lcd/test_apps/spi_lcd/main/test_spi_lcd_panel.c +++ b/components/esp_lcd/test_apps/spi_lcd/main/test_spi_lcd_panel.c @@ -90,14 +90,29 @@ static void lcd_panel_test(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_ha // turn on backlight gpio_set_level(TEST_LCD_BK_LIGHT_GPIO, 1); - for (int i = 0; i < 200; i++) { + for (int i = 0; i < 100; i++) { uint8_t color_byte = rand() & 0xFF; int x_start = rand() % (TEST_LCD_H_RES - 200); int y_start = rand() % (TEST_LCD_V_RES - 200); memset(img, color_byte, TEST_IMG_SIZE); esp_lcd_panel_draw_bitmap(panel_handle, x_start, y_start, x_start + 200, y_start + 200, img); } - // turn off screen + + printf("go into sleep mode\r\n"); + esp_lcd_panel_disp_sleep(panel_handle, true); + vTaskDelay(pdMS_TO_TICKS(500)); + printf("exit sleep mode\r\n"); + esp_lcd_panel_disp_sleep(panel_handle, false); + + for (int i = 0; i < 100; i++) { + uint8_t color_byte = rand() & 0xFF; + int x_start = rand() % (TEST_LCD_H_RES - 200); + int y_start = rand() % (TEST_LCD_V_RES - 200); + memset(img, color_byte, TEST_IMG_SIZE); + esp_lcd_panel_draw_bitmap(panel_handle, x_start, y_start, x_start + 200, y_start + 200, img); + } + + printf("turn off the panel\r\n"); esp_lcd_panel_disp_on_off(panel_handle, false); TEST_ESP_OK(esp_lcd_panel_del(panel_handle)); TEST_ESP_OK(esp_lcd_panel_io_del(io_handle)); @@ -247,12 +262,14 @@ TEST_CASE("spi_lcd_send_colors_to_fixed_region", "[lcd]") TEST_ESP_OK(esp_lcd_panel_io_tx_color(io_handle, -1, color_data + i * color_size_per_step, color_size_per_step)); } vTaskDelay(pdMS_TO_TICKS(1000)); - // change to another color + + printf("change to another color\r\n"); color_byte = rand() & 0xFF; memset(color_data, color_byte, color_size); for (int i = 0; i < steps; i++) { TEST_ESP_OK(esp_lcd_panel_io_tx_color(io_handle, -1, color_data + i * color_size_per_step, color_size_per_step)); } + vTaskDelay(pdMS_TO_TICKS(1000)); TEST_ESP_OK(esp_lcd_panel_del(panel_handle)); TEST_ESP_OK(esp_lcd_panel_io_del(io_handle)); diff --git a/docs/en/api-reference/peripherals/lcd.rst b/docs/en/api-reference/peripherals/lcd.rst index d0708e0645..625f261e38 100644 --- a/docs/en/api-reference/peripherals/lcd.rst +++ b/docs/en/api-reference/peripherals/lcd.rst @@ -454,7 +454,8 @@ LCD Panel IO Operations * :cpp:func:`esp_lcd_panel_reset` can reset the LCD panel. * :cpp:func:`esp_lcd_panel_init` performs a basic initialization of the panel. To perform more manufacture specific initialization, please go to :ref:`steps_add_manufacture_init`. * Through combined use of :cpp:func:`esp_lcd_panel_swap_xy` and :cpp:func:`esp_lcd_panel_mirror`, you can rotate the LCD screen. -* :cpp:func:`esp_lcd_panel_disp_on_off` can turn on or off the LCD screen (different from LCD backlight). +* :cpp:func:`esp_lcd_panel_disp_on_off` can turn on or off the LCD screen by cutting down the output path from the frame buffer to the LCD screen. +* :cpp:func:`esp_lcd_panel_disp_sleep` can reduce the power consumption of the LCD screen by entering the sleep mode. The internal frame buffer is still retained. * :cpp:func:`esp_lcd_panel_draw_bitmap` is the most significant function, which does the magic to draw the user provided color buffer to the LCD screen, where the draw window is also configurable. .. _steps_add_manufacture_init: