|
|
@@ -1,8 +1,12 @@
|
|
|
+/*
|
|
|
+ * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
|
+ *
|
|
|
+ * SPDX-License-Identifier: Apache-2.0
|
|
|
+ */
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include "sdkconfig.h"
|
|
|
#include "unity.h"
|
|
|
-#include "test_utils.h"
|
|
|
#include "driver/spi_master.h"
|
|
|
#include "driver/gpio.h"
|
|
|
#include "esp_lcd_panel_io.h"
|
|
|
@@ -12,16 +16,22 @@
|
|
|
#include "soc/soc_caps.h"
|
|
|
#include "test_spi_board.h"
|
|
|
|
|
|
-#define TEST_SPI_HOST_ID (1)
|
|
|
-#define TEST_LCD_PIXEL_CLOCK_HZ (20 * 1000 * 1000) // 20MHz
|
|
|
+#define TEST_SPI_HOST_ID SPI2_HOST
|
|
|
|
|
|
-static void lcd_initialize_spi(esp_lcd_panel_io_handle_t *io_handle, esp_lcd_panel_io_color_trans_done_cb_t on_color_trans_done, void *user_ctx, int cmd_bits, int param_bits, bool oct_mode)
|
|
|
+void test_app_include_spi_lcd(void)
|
|
|
{
|
|
|
+}
|
|
|
+
|
|
|
+void test_spi_lcd_common_initialize(esp_lcd_panel_io_handle_t *io_handle, esp_lcd_panel_io_color_trans_done_cb_t on_color_trans_done,
|
|
|
+ void *user_data, int cmd_bits, int param_bits, bool oct_mode)
|
|
|
+{
|
|
|
+ // turn off backlight
|
|
|
gpio_config_t bk_gpio_config = {
|
|
|
.mode = GPIO_MODE_OUTPUT,
|
|
|
.pin_bit_mask = 1ULL << TEST_LCD_BK_LIGHT_GPIO
|
|
|
};
|
|
|
TEST_ESP_OK(gpio_config(&bk_gpio_config));
|
|
|
+ gpio_set_level(TEST_LCD_BK_LIGHT_GPIO, 0);
|
|
|
|
|
|
spi_bus_config_t buscfg = {
|
|
|
.sclk_io_num = TEST_LCD_PCLK_GPIO,
|
|
|
@@ -52,7 +62,7 @@ static void lcd_initialize_spi(esp_lcd_panel_io_handle_t *io_handle, esp_lcd_pan
|
|
|
.lcd_cmd_bits = cmd_bits,
|
|
|
.lcd_param_bits = param_bits,
|
|
|
.on_color_trans_done = on_color_trans_done,
|
|
|
- .user_ctx = user_ctx
|
|
|
+ .user_ctx = user_data,
|
|
|
};
|
|
|
if (oct_mode) {
|
|
|
io_config.flags.octal_mode = 1;
|
|
|
@@ -67,8 +77,6 @@ static void lcd_panel_test(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_ha
|
|
|
uint8_t *img = heap_caps_malloc(TEST_IMG_SIZE, MALLOC_CAP_DMA);
|
|
|
TEST_ASSERT_NOT_NULL(img);
|
|
|
|
|
|
- // turn off backlight
|
|
|
- gpio_set_level(TEST_LCD_BK_LIGHT_GPIO, 0);
|
|
|
esp_lcd_panel_reset(panel_handle);
|
|
|
esp_lcd_panel_init(panel_handle);
|
|
|
esp_lcd_panel_invert_color(panel_handle, true);
|
|
|
@@ -94,10 +102,10 @@ static void lcd_panel_test(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_ha
|
|
|
#undef TEST_IMG_SIZE
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("lcd panel spi io test", "[lcd]")
|
|
|
+TEST_CASE("lcd_panel_spi_io_test", "[lcd]")
|
|
|
{
|
|
|
esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
|
- lcd_initialize_spi(&io_handle, NULL, NULL, 8, 8, false);
|
|
|
+ test_spi_lcd_common_initialize(&io_handle, NULL, NULL, 8, 8, false);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1A, NULL, 0);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1B, (uint8_t[]) {
|
|
|
0x11, 0x22, 0x33
|
|
|
@@ -106,7 +114,7 @@ TEST_CASE("lcd panel spi io test", "[lcd]")
|
|
|
TEST_ESP_OK(esp_lcd_panel_io_del(io_handle));
|
|
|
TEST_ESP_OK(spi_bus_free(TEST_SPI_HOST_ID));
|
|
|
|
|
|
- lcd_initialize_spi(&io_handle, NULL, NULL, 16, 16, false);
|
|
|
+ test_spi_lcd_common_initialize(&io_handle, NULL, NULL, 16, 16, false);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1A01, NULL, 0);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1B02, (uint16_t[]) {
|
|
|
0x11, 0x22, 0x33
|
|
|
@@ -116,7 +124,7 @@ TEST_CASE("lcd panel spi io test", "[lcd]")
|
|
|
TEST_ESP_OK(spi_bus_free(TEST_SPI_HOST_ID));
|
|
|
|
|
|
#if SOC_SPI_SUPPORT_OCT
|
|
|
- lcd_initialize_spi(&io_handle, NULL, NULL, 8, 8, true);
|
|
|
+ test_spi_lcd_common_initialize(&io_handle, NULL, NULL, 8, 8, true);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1A, NULL, 0);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1B, (uint8_t[]) {
|
|
|
0x11, 0x22, 0x33
|
|
|
@@ -125,7 +133,7 @@ TEST_CASE("lcd panel spi io test", "[lcd]")
|
|
|
TEST_ESP_OK(esp_lcd_panel_io_del(io_handle));
|
|
|
TEST_ESP_OK(spi_bus_free(TEST_SPI_HOST_ID));
|
|
|
|
|
|
- lcd_initialize_spi(&io_handle, NULL, NULL, 16, 16, true);
|
|
|
+ test_spi_lcd_common_initialize(&io_handle, NULL, NULL, 16, 16, true);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1A01, NULL, 0);
|
|
|
esp_lcd_panel_io_tx_param(io_handle, 0x1B02, (uint16_t[]) {
|
|
|
0x11, 0x22, 0x33
|
|
|
@@ -137,11 +145,11 @@ TEST_CASE("lcd panel spi io test", "[lcd]")
|
|
|
}
|
|
|
|
|
|
#if SOC_SPI_SUPPORT_OCT
|
|
|
-TEST_CASE("lcd panel with 8-line spi interface (st7789)", "[lcd]")
|
|
|
+TEST_CASE("lcd_panel_with_8-line_spi_interface_(st7789)", "[lcd]")
|
|
|
{
|
|
|
esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
|
|
- lcd_initialize_spi(&io_handle, NULL, NULL, 8, 8, true);
|
|
|
+ test_spi_lcd_common_initialize(&io_handle, NULL, NULL, 8, 8, true);
|
|
|
esp_lcd_panel_dev_config_t panel_config = {
|
|
|
.reset_gpio_num = TEST_LCD_RST_GPIO,
|
|
|
.color_space = ESP_LCD_COLOR_SPACE_RGB,
|
|
|
@@ -151,11 +159,11 @@ TEST_CASE("lcd panel with 8-line spi interface (st7789)", "[lcd]")
|
|
|
lcd_panel_test(io_handle, panel_handle);
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("lcd panel with 8-line spi interface (nt35510)", "[lcd]")
|
|
|
+TEST_CASE("lcd_panel_with_8-line_spi_interface_(nt35510)", "[lcd]")
|
|
|
{
|
|
|
esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
|
|
- lcd_initialize_spi(&io_handle, NULL, NULL, 16, 16, true);
|
|
|
+ test_spi_lcd_common_initialize(&io_handle, NULL, NULL, 16, 16, true);
|
|
|
esp_lcd_panel_dev_config_t panel_config = {
|
|
|
.reset_gpio_num = TEST_LCD_RST_GPIO,
|
|
|
.color_space = ESP_LCD_COLOR_SPACE_RGB,
|
|
|
@@ -166,11 +174,11 @@ TEST_CASE("lcd panel with 8-line spi interface (nt35510)", "[lcd]")
|
|
|
}
|
|
|
#endif // SOC_SPI_SUPPORT_OCT
|
|
|
|
|
|
-TEST_CASE("lcd panel with 1-line spi interface (st7789)", "[lcd]")
|
|
|
+TEST_CASE("lcd_panel_with_1-line_spi_interface_(st7789)", "[lcd]")
|
|
|
{
|
|
|
esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
|
|
- lcd_initialize_spi(&io_handle, NULL, NULL, 8, 8, false);
|
|
|
+ test_spi_lcd_common_initialize(&io_handle, NULL, NULL, 8, 8, false);
|
|
|
esp_lcd_panel_dev_config_t panel_config = {
|
|
|
.reset_gpio_num = TEST_LCD_RST_GPIO,
|
|
|
.color_space = ESP_LCD_COLOR_SPACE_RGB,
|
|
|
@@ -179,81 +187,3 @@ TEST_CASE("lcd panel with 1-line spi interface (st7789)", "[lcd]")
|
|
|
TEST_ESP_OK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
|
|
|
lcd_panel_test(io_handle, panel_handle);
|
|
|
}
|
|
|
-
|
|
|
-// The following test shows a porting example of LVGL GUI library
|
|
|
-// To run the LVGL tests, you need to clone the LVGL library into components directory firstly
|
|
|
-#if CONFIG_LV_USE_USER_DATA
|
|
|
-#include "test_lvgl_port.h"
|
|
|
-
|
|
|
-static bool notify_lvgl_ready_to_flush(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx)
|
|
|
-{
|
|
|
- lv_disp_t *disp = *(lv_disp_t **)user_ctx;
|
|
|
- lv_disp_flush_ready(&disp->driver);
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-static void lvgl_gui_test(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_handle_t panel_handle, lv_disp_t **disp)
|
|
|
-{
|
|
|
- // initialize LVGL graphics library
|
|
|
- lv_init();
|
|
|
- // turn off backlight
|
|
|
- gpio_set_level(TEST_LCD_BK_LIGHT_GPIO, 0);
|
|
|
- esp_lcd_panel_reset(panel_handle);
|
|
|
- esp_lcd_panel_init(panel_handle);
|
|
|
- esp_lcd_panel_invert_color(panel_handle, true);
|
|
|
- // the gap is LCD panel specific, even panels with the same driver IC, can have different gap value
|
|
|
- esp_lcd_panel_set_gap(panel_handle, 0, 20);
|
|
|
- // turn on backlight
|
|
|
- gpio_set_level(TEST_LCD_BK_LIGHT_GPIO, 1);
|
|
|
-
|
|
|
- test_lvgl_task_loop(panel_handle, TEST_LCD_H_RES, TEST_LCD_V_RES, disp);
|
|
|
-}
|
|
|
-
|
|
|
-#if SOC_SPI_SUPPORT_OCT
|
|
|
-TEST_CASE("lvgl gui with 8-line spi interface (st7789)", "[lcd][lvgl][ignore]")
|
|
|
-{
|
|
|
- lv_disp_t *disp = NULL;
|
|
|
- esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
|
- esp_lcd_panel_handle_t panel_handle = NULL;
|
|
|
- lcd_initialize_spi(&io_handle, notify_lvgl_ready_to_flush, &disp, 8, 8, true);
|
|
|
- esp_lcd_panel_dev_config_t panel_config = {
|
|
|
- .reset_gpio_num = TEST_LCD_RST_GPIO,
|
|
|
- .color_space = ESP_LCD_COLOR_SPACE_RGB,
|
|
|
- .bits_per_pixel = 16,
|
|
|
- };
|
|
|
- TEST_ESP_OK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
|
|
|
- lvgl_gui_test(io_handle, panel_handle, &disp);
|
|
|
-}
|
|
|
-
|
|
|
-TEST_CASE("lvgl gui with 8-line spi interface (nt35510)", "[lcd][lvgl][ignore]")
|
|
|
-{
|
|
|
- lv_disp_t *disp = NULL;
|
|
|
- esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
|
- esp_lcd_panel_handle_t panel_handle = NULL;
|
|
|
- lcd_initialize_spi(&io_handle, notify_lvgl_ready_to_flush, &disp, 16, 16, true);
|
|
|
- esp_lcd_panel_dev_config_t panel_config = {
|
|
|
- .reset_gpio_num = TEST_LCD_RST_GPIO,
|
|
|
- .color_space = ESP_LCD_COLOR_SPACE_RGB,
|
|
|
- .bits_per_pixel = 16,
|
|
|
- };
|
|
|
- TEST_ESP_OK(esp_lcd_new_panel_nt35510(io_handle, &panel_config, &panel_handle));
|
|
|
- lvgl_gui_test(io_handle, panel_handle, &disp);
|
|
|
-}
|
|
|
-#endif // SOC_SPI_SUPPORT_OCT
|
|
|
-
|
|
|
-TEST_CASE("lvgl gui with 1-line spi interface (st7789)", "[lcd][lvgl][ignore]")
|
|
|
-{
|
|
|
- lv_disp_t *disp = NULL;
|
|
|
- esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
|
- esp_lcd_panel_handle_t panel_handle = NULL;
|
|
|
- lcd_initialize_spi(&io_handle, notify_lvgl_ready_to_flush, &disp, 8, 8, false);
|
|
|
- esp_lcd_panel_dev_config_t panel_config = {
|
|
|
- .reset_gpio_num = TEST_LCD_RST_GPIO,
|
|
|
- .color_space = ESP_LCD_COLOR_SPACE_RGB,
|
|
|
- .bits_per_pixel = 16,
|
|
|
- };
|
|
|
- TEST_ESP_OK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
|
|
|
- lvgl_gui_test(io_handle, panel_handle, &disp);
|
|
|
-}
|
|
|
-
|
|
|
-#endif // CONFIG_LV_USE_USER_DATA
|