add some code
This commit is contained in:
@@ -0,0 +1 @@
|
||||
8637c97feeb8d83ba637599f6bf4ef30e83595486930e7df17ffa24f3fef1242
|
||||
35
managed_components/espressif__esp_lcd_spd2010/CHANGELOG.md
Normal file
35
managed_components/espressif__esp_lcd_spd2010/CHANGELOG.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# ChangeLog
|
||||
|
||||
## v1.0.2 - 2024-08-12
|
||||
|
||||
### Enhancements:
|
||||
|
||||
* Component version maintenance, code improvement, and documentation enhancement
|
||||
|
||||
## v0.0.1 - 2023-08-22
|
||||
|
||||
### Enhancements:
|
||||
|
||||
* Implement the driver for the SPD2010 LCD controller
|
||||
* Support SPI and QSPI interface
|
||||
|
||||
## v0.0.2 - 2023-10-07
|
||||
|
||||
### Enhancements:
|
||||
|
||||
* Support to use ESP-IDF release/v5.0
|
||||
|
||||
## v1.0.0 - 2023-11-03
|
||||
|
||||
### bugfix
|
||||
|
||||
* Fix the incompatible dependent version of ESP-IDF
|
||||
* Remove LCD command `29h` from the initialization sequence
|
||||
* Add parameter `max_trans_sz` in default bus configuration macro
|
||||
* Check conflicting commands between initialization sequence and driver
|
||||
|
||||
## v1.0.1 - 2023-12-04
|
||||
|
||||
### bugfix
|
||||
|
||||
* Remove unused header `hal/spi_ll.h`
|
||||
@@ -0,0 +1 @@
|
||||
{"version": "1.0", "algorithm": "sha256", "created_at": "2025-05-21T17:26:57.666737+00:00", "files": [{"path": "CMakeLists.txt", "size": 189, "hash": "93e6e5c11b2bfc1b9064139a5995e16de3250ae03fbf1ca9a8a70d442526c075"}, {"path": "CHANGELOG.md", "size": 712, "hash": "b94baef50986be84ccd58dfe9b1186d82ef53410c2d682e6095b0b1a9e13ee0a"}, {"path": "idf_component.yml", "size": 459, "hash": "e6396439769567cb93330f4f2c6900da69c02454a91d521174558b1d6a9783af"}, {"path": "README.md", "size": 6942, "hash": "75c8e6054438fbe64054f4bb9be16d99ee077fcfccd48861088c8f7dc897e9f4"}, {"path": "license.txt", "size": 11358, "hash": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30"}, {"path": "esp_lcd_spd2010.c", "size": 29274, "hash": "96abc66d799b4afc195e375ac3b75b957a24fc16c5e15948c0d1f0c77bdf9536"}, {"path": "include/esp_lcd_spd2010.h", "size": 4958, "hash": "7d1b304f4a06a9add4293c97eb8c6cc4e12a599699df4fc744c783566213097c"}, {"path": "test_apps/CMakeLists.txt", "size": 317, "hash": "e6b636b37962c5f92044e7beb6ad8ab959c83a7611187db6ce0006e98fb70175"}, {"path": "test_apps/sdkconfig.defaults", "size": 257, "hash": "b3f9660085595b907f7411e205468220c2dfb867de4de5d7fb3cbb406651dcab"}, {"path": "test_apps/pytest_esp_lcd_spd2010.py", "size": 300, "hash": "6513b1e4ab20df1aca721edef3485c23da4c0bc34920537ede6c1203ddd4f16a"}, {"path": "examples/qspi_with_ram/CMakeLists.txt", "size": 415, "hash": "3d5473b747a03a3e0e6112902044b4c63d2c46337ebfded64638211b4493c3a8"}, {"path": "examples/qspi_with_ram/sdkconfig.ci.sh8601", "size": 39, "hash": "807b4806a87951ffb21a21a96a9e59d10053d1533741658d6fff344b837b340b"}, {"path": "examples/qspi_with_ram/README.md", "size": 6685, "hash": "e1d96bb07f0d08b375e1478a568494fef869d5170aea434f3bb37be81f37b76b"}, {"path": "examples/qspi_with_ram/partitions.csv", "size": 271, "hash": "634023eff6a70f3f04e1c394d401ef8168162de0da7c163768394a4b69db0358"}, {"path": "examples/qspi_with_ram/sdkconfig.defaults.esp32s3", "size": 273, "hash": "c50c76c883c70f0c608fdf14430b54febf84163ee861af0d19c4e6a529408502"}, {"path": "examples/qspi_with_ram/sdkconfig.defaults", "size": 569, "hash": "b3e093bd95b627b95d3d477d4d2dc9e3dd8268840c3ba63cac5e5d77cc3b20a3"}, {"path": "examples/qspi_with_ram/sdkconfig.ci.gc9b71", "size": 74, "hash": "1846aeb5ce90d94e361d9310882e50a41e8a9fed27d4a55b6213c40ef58906fa"}, {"path": "examples/qspi_with_ram/sdkconfig.ci.defaults", "size": 35, "hash": "7c71aaa5a411e5dfe41955e925656b942f546e5ab7afa4fe4d0a628cf4474ecf"}, {"path": "examples/qspi_with_ram/main/CMakeLists.txt", "size": 81, "hash": "52027f86a48531b480bc67d9fe88b0e78a4566d3b0e6ddaf0cc432fb58b303d8"}, {"path": "examples/qspi_with_ram/main/idf_component.yml", "size": 596, "hash": "fb1251a344fe312b9971e3b60c485ba6ddf5837113a705af16d8f1104a12a639"}, {"path": "examples/qspi_with_ram/main/example_qspi_with_ram.c", "size": 19623, "hash": "0423049dbca356343aef53aa045516cc7a23ec894fbaa807d14c10588aef2b53"}, {"path": "examples/qspi_with_ram/main/Kconfig.projbuild", "size": 1238, "hash": "e3949ea458b641dac6b5406cb884d999444dd4371af4ac2aea9c97cf947b4937"}, {"path": "test_apps/main/test_esp_lcd_spd2010.c", "size": 8608, "hash": "b2ac75347a9ec5a43d77284fa15c65302c5db754b8566cef17e9f420eace7556"}, {"path": "test_apps/main/CMakeLists.txt", "size": 54, "hash": "c48ca046f5d1d5f56fbea23379ae463c2223ca8153844f4090f4c5fb6835032c"}, {"path": "test_apps/main/idf_component.yml", "size": 159, "hash": "60bb700f9ce3f6e21c1a6dbdffe31c3d024ddae17babf8ec1fad7b37fa9ee554"}]}
|
||||
@@ -0,0 +1,4 @@
|
||||
idf_component_register(SRCS "esp_lcd_spd2010.c" INCLUDE_DIRS "include" PRIV_REQUIRES "driver" REQUIRES "esp_lcd")
|
||||
|
||||
include(package_manager)
|
||||
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})
|
||||
140
managed_components/espressif__esp_lcd_spd2010/README.md
Normal file
140
managed_components/espressif__esp_lcd_spd2010/README.md
Normal file
@@ -0,0 +1,140 @@
|
||||
# ESP LCD SPD2010
|
||||
|
||||
[](https://components.espressif.com/components/espressif/esp_lcd_spd2010)
|
||||
|
||||
Implementation of the SPD2010 LCD controller with [esp_lcd](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/lcd.html) component.
|
||||
|
||||
| LCD controller | Communication interface | Component name | Link to datasheet |
|
||||
| :------------: | :---------------------: | :-------------: | :-----------------------------------------------------------------------------: |
|
||||
| SPD2010 | SPI/QSPI | esp_lcd_spd2010 | [PDF](https://dl.espressif.com/AE/esp-iot-solution/SPD2010_L-WEA2010_0.50.pdf) |
|
||||
|
||||
## Add to project
|
||||
|
||||
Packages from this repository are uploaded to [Espressif's component service](https://components.espressif.com/).
|
||||
You can add them to your project via `idf.py add-dependancy`, e.g.
|
||||
```
|
||||
idf.py add-dependency "espressif/esp_lcd_spd2010"
|
||||
```
|
||||
|
||||
Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
|
||||
|
||||
For more information on LCD, please refer to the [LCD documentation](https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html).
|
||||
|
||||
## Initialization Code
|
||||
|
||||
### SPI Interface
|
||||
|
||||
```c
|
||||
ESP_LOGI(TAG, "Initialize SPI bus");
|
||||
const spi_bus_config_t bus_config = SPD2010_PANEL_BUS_SPI_CONFIG(EXAMPLE_PIN_NUM_LCD_PCLK,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA0,
|
||||
EXAMPLE_LCD_H_RES * 80 * sizeof(uint16_t));
|
||||
ESP_ERROR_CHECK(spi_bus_initialize(EXAMPLE_LCD_HOST, &bus_config, SPI_DMA_CH_AUTO));
|
||||
|
||||
ESP_LOGI(TAG, "Install panel IO");
|
||||
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||
const esp_lcd_panel_io_spi_config_t io_config = SPD2010_PANEL_IO_SPI_CONFIG(EXAMPLE_PIN_NUM_LCD_CS, EXAMPLE_PIN_NUM_LCD_DC,
|
||||
callback, &callback_data);
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)EXAMPLE_LCD_HOST, &io_config, &io_handle));
|
||||
|
||||
/**
|
||||
* Uncomment these line if use custom initialization commands.
|
||||
* The array should be declared as static const and positioned outside the function.
|
||||
*/
|
||||
// static const spd2010_lcd_init_cmd_t lcd_init_cmds[] = {
|
||||
// // {cmd, { data }, data_size, delay_ms}
|
||||
// {0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
// {0x0C, (uint8_t []){0x11}, 1, 0},
|
||||
// {0x10, (uint8_t []){0x02}, 1, 0},
|
||||
// {0x11, (uint8_t []){0x11}, 1, 0},
|
||||
// ...
|
||||
// };
|
||||
|
||||
ESP_LOGI(TAG, "Install SPD2010 panel driver");
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
const spd2010_vendor_config_t vendor_config = {
|
||||
// .init_cmds = lcd_init_cmds, // Uncomment these line if use custom initialization commands
|
||||
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(spd2010_lcd_init_cmd_t),
|
||||
.flags = {
|
||||
.use_qspi_interface = 0,
|
||||
},
|
||||
};
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
|
||||
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, // Implemented by LCD command `36h`
|
||||
.bits_per_pixel = 16, // Implemented by LCD command `3Ah` (16/18/24)
|
||||
.vendor_config = &vendor_config,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_spd2010(io_handle, &panel_config, &panel_handle));
|
||||
esp_lcd_panel_reset(panel_handle);
|
||||
esp_lcd_panel_init(panel_handle);
|
||||
```
|
||||
|
||||
### QSPI Interface
|
||||
|
||||
```c
|
||||
ESP_LOGI(TAG, "Initialize QSPI bus");
|
||||
const esp_lcd_panel_io_spi_config_t io_config = SPD2010_PANEL_BUS_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_PCLK,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA0,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA1,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA2,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA3,
|
||||
EXAMPLE_LCD_H_RES * 80 * sizeof(uint16_t));
|
||||
ESP_ERROR_CHECK(spi_bus_initialize(EXAMPLE_LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));
|
||||
|
||||
ESP_LOGI(TAG, "Install panel IO");
|
||||
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||
const esp_lcd_panel_io_spi_config_t io_config = SPD2010_PANEL_IO_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_CS, callback, &callback_data);
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)EXAMPLE_LCD_HOST, &io_config, &io_handle));
|
||||
|
||||
/**
|
||||
* Uncomment these line if use custom initialization commands.
|
||||
* The array should be declared as static const and positioned outside the function.
|
||||
*/
|
||||
// static const spd2010_lcd_init_cmd_t lcd_init_cmds[] = {
|
||||
// // {cmd, { data }, data_size, delay_ms}
|
||||
// {0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
// {0x0C, (uint8_t []){0x11}, 1, 0},
|
||||
// {0x10, (uint8_t []){0x02}, 1, 0},
|
||||
// {0x11, (uint8_t []){0x11}, 1, 0},
|
||||
// ...
|
||||
// };
|
||||
|
||||
ESP_LOGI(TAG, "Install SPD2010 panel driver");
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
spd2010_vendor_config_t vendor_config = {
|
||||
// .init_cmds = lcd_init_cmds, // Uncomment these line if use custom initialization commands
|
||||
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(spd2010_lcd_init_cmd_t),
|
||||
.flags = {
|
||||
.use_qspi_interface = 1,
|
||||
},
|
||||
};
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
|
||||
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, // Implemented by LCD command `36h`
|
||||
.bits_per_pixel = 16, // Implemented by LCD command `3Ah` (16/18/24)
|
||||
.vendor_config = &vendor_config,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_spd2010(io_handle, &panel_config, &panel_handle));
|
||||
esp_lcd_panel_reset(panel_handle);
|
||||
esp_lcd_panel_init(panel_handle);
|
||||
esp_lcd_panel_disp_on_off(panel_handle, true);
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
* When using `esp_panel_lcd_draw_bitmap()` to refresh the screen, ensure that both `x_start` and `x_end` are divisible by `4`. This is a requirement of SPD2010. For LVGL, register the following function into `rounder_cb` of `lv_disp_drv_t` to round the coordinates.
|
||||
|
||||
```c
|
||||
void lvgl_port_rounder_callback(struct _lv_disp_drv_t * disp_drv, lv_area_t * area)
|
||||
{
|
||||
uint16_t x1 = area->x1;
|
||||
uint16_t x2 = area->x2;
|
||||
|
||||
// round the start of coordinate down to the nearest 4M number
|
||||
area->x1 = (x1 >> 2) << 2;
|
||||
|
||||
// round the end of coordinate up to the nearest 4N+3 number
|
||||
area->x2 = ((x2 >> 2) << 2) + 3;
|
||||
}
|
||||
```
|
||||
764
managed_components/espressif__esp_lcd_spd2010/esp_lcd_spd2010.c
Normal file
764
managed_components/espressif__esp_lcd_spd2010/esp_lcd_spd2010.c
Normal file
@@ -0,0 +1,764 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_lcd_panel_interface.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_lcd_panel_commands.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "esp_lcd_spd2010.h"
|
||||
|
||||
#define LCD_OPCODE_WRITE_CMD (0x02ULL)
|
||||
#define LCD_OPCODE_READ_CMD (0x0BULL)
|
||||
#define LCD_OPCODE_WRITE_COLOR (0x32ULL)
|
||||
|
||||
#define SPD2010_CMD_SET (0xFF)
|
||||
#define SPD2010_CMD_SET_BYTE0 (0x20)
|
||||
#define SPD2010_CMD_SET_BYTE1 (0x10)
|
||||
#define SPD2010_CMD_SET_USER (0x00)
|
||||
|
||||
static const char *TAG = "spd2010";
|
||||
|
||||
static esp_err_t panel_spd2010_del(esp_lcd_panel_t *panel);
|
||||
static esp_err_t panel_spd2010_reset(esp_lcd_panel_t *panel);
|
||||
static esp_err_t panel_spd2010_init(esp_lcd_panel_t *panel);
|
||||
static esp_err_t panel_spd2010_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data);
|
||||
static esp_err_t panel_spd2010_invert_color(esp_lcd_panel_t *panel, bool invert_color_data);
|
||||
static esp_err_t panel_spd2010_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y);
|
||||
static esp_err_t panel_spd2010_swap_xy(esp_lcd_panel_t *panel, bool swap_axes);
|
||||
static esp_err_t panel_spd2010_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap);
|
||||
static esp_err_t panel_spd2010_disp_on_off(esp_lcd_panel_t *panel, bool off);
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_t base;
|
||||
esp_lcd_panel_io_handle_t io;
|
||||
int reset_gpio_num;
|
||||
int x_gap;
|
||||
int y_gap;
|
||||
uint8_t fb_bits_per_pixel;
|
||||
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
|
||||
uint8_t colmod_val; // save current value of LCD_CMD_COLMOD register
|
||||
const spd2010_lcd_init_cmd_t *init_cmds;
|
||||
uint16_t init_cmds_size;
|
||||
struct {
|
||||
unsigned int use_qspi_interface: 1;
|
||||
unsigned int reset_level: 1;
|
||||
} flags;
|
||||
} spd2010_panel_t;
|
||||
|
||||
esp_err_t esp_lcd_new_panel_spd2010(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
|
||||
esp_err_t ret = ESP_OK;
|
||||
spd2010_panel_t *spd2010 = NULL;
|
||||
spd2010 = calloc(1, sizeof(spd2010_panel_t));
|
||||
ESP_GOTO_ON_FALSE(spd2010, ESP_ERR_NO_MEM, err, TAG, "no mem for spd2010 panel");
|
||||
|
||||
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||
gpio_config_t io_conf = {
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pin_bit_mask = 1ULL << panel_dev_config->reset_gpio_num,
|
||||
};
|
||||
ESP_GOTO_ON_ERROR(gpio_config(&io_conf), err, TAG, "configure GPIO for RST line failed");
|
||||
}
|
||||
|
||||
switch (panel_dev_config->rgb_ele_order) {
|
||||
case LCD_RGB_ELEMENT_ORDER_RGB:
|
||||
spd2010->madctl_val = 0;
|
||||
break;
|
||||
case LCD_RGB_ELEMENT_ORDER_BGR:
|
||||
spd2010->madctl_val |= LCD_CMD_BGR_BIT;
|
||||
break;
|
||||
default:
|
||||
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color element order");
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t fb_bits_per_pixel = 0;
|
||||
switch (panel_dev_config->bits_per_pixel) {
|
||||
case 16: // RGB565
|
||||
spd2010->colmod_val = 0x55;
|
||||
fb_bits_per_pixel = 16;
|
||||
break;
|
||||
case 18: // RGB666
|
||||
spd2010->colmod_val = 0x66;
|
||||
// each color component (R/G/B) should occupy the 6 high bits of a byte, which means 3 full bytes are required for a pixel
|
||||
fb_bits_per_pixel = 24;
|
||||
break;
|
||||
case 24: // RGB888
|
||||
spd2010->colmod_val = 0x77;
|
||||
fb_bits_per_pixel = 24;
|
||||
break;
|
||||
default:
|
||||
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width");
|
||||
break;
|
||||
}
|
||||
|
||||
spd2010->io = io;
|
||||
spd2010->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
||||
spd2010->fb_bits_per_pixel = fb_bits_per_pixel;
|
||||
spd2010_vendor_config_t *vendor_config = (spd2010_vendor_config_t *)panel_dev_config->vendor_config;
|
||||
if (vendor_config) {
|
||||
spd2010->init_cmds = vendor_config->init_cmds;
|
||||
spd2010->init_cmds_size = vendor_config->init_cmds_size;
|
||||
spd2010->flags.use_qspi_interface = vendor_config->flags.use_qspi_interface;
|
||||
}
|
||||
spd2010->flags.reset_level = panel_dev_config->flags.reset_active_high;
|
||||
spd2010->base.del = panel_spd2010_del;
|
||||
spd2010->base.reset = panel_spd2010_reset;
|
||||
spd2010->base.init = panel_spd2010_init;
|
||||
spd2010->base.draw_bitmap = panel_spd2010_draw_bitmap;
|
||||
spd2010->base.invert_color = panel_spd2010_invert_color;
|
||||
spd2010->base.set_gap = panel_spd2010_set_gap;
|
||||
spd2010->base.mirror = panel_spd2010_mirror;
|
||||
spd2010->base.swap_xy = panel_spd2010_swap_xy;
|
||||
spd2010->base.disp_on_off = panel_spd2010_disp_on_off;
|
||||
*ret_panel = &(spd2010->base);
|
||||
ESP_LOGD(TAG, "new spd2010 panel @%p", spd2010);
|
||||
|
||||
ESP_LOGI(TAG, "LCD panel create success, version: %d.%d.%d", ESP_LCD_SPD2010_VER_MAJOR, ESP_LCD_SPD2010_VER_MINOR,
|
||||
ESP_LCD_SPD2010_VER_PATCH);
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
err:
|
||||
if (spd2010) {
|
||||
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||
gpio_reset_pin(panel_dev_config->reset_gpio_num);
|
||||
}
|
||||
free(spd2010);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t tx_param(spd2010_panel_t *spd2010, esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *param, size_t param_size)
|
||||
{
|
||||
if (spd2010->flags.use_qspi_interface) {
|
||||
lcd_cmd &= 0xff;
|
||||
lcd_cmd <<= 8;
|
||||
lcd_cmd |= LCD_OPCODE_WRITE_CMD << 24;
|
||||
}
|
||||
return esp_lcd_panel_io_tx_param(io, lcd_cmd, param, param_size);
|
||||
}
|
||||
|
||||
static esp_err_t tx_color(spd2010_panel_t *spd2010, esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *param, size_t param_size)
|
||||
{
|
||||
if (spd2010->flags.use_qspi_interface) {
|
||||
lcd_cmd &= 0xff;
|
||||
lcd_cmd <<= 8;
|
||||
lcd_cmd |= LCD_OPCODE_WRITE_COLOR << 24;
|
||||
}
|
||||
return esp_lcd_panel_io_tx_color(io, lcd_cmd, param, param_size);
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_del(esp_lcd_panel_t *panel)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
|
||||
if (spd2010->reset_gpio_num >= 0) {
|
||||
gpio_reset_pin(spd2010->reset_gpio_num);
|
||||
}
|
||||
ESP_LOGD(TAG, "del spd2010 panel @%p", spd2010);
|
||||
free(spd2010);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_reset(esp_lcd_panel_t *panel)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = spd2010->io;
|
||||
|
||||
// Perform hardware reset
|
||||
if (spd2010->reset_gpio_num >= 0) {
|
||||
gpio_set_level(spd2010->reset_gpio_num, spd2010->flags.reset_level);
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
gpio_set_level(spd2010->reset_gpio_num, !spd2010->flags.reset_level);
|
||||
vTaskDelay(pdMS_TO_TICKS(120));
|
||||
} else { // Perform software reset
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, LCD_CMD_SWRESET, NULL, 0), TAG, "send command failed");
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static const spd2010_lcd_init_cmd_t vendor_specific_init_default[] = {
|
||||
// {cmd, { data }, data_size, delay_ms}
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
{0x0C, (uint8_t []){0x11}, 1, 0},
|
||||
{0x10, (uint8_t []){0x02}, 1, 0},
|
||||
{0x11, (uint8_t []){0x11}, 1, 0},
|
||||
{0x15, (uint8_t []){0x42}, 1, 0},
|
||||
{0x16, (uint8_t []){0x11}, 1, 0},
|
||||
{0x1A, (uint8_t []){0x02}, 1, 0},
|
||||
{0x1B, (uint8_t []){0x11}, 1, 0},
|
||||
{0x61, (uint8_t []){0x80}, 1, 0},
|
||||
{0x62, (uint8_t []){0x80}, 1, 0},
|
||||
{0x54, (uint8_t []){0x44}, 1, 0},
|
||||
{0x58, (uint8_t []){0x88}, 1, 0},
|
||||
{0x5C, (uint8_t []){0xcc}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
{0x20, (uint8_t []){0x80}, 1, 0},
|
||||
{0x21, (uint8_t []){0x81}, 1, 0},
|
||||
{0x22, (uint8_t []){0x31}, 1, 0},
|
||||
{0x23, (uint8_t []){0x20}, 1, 0},
|
||||
{0x24, (uint8_t []){0x11}, 1, 0},
|
||||
{0x25, (uint8_t []){0x11}, 1, 0},
|
||||
{0x26, (uint8_t []){0x12}, 1, 0},
|
||||
{0x27, (uint8_t []){0x12}, 1, 0},
|
||||
{0x30, (uint8_t []){0x80}, 1, 0},
|
||||
{0x31, (uint8_t []){0x81}, 1, 0},
|
||||
{0x32, (uint8_t []){0x31}, 1, 0},
|
||||
{0x33, (uint8_t []){0x20}, 1, 0},
|
||||
{0x34, (uint8_t []){0x11}, 1, 0},
|
||||
{0x35, (uint8_t []){0x11}, 1, 0},
|
||||
{0x36, (uint8_t []){0x12}, 1, 0},
|
||||
{0x37, (uint8_t []){0x12}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
{0x41, (uint8_t []){0x11}, 1, 0},
|
||||
{0x42, (uint8_t []){0x22}, 1, 0},
|
||||
{0x43, (uint8_t []){0x33}, 1, 0},
|
||||
{0x49, (uint8_t []){0x11}, 1, 0},
|
||||
{0x4A, (uint8_t []){0x22}, 1, 0},
|
||||
{0x4B, (uint8_t []){0x33}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x15}, 3, 0},
|
||||
{0x00, (uint8_t []){0x00}, 1, 0},
|
||||
{0x01, (uint8_t []){0x00}, 1, 0},
|
||||
{0x02, (uint8_t []){0x00}, 1, 0},
|
||||
{0x03, (uint8_t []){0x00}, 1, 0},
|
||||
{0x04, (uint8_t []){0x10}, 1, 0},
|
||||
{0x05, (uint8_t []){0x0C}, 1, 0},
|
||||
{0x06, (uint8_t []){0x23}, 1, 0},
|
||||
{0x07, (uint8_t []){0x22}, 1, 0},
|
||||
{0x08, (uint8_t []){0x21}, 1, 0},
|
||||
{0x09, (uint8_t []){0x20}, 1, 0},
|
||||
{0x0A, (uint8_t []){0x33}, 1, 0},
|
||||
{0x0B, (uint8_t []){0x32}, 1, 0},
|
||||
{0x0C, (uint8_t []){0x34}, 1, 0},
|
||||
{0x0D, (uint8_t []){0x35}, 1, 0},
|
||||
{0x0E, (uint8_t []){0x01}, 1, 0},
|
||||
{0x0F, (uint8_t []){0x01}, 1, 0},
|
||||
{0x20, (uint8_t []){0x00}, 1, 0},
|
||||
{0x21, (uint8_t []){0x00}, 1, 0},
|
||||
{0x22, (uint8_t []){0x00}, 1, 0},
|
||||
{0x23, (uint8_t []){0x00}, 1, 0},
|
||||
{0x24, (uint8_t []){0x0C}, 1, 0},
|
||||
{0x25, (uint8_t []){0x10}, 1, 0},
|
||||
{0x26, (uint8_t []){0x20}, 1, 0},
|
||||
{0x27, (uint8_t []){0x21}, 1, 0},
|
||||
{0x28, (uint8_t []){0x22}, 1, 0},
|
||||
{0x29, (uint8_t []){0x23}, 1, 0},
|
||||
{0x2A, (uint8_t []){0x33}, 1, 0},
|
||||
{0x2B, (uint8_t []){0x32}, 1, 0},
|
||||
{0x2C, (uint8_t []){0x34}, 1, 0},
|
||||
{0x2D, (uint8_t []){0x35}, 1, 0},
|
||||
{0x2E, (uint8_t []){0x01}, 1, 0},
|
||||
{0x2F, (uint8_t []){0x01}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x16}, 3, 0},
|
||||
{0x00, (uint8_t []){0x00}, 1, 0},
|
||||
{0x01, (uint8_t []){0x00}, 1, 0},
|
||||
{0x02, (uint8_t []){0x00}, 1, 0},
|
||||
{0x03, (uint8_t []){0x00}, 1, 0},
|
||||
{0x04, (uint8_t []){0x08}, 1, 0},
|
||||
{0x05, (uint8_t []){0x04}, 1, 0},
|
||||
{0x06, (uint8_t []){0x19}, 1, 0},
|
||||
{0x07, (uint8_t []){0x18}, 1, 0},
|
||||
{0x08, (uint8_t []){0x17}, 1, 0},
|
||||
{0x09, (uint8_t []){0x16}, 1, 0},
|
||||
{0x0A, (uint8_t []){0x33}, 1, 0},
|
||||
{0x0B, (uint8_t []){0x32}, 1, 0},
|
||||
{0x0C, (uint8_t []){0x34}, 1, 0},
|
||||
{0x0D, (uint8_t []){0x35}, 1, 0},
|
||||
{0x0E, (uint8_t []){0x01}, 1, 0},
|
||||
{0x0F, (uint8_t []){0x01}, 1, 0},
|
||||
{0x20, (uint8_t []){0x00}, 1, 0},
|
||||
{0x21, (uint8_t []){0x00}, 1, 0},
|
||||
{0x22, (uint8_t []){0x00}, 1, 0},
|
||||
{0x23, (uint8_t []){0x00}, 1, 0},
|
||||
{0x24, (uint8_t []){0x04}, 1, 0},
|
||||
{0x25, (uint8_t []){0x08}, 1, 0},
|
||||
{0x26, (uint8_t []){0x16}, 1, 0},
|
||||
{0x27, (uint8_t []){0x17}, 1, 0},
|
||||
{0x28, (uint8_t []){0x18}, 1, 0},
|
||||
{0x29, (uint8_t []){0x19}, 1, 0},
|
||||
{0x2A, (uint8_t []){0x33}, 1, 0},
|
||||
{0x2B, (uint8_t []){0x32}, 1, 0},
|
||||
{0x2C, (uint8_t []){0x34}, 1, 0},
|
||||
{0x2D, (uint8_t []){0x35}, 1, 0},
|
||||
{0x2E, (uint8_t []){0x01}, 1, 0},
|
||||
{0x2F, (uint8_t []){0x01}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x00, (uint8_t []){0x99}, 1, 0},
|
||||
{0x2A, (uint8_t []){0x28}, 1, 0},
|
||||
{0x2B, (uint8_t []){0x0f}, 1, 0},
|
||||
{0x2C, (uint8_t []){0x16}, 1, 0},
|
||||
{0x2D, (uint8_t []){0x28}, 1, 0},
|
||||
{0x2E, (uint8_t []){0x0f}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0xA0}, 3, 0},
|
||||
{0x08, (uint8_t []){0xdc}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x45}, 3, 0},
|
||||
{0x01, (uint8_t []){0x9C}, 1, 0},
|
||||
{0x03, (uint8_t []){0x9C}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x42}, 3, 0},
|
||||
{0x05, (uint8_t []){0x2c}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x11}, 3, 0},
|
||||
{0x50, (uint8_t []){0x01}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0x2A, (uint8_t []){0x00, 0x00, 0x01, 0x9B}, 4, 0},
|
||||
{0x2B, (uint8_t []){0x00, 0x00, 0x01, 0x9B}, 4, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x40}, 3, 0},
|
||||
{0x86, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x0D, (uint8_t []){0x66}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x17}, 3, 0},
|
||||
{0x39, (uint8_t []){0x3c}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x31}, 3, 0},
|
||||
{0x38, (uint8_t []){0x03}, 1, 0},
|
||||
{0x39, (uint8_t []){0xf0}, 1, 0},
|
||||
{0x36, (uint8_t []){0x03}, 1, 0},
|
||||
{0x37, (uint8_t []){0xe8}, 1, 0},
|
||||
{0x34, (uint8_t []){0x03}, 1, 0},
|
||||
{0x35, (uint8_t []){0xCF}, 1, 0},
|
||||
{0x32, (uint8_t []){0x03}, 1, 0},
|
||||
{0x33, (uint8_t []){0xBA}, 1, 0},
|
||||
{0x30, (uint8_t []){0x03}, 1, 0},
|
||||
{0x31, (uint8_t []){0xA2}, 1, 0},
|
||||
{0x2e, (uint8_t []){0x03}, 1, 0},
|
||||
{0x2f, (uint8_t []){0x95}, 1, 0},
|
||||
{0x2c, (uint8_t []){0x03}, 1, 0},
|
||||
{0x2d, (uint8_t []){0x7e}, 1, 0},
|
||||
{0x2a, (uint8_t []){0x03}, 1, 0},
|
||||
{0x2b, (uint8_t []){0x62}, 1, 0},
|
||||
{0x28, (uint8_t []){0x03}, 1, 0},
|
||||
{0x29, (uint8_t []){0x44}, 1, 0},
|
||||
{0x26, (uint8_t []){0x02}, 1, 0},
|
||||
{0x27, (uint8_t []){0xfc}, 1, 0},
|
||||
{0x24, (uint8_t []){0x02}, 1, 0},
|
||||
{0x25, (uint8_t []){0xd0}, 1, 0},
|
||||
{0x22, (uint8_t []){0x02}, 1, 0},
|
||||
{0x23, (uint8_t []){0x98}, 1, 0},
|
||||
{0x20, (uint8_t []){0x02}, 1, 0},
|
||||
{0x21, (uint8_t []){0x6f}, 1, 0},
|
||||
{0x1e, (uint8_t []){0x02}, 1, 0},
|
||||
{0x1f, (uint8_t []){0x32}, 1, 0},
|
||||
{0x1c, (uint8_t []){0x01}, 1, 0},
|
||||
{0x1d, (uint8_t []){0xf6}, 1, 0},
|
||||
{0x1a, (uint8_t []){0x01}, 1, 0},
|
||||
{0x1b, (uint8_t []){0xb8}, 1, 0},
|
||||
{0x18, (uint8_t []){0x01}, 1, 0},
|
||||
{0x19, (uint8_t []){0x6E}, 1, 0},
|
||||
{0x16, (uint8_t []){0x01}, 1, 0},
|
||||
{0x17, (uint8_t []){0x41}, 1, 0},
|
||||
{0x14, (uint8_t []){0x00}, 1, 0},
|
||||
{0x15, (uint8_t []){0xfd}, 1, 0},
|
||||
{0x12, (uint8_t []){0x00}, 1, 0},
|
||||
{0x13, (uint8_t []){0xCf}, 1, 0},
|
||||
{0x10, (uint8_t []){0x00}, 1, 0},
|
||||
{0x11, (uint8_t []){0x98}, 1, 0},
|
||||
{0x0e, (uint8_t []){0x00}, 1, 0},
|
||||
{0x0f, (uint8_t []){0x89}, 1, 0},
|
||||
{0x0c, (uint8_t []){0x00}, 1, 0},
|
||||
{0x0d, (uint8_t []){0x79}, 1, 0},
|
||||
{0x0a, (uint8_t []){0x00}, 1, 0},
|
||||
{0x0b, (uint8_t []){0x67}, 1, 0},
|
||||
{0x08, (uint8_t []){0x00}, 1, 0},
|
||||
{0x09, (uint8_t []){0x55}, 1, 0},
|
||||
{0x06, (uint8_t []){0x00}, 1, 0},
|
||||
{0x07, (uint8_t []){0x3F}, 1, 0},
|
||||
{0x04, (uint8_t []){0x00}, 1, 0},
|
||||
{0x05, (uint8_t []){0x28}, 1, 0},
|
||||
{0x02, (uint8_t []){0x00}, 1, 0},
|
||||
{0x03, (uint8_t []){0x0E}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x32}, 3, 0},
|
||||
{0x38, (uint8_t []){0x03}, 1, 0},
|
||||
{0x39, (uint8_t []){0xf0}, 1, 0},
|
||||
{0x36, (uint8_t []){0x03}, 1, 0},
|
||||
{0x37, (uint8_t []){0xe8}, 1, 0},
|
||||
{0x34, (uint8_t []){0x03}, 1, 0},
|
||||
{0x35, (uint8_t []){0xCF}, 1, 0},
|
||||
{0x32, (uint8_t []){0x03}, 1, 0},
|
||||
{0x33, (uint8_t []){0xBA}, 1, 0},
|
||||
{0x30, (uint8_t []){0x03}, 1, 0},
|
||||
{0x31, (uint8_t []){0xA2}, 1, 0},
|
||||
{0x2e, (uint8_t []){0x03}, 1, 0},
|
||||
{0x2f, (uint8_t []){0x95}, 1, 0},
|
||||
{0x2c, (uint8_t []){0x03}, 1, 0},
|
||||
{0x2d, (uint8_t []){0x7e}, 1, 0},
|
||||
{0x2a, (uint8_t []){0x03}, 1, 0},
|
||||
{0x2b, (uint8_t []){0x62}, 1, 0},
|
||||
{0x28, (uint8_t []){0x03}, 1, 0},
|
||||
{0x29, (uint8_t []){0x44}, 1, 0},
|
||||
{0x26, (uint8_t []){0x02}, 1, 0},
|
||||
{0x27, (uint8_t []){0xfc}, 1, 0},
|
||||
{0x24, (uint8_t []){0x02}, 1, 0},
|
||||
{0x25, (uint8_t []){0xd0}, 1, 0},
|
||||
{0x22, (uint8_t []){0x02}, 1, 0},
|
||||
{0x23, (uint8_t []){0x98}, 1, 0},
|
||||
{0x20, (uint8_t []){0x02}, 1, 0},
|
||||
{0x21, (uint8_t []){0x6f}, 1, 0},
|
||||
{0x1e, (uint8_t []){0x02}, 1, 0},
|
||||
{0x1f, (uint8_t []){0x32}, 1, 0},
|
||||
{0x1c, (uint8_t []){0x01}, 1, 0},
|
||||
{0x1d, (uint8_t []){0xf6}, 1, 0},
|
||||
{0x1a, (uint8_t []){0x01}, 1, 0},
|
||||
{0x1b, (uint8_t []){0xb8}, 1, 0},
|
||||
{0x18, (uint8_t []){0x01}, 1, 0},
|
||||
{0x19, (uint8_t []){0x6E}, 1, 0},
|
||||
{0x16, (uint8_t []){0x01}, 1, 0},
|
||||
{0x17, (uint8_t []){0x41}, 1, 0},
|
||||
{0x14, (uint8_t []){0x00}, 1, 0},
|
||||
{0x15, (uint8_t []){0xfd}, 1, 0},
|
||||
{0x12, (uint8_t []){0x00}, 1, 0},
|
||||
{0x13, (uint8_t []){0xCf}, 1, 0},
|
||||
{0x10, (uint8_t []){0x00}, 1, 0},
|
||||
{0x11, (uint8_t []){0x98}, 1, 0},
|
||||
{0x0e, (uint8_t []){0x00}, 1, 0},
|
||||
{0x0f, (uint8_t []){0x89}, 1, 0},
|
||||
{0x0c, (uint8_t []){0x00}, 1, 0},
|
||||
{0x0d, (uint8_t []){0x79}, 1, 0},
|
||||
{0x0a, (uint8_t []){0x00}, 1, 0},
|
||||
{0x0b, (uint8_t []){0x67}, 1, 0},
|
||||
{0x08, (uint8_t []){0x00}, 1, 0},
|
||||
{0x09, (uint8_t []){0x55}, 1, 0},
|
||||
{0x06, (uint8_t []){0x00}, 1, 0},
|
||||
{0x07, (uint8_t []){0x3F}, 1, 0},
|
||||
{0x04, (uint8_t []){0x00}, 1, 0},
|
||||
{0x05, (uint8_t []){0x28}, 1, 0},
|
||||
{0x02, (uint8_t []){0x00}, 1, 0},
|
||||
{0x03, (uint8_t []){0x0E}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x11}, 3, 0},
|
||||
{0x60, (uint8_t []){0x01}, 1, 0},
|
||||
{0x65, (uint8_t []){0x03}, 1, 0},
|
||||
{0x66, (uint8_t []){0x38}, 1, 0},
|
||||
{0x67, (uint8_t []){0x04}, 1, 0},
|
||||
{0x68, (uint8_t []){0x34}, 1, 0},
|
||||
{0x69, (uint8_t []){0x03}, 1, 0},
|
||||
{0x61, (uint8_t []){0x03}, 1, 0},
|
||||
{0x62, (uint8_t []){0x38}, 1, 0},
|
||||
{0x63, (uint8_t []){0x04}, 1, 0},
|
||||
{0x64, (uint8_t []){0x34}, 1, 0},
|
||||
{0x0A, (uint8_t []){0x11}, 1, 0},
|
||||
{0x0B, (uint8_t []){0x20}, 1, 0},
|
||||
{0x0c, (uint8_t []){0x20}, 1, 0},
|
||||
{0x55, (uint8_t []){0x06}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x42}, 3, 0},
|
||||
{0x05, (uint8_t []){0x3D}, 1, 0},
|
||||
{0x06, (uint8_t []){0x03}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x1F, (uint8_t []){0xDC}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x17}, 3, 0},
|
||||
{0x11, (uint8_t []){0xAA}, 1, 0},
|
||||
{0x16, (uint8_t []){0x12}, 1, 0},
|
||||
{0x0B, (uint8_t []){0xC3}, 1, 0},
|
||||
{0x10, (uint8_t []){0x0E}, 1, 0},
|
||||
{0x14, (uint8_t []){0xAA}, 1, 0},
|
||||
{0x18, (uint8_t []){0xA0}, 1, 0},
|
||||
{0x1A, (uint8_t []){0x80}, 1, 0},
|
||||
{0x1F, (uint8_t []){0x80}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x11}, 3, 0},
|
||||
{0x30, (uint8_t []){0xEE}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x15, (uint8_t []){0x0F}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x2D}, 3, 0},
|
||||
{0x01, (uint8_t []){0x3E}, 1, 0},
|
||||
{0xff, (uint8_t []){0x20, 0x10, 0x40}, 3, 0},
|
||||
{0x83, (uint8_t []){0xC4}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x00, (uint8_t []){0xCC}, 1, 0},
|
||||
{0x36, (uint8_t []){0xA0}, 1, 0},
|
||||
{0x2A, (uint8_t []){0x2D}, 1, 0},
|
||||
{0x2B, (uint8_t []){0x1e}, 1, 0},
|
||||
{0x2C, (uint8_t []){0x26}, 1, 0},
|
||||
{0x2D, (uint8_t []){0x2D}, 1, 0},
|
||||
{0x2E, (uint8_t []){0x1e}, 1, 0},
|
||||
{0x1F, (uint8_t []){0xE6}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0xA0}, 3, 0},
|
||||
{0x08, (uint8_t []){0xE6}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x10, (uint8_t []){0x0F}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x18}, 3, 0},
|
||||
{0x01, (uint8_t []){0x01}, 1, 0},
|
||||
{0x00, (uint8_t []){0x1E}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x43}, 3, 0},
|
||||
{0x03, (uint8_t []){0x04}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x18}, 3, 0},
|
||||
{0x3A, (uint8_t []){0x01}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x50}, 3, 0},
|
||||
{0x05, (uint8_t []){0x08}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x50}, 3, 0},
|
||||
{0x00, (uint8_t []){0xA6}, 1, 0},
|
||||
{0x01, (uint8_t []){0xA6}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x50}, 3, 0},
|
||||
{0x08, (uint8_t []){0x55}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
{0x0B, (uint8_t []){0x43}, 1, 0},
|
||||
{0x0C, (uint8_t []){0x12}, 1, 0},
|
||||
{0x10, (uint8_t []){0x01}, 1, 0},
|
||||
{0x11, (uint8_t []){0x12}, 1, 0},
|
||||
{0x15, (uint8_t []){0x00}, 1, 0},
|
||||
{0x16, (uint8_t []){0x00}, 1, 0},
|
||||
{0x1A, (uint8_t []){0x00}, 1, 0},
|
||||
{0x1B, (uint8_t []){0x00}, 1, 0},
|
||||
{0x61, (uint8_t []){0x00}, 1, 0},
|
||||
{0x62, (uint8_t []){0x00}, 1, 0},
|
||||
{0x51, (uint8_t []){0x11}, 1, 0},
|
||||
{0x55, (uint8_t []){0x55}, 1, 0},
|
||||
{0x58, (uint8_t []){0x00}, 1, 0},
|
||||
{0x5C, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
{0x20, (uint8_t []){0x81}, 1, 0},
|
||||
{0x21, (uint8_t []){0x82}, 1, 0},
|
||||
{0x22, (uint8_t []){0x72}, 1, 0},
|
||||
{0x30, (uint8_t []){0x00}, 1, 0},
|
||||
{0x31, (uint8_t []){0x00}, 1, 0},
|
||||
{0x32, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
{0x44, (uint8_t []){0x44}, 1, 0},
|
||||
{0x45, (uint8_t []){0x55}, 1, 0},
|
||||
{0x46, (uint8_t []){0x66}, 1, 0},
|
||||
{0x47, (uint8_t []){0x77}, 1, 0},
|
||||
{0x49, (uint8_t []){0x00}, 1, 0},
|
||||
{0x4A, (uint8_t []){0x00}, 1, 0},
|
||||
{0x4B, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x17}, 3, 0},
|
||||
{0x37, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x15}, 3, 0},
|
||||
{0x04, (uint8_t []){0x08}, 1, 0},
|
||||
{0x05, (uint8_t []){0x04}, 1, 0},
|
||||
{0x06, (uint8_t []){0x1C}, 1, 0},
|
||||
{0x07, (uint8_t []){0x1A}, 1, 0},
|
||||
{0x08, (uint8_t []){0x18}, 1, 0},
|
||||
{0x09, (uint8_t []){0x16}, 1, 0},
|
||||
{0x24, (uint8_t []){0x05}, 1, 0},
|
||||
{0x25, (uint8_t []){0x09}, 1, 0},
|
||||
{0x26, (uint8_t []){0x17}, 1, 0},
|
||||
{0x27, (uint8_t []){0x19}, 1, 0},
|
||||
{0x28, (uint8_t []){0x1B}, 1, 0},
|
||||
{0x29, (uint8_t []){0x1D}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x16}, 3, 0},
|
||||
{0x04, (uint8_t []){0x09}, 1, 0},
|
||||
{0x05, (uint8_t []){0x05}, 1, 0},
|
||||
{0x06, (uint8_t []){0x1D}, 1, 0},
|
||||
{0x07, (uint8_t []){0x1B}, 1, 0},
|
||||
{0x08, (uint8_t []){0x19}, 1, 0},
|
||||
{0x09, (uint8_t []){0x17}, 1, 0},
|
||||
{0x24, (uint8_t []){0x04}, 1, 0},
|
||||
{0x25, (uint8_t []){0x08}, 1, 0},
|
||||
{0x26, (uint8_t []){0x16}, 1, 0},
|
||||
{0x27, (uint8_t []){0x18}, 1, 0},
|
||||
{0x28, (uint8_t []){0x1A}, 1, 0},
|
||||
{0x29, (uint8_t []){0x1C}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x18}, 3, 0},
|
||||
{0x1F, (uint8_t []){0x02}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x11}, 3, 0},
|
||||
{0x15, (uint8_t []){0x99}, 1, 0},
|
||||
{0x16, (uint8_t []){0x99}, 1, 0},
|
||||
{0x1C, (uint8_t []){0x88}, 1, 0},
|
||||
{0x1D, (uint8_t []){0x88}, 1, 0},
|
||||
{0x1E, (uint8_t []){0x88}, 1, 0},
|
||||
{0x13, (uint8_t []){0xf0}, 1, 0},
|
||||
{0x14, (uint8_t []){0x34}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x12, (uint8_t []){0x89}, 1, 0},
|
||||
{0x06, (uint8_t []){0x06}, 1, 0},
|
||||
{0x18, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x11}, 3, 0},
|
||||
{0x0A, (uint8_t []){0x00}, 1, 0},
|
||||
{0x0B, (uint8_t []){0xF0}, 1, 0},
|
||||
{0x0c, (uint8_t []){0xF0}, 1, 0},
|
||||
{0x6A, (uint8_t []){0x10}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x11}, 3, 0},
|
||||
{0x08, (uint8_t []){0x70}, 1, 0},
|
||||
{0x09, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0x35, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x12}, 3, 0},
|
||||
{0x21, (uint8_t []){0x70}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x2D}, 3, 0},
|
||||
{0x02, (uint8_t []){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t []){0x20, 0x10, 0x00}, 3, 0},
|
||||
{0x11, (uint8_t []){0x00}, 0, 120},
|
||||
};
|
||||
|
||||
static esp_err_t panel_spd2010_init(esp_lcd_panel_t *panel)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = spd2010->io;
|
||||
const spd2010_lcd_init_cmd_t *init_cmds = NULL;
|
||||
uint16_t init_cmds_size = 0;
|
||||
bool is_user_set = true;
|
||||
bool is_cmd_overwritten = false;
|
||||
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, SPD2010_CMD_SET, (uint8_t[]) {
|
||||
SPD2010_CMD_SET_BYTE0, SPD2010_CMD_SET_BYTE1, SPD2010_CMD_SET_USER
|
||||
}, 3), TAG, "send command failed");
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, LCD_CMD_MADCTL, (uint8_t[]) {
|
||||
spd2010->madctl_val,
|
||||
}, 1), TAG, "send command failed");
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, LCD_CMD_COLMOD, (uint8_t[]) {
|
||||
spd2010->colmod_val,
|
||||
}, 1), TAG, "send command failed");
|
||||
|
||||
// vendor specific initialization, it can be different between manufacturers
|
||||
// should consult the LCD supplier for initialization sequence code
|
||||
if (spd2010->init_cmds) {
|
||||
init_cmds = spd2010->init_cmds;
|
||||
init_cmds_size = spd2010->init_cmds_size;
|
||||
} else {
|
||||
init_cmds = vendor_specific_init_default;
|
||||
init_cmds_size = sizeof(vendor_specific_init_default) / sizeof(spd2010_lcd_init_cmd_t);
|
||||
}
|
||||
|
||||
for (int i = 0; i < init_cmds_size; i++) {
|
||||
// Check if the command has been used or conflicts with the internal only when command2 is disable
|
||||
if (is_user_set && (init_cmds[i].data_bytes > 0)) {
|
||||
switch (init_cmds[i].cmd) {
|
||||
case LCD_CMD_MADCTL:
|
||||
is_cmd_overwritten = true;
|
||||
spd2010->madctl_val = ((uint8_t *)init_cmds[i].data)[0];
|
||||
break;
|
||||
case LCD_CMD_COLMOD:
|
||||
is_cmd_overwritten = true;
|
||||
spd2010->colmod_val = ((uint8_t *)init_cmds[i].data)[0];
|
||||
break;
|
||||
default:
|
||||
is_cmd_overwritten = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_cmd_overwritten) {
|
||||
is_cmd_overwritten = false;
|
||||
ESP_LOGW(TAG, "The %02Xh command has been used and will be overwritten by external initialization sequence",
|
||||
init_cmds[i].cmd);
|
||||
}
|
||||
}
|
||||
|
||||
// Send command
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, init_cmds[i].cmd, init_cmds[i].data, init_cmds[i].data_bytes), TAG,
|
||||
"send command failed");
|
||||
vTaskDelay(pdMS_TO_TICKS(init_cmds[i].delay_ms));
|
||||
|
||||
// Check if the current cmd is the "command set" cmd
|
||||
if ((init_cmds[i].cmd == SPD2010_CMD_SET) && (init_cmds[i].data_bytes > 2)) {
|
||||
is_user_set = (((uint8_t *)init_cmds[i].data)[2] == SPD2010_CMD_SET_USER);
|
||||
}
|
||||
}
|
||||
ESP_LOGD(TAG, "send init commands success");
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
|
||||
esp_lcd_panel_io_handle_t io = spd2010->io;
|
||||
|
||||
x_start += spd2010->x_gap;
|
||||
x_end += spd2010->x_gap;
|
||||
y_start += spd2010->y_gap;
|
||||
y_end += spd2010->y_gap;
|
||||
|
||||
// define an area of frame memory where MCU can access
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, LCD_CMD_CASET, (uint8_t[]) {
|
||||
(x_start >> 8) & 0xFF,
|
||||
x_start & 0xFF,
|
||||
((x_end - 1) >> 8) & 0xFF,
|
||||
(x_end - 1) & 0xFF,
|
||||
}, 4), TAG, "send command failed");
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, LCD_CMD_RASET, (uint8_t[]) {
|
||||
(y_start >> 8) & 0xFF,
|
||||
y_start & 0xFF,
|
||||
((y_end - 1) >> 8) & 0xFF,
|
||||
(y_end - 1) & 0xFF,
|
||||
}, 4), TAG, "send command failed");
|
||||
// transfer frame buffer
|
||||
size_t len = (x_end - x_start) * (y_end - y_start) * spd2010->fb_bits_per_pixel / 8;
|
||||
ESP_RETURN_ON_ERROR(tx_color(spd2010, io, LCD_CMD_RAMWR, color_data, len), TAG, "send color failed");
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_invert_color(esp_lcd_panel_t *panel, bool invert_color_data)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = spd2010->io;
|
||||
int command = 0;
|
||||
if (invert_color_data) {
|
||||
command = LCD_CMD_INVON;
|
||||
} else {
|
||||
command = LCD_CMD_INVOFF;
|
||||
}
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, command, NULL, 0), TAG, "send command failed");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = spd2010->io;
|
||||
if (mirror_x) {
|
||||
spd2010->madctl_val |= BIT(1);
|
||||
} else {
|
||||
spd2010->madctl_val &= ~BIT(1);
|
||||
}
|
||||
if (mirror_y) {
|
||||
spd2010->madctl_val |= BIT(0);
|
||||
} else {
|
||||
spd2010->madctl_val &= ~BIT(0);
|
||||
}
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, LCD_CMD_MADCTL, (uint8_t[]) {
|
||||
spd2010->madctl_val
|
||||
}, 1), TAG, "send command failed");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_swap_xy(esp_lcd_panel_t *panel, bool swap_axes)
|
||||
{
|
||||
ESP_LOGE(TAG, "swap_xy is not supported by this panel");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
spd2010->x_gap = x_gap;
|
||||
spd2010->y_gap = y_gap;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_spd2010_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
|
||||
{
|
||||
spd2010_panel_t *spd2010 = __containerof(panel, spd2010_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = spd2010->io;
|
||||
int command = 0;
|
||||
|
||||
if (on_off) {
|
||||
command = LCD_CMD_DISPON;
|
||||
} else {
|
||||
command = LCD_CMD_DISPOFF;
|
||||
}
|
||||
ESP_RETURN_ON_ERROR(tx_param(spd2010, io, command, NULL, 0), TAG, "send command failed");
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# For more information about build system see
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
add_compile_options("-Wno-format")
|
||||
project(example_qspi_with_ram)
|
||||
@@ -0,0 +1,104 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
|
||||
| Supported LCD Controllers | SPD2010 | GC9B71 | SH8601 |
|
||||
| ------------------------- | ------- | ------ | ------ |
|
||||
|
||||
# QSPI LCD (with RAM) and Touch Panel Example
|
||||
|
||||
[esp_lcd](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd.html) provides several panel drivers out-of box, e.g. ST7789, SSD1306, NT35510. However, there're a lot of other panels on the market, it's beyond `esp_lcd` component's responsibility to include them all.
|
||||
|
||||
`esp_lcd` allows user to add their own panel drivers in the project scope (i.e. panel driver can live outside of esp-idf), so that the upper layer code like LVGL porting code can be reused without any modifications, as long as user-implemented panel driver follows the interface defined in the `esp_lcd` component.
|
||||
|
||||
This example shows how to use SPD1020, GC9B71 or SH8601 display driver from Component manager in esp-idf project. These components are using API provided by `esp_lcd` component. This example will draw a fancy dash board with the LVGL library.
|
||||
|
||||
This example uses the [esp_timer](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/esp_timer.html) to generate the ticks needed by LVGL and uses a dedicated task to run the `lv_timer_handler()`. Since the LVGL APIs are not thread-safe, this example uses a mutex which be invoked before the call of `lv_timer_handler()` and released after it. The same mutex needs to be used in other tasks and threads around every LVGL (lv_...) related function call and code. For more porting guides, please refer to [LVGL porting doc](https://docs.lvgl.io/master/porting/index.html).
|
||||
|
||||
## Touch controller
|
||||
|
||||
In this example you can enable touch controller SPD2010 or CST816 connected via I2C.
|
||||
|
||||
## How to use the example
|
||||
|
||||
### Hardware Required
|
||||
|
||||
* An ESP development board
|
||||
* A SPD1020, GC9B71 or SH8601 LCD panel, with QSPI interface (with/without touch)
|
||||
* An USB cable for power supply and programming
|
||||
|
||||
### Hardware Connection
|
||||
|
||||
The connection between ESP Board and the LCD is as follows:
|
||||
|
||||
```
|
||||
ESP Board SPD1020, GC9B71 or SH8601 Panel (QSPI)
|
||||
┌──────────────────────┐ ┌────────────────────┐
|
||||
│ GND ├─────────────►│ GND │
|
||||
│ │ │ │
|
||||
│ 3V3 ├─────────────►│ VCC │
|
||||
│ │ │ │
|
||||
│ CS ├─────────────►│ CS │
|
||||
│ │ │ │
|
||||
│ SCK ├─────────────►│ CLK │
|
||||
│ │ │ │
|
||||
│ D3 ├─────────────►│ IO3 │
|
||||
│ │ │ │
|
||||
│ D2 ├─────────────►│ IO2 │
|
||||
│ │ │ │
|
||||
│ D1 ├─────────────►│ IO1 │
|
||||
│ │ │ │
|
||||
│ D0 ├─────────────►│ IO0 │
|
||||
│ │ │ │
|
||||
│ RST ├─────────────►│ RSTN │
|
||||
│ │ │ │
|
||||
│ (SCL) ├─────────────►│ TP_SCL │
|
||||
│ │ │ │
|
||||
│ (SDA) ├─────────────►│ TP_SDA │
|
||||
│ │ │ │
|
||||
│ (TP_INT) ├─────────────►│ TP_INT │
|
||||
│ │ │ │
|
||||
│ (3V3) ├─────────────►│ TP_RST │
|
||||
│ │ │ │
|
||||
└──────────────────────┘ └────────────────────┘
|
||||
```
|
||||
|
||||
* The LCD parameters and GPIO number used by this example can be changed in [example_qspi_with_ram.c](main/example_qspi_with_ram.c). Especially, please pay attention to the **vendor specific initialization**, it can be different between manufacturers and should consult the LCD supplier for initialization sequence code.
|
||||
|
||||
### Configure the Project
|
||||
|
||||
Run `idf.py menuconfig` and navigate to `Example Configuration` menu.
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Run `idf.py -p PORT build flash monitor` to build, flash and monitor the project. A fancy animation will show up on the LCD as expected.
|
||||
|
||||
The first time you run `idf.py` for the example will cost extra time as the build system needs to address the component dependencies and downloads the missing components from registry into `managed_components` folder.
|
||||
|
||||
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||
|
||||
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
|
||||
|
||||
### Example Output
|
||||
|
||||
```bash
|
||||
...
|
||||
I (415) example: Turn off LCD backlight
|
||||
I (420) gpio: GPIO[0]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
|
||||
I (429) example: Initialize SPI bus
|
||||
I (434) example: Install panel IO
|
||||
I (438) example: Install SPD2010 panel driver
|
||||
I (442) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
|
||||
I (452) spd2010: LCD panel create success, version: 0.0.1
|
||||
I (741) example: Turn on LCD backlight
|
||||
I (741) example: Initialize LVGL library
|
||||
I (741) example: Register display driver to LVGL
|
||||
I (746) example: Install LVGL tick timer
|
||||
I (748) example: Starting LVGL task
|
||||
I (795) example: Display LVGL demos
|
||||
I (1038) main_task: Returned from app_main()
|
||||
...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
For any technical queries, please open an [issue] (https://github.com/espressif/esp-iot-solution/issues) on GitHub. We will get back to you soon.
|
||||
@@ -0,0 +1,3 @@
|
||||
idf_component_register(
|
||||
SRCS "example_qspi_with_ram.c"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,41 @@
|
||||
menu "Example Configuration"
|
||||
|
||||
choice EXAMPLE_LCD_CONTROLLER
|
||||
prompt "LCD controller model"
|
||||
default EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
help
|
||||
Select LCD controller model
|
||||
|
||||
config EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
bool "SPD2010"
|
||||
|
||||
config EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
bool "GC9B71"
|
||||
|
||||
config EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
bool "SH8601"
|
||||
endchoice
|
||||
|
||||
config EXAMPLE_LCD_TOUCH_ENABLED
|
||||
bool "Enable LCD touch"
|
||||
default n
|
||||
help
|
||||
Enable this option if you wish to use display touch. You can select from touch controllers.
|
||||
|
||||
choice EXAMPLE_LCD_TOUCH_CONTROLLER
|
||||
prompt "LCD touch controller model"
|
||||
depends on EXAMPLE_LCD_TOUCH_ENABLED
|
||||
default EXAMPLE_LCD_TOUCH_CONTROLLER_CST816S if EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
default EXAMPLE_LCD_TOUCH_CONTROLLER_SPD2010 if EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
help
|
||||
Select LCD touch controller model
|
||||
|
||||
config EXAMPLE_LCD_TOUCH_CONTROLLER_SPD2010
|
||||
depends on EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
bool "SPD2010"
|
||||
|
||||
config EXAMPLE_LCD_TOUCH_CONTROLLER_CST816S
|
||||
bool "CST816S"
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "lv_demos.h"
|
||||
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
#include "esp_lcd_spd2010.h"
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
#include "esp_lcd_gc9b71.h"
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
#include "esp_lcd_sh8601.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_SPD2010
|
||||
#include "esp_lcd_touch_spd2010.h"
|
||||
#elif CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_CST816S
|
||||
#include "esp_lcd_touch_cst816s.h"
|
||||
#endif
|
||||
|
||||
static const char *TAG = "example";
|
||||
static SemaphoreHandle_t lvgl_mux = NULL;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_LCD_HOST (SPI2_HOST)
|
||||
#define EXAMPLE_PIN_NUM_LCD_CS (GPIO_NUM_9)
|
||||
#define EXAMPLE_PIN_NUM_LCD_PCLK (GPIO_NUM_10)
|
||||
#define EXAMPLE_PIN_NUM_LCD_DATA0 (GPIO_NUM_11)
|
||||
#define EXAMPLE_PIN_NUM_LCD_DATA1 (GPIO_NUM_12)
|
||||
#define EXAMPLE_PIN_NUM_LCD_DATA2 (GPIO_NUM_13)
|
||||
#define EXAMPLE_PIN_NUM_LCD_DATA3 (GPIO_NUM_14)
|
||||
#define EXAMPLE_PIN_NUM_LCD_RST (GPIO_NUM_0) // -1 if not used
|
||||
#define EXAMPLE_PIN_NUM_BK_LIGHT (GPIO_NUM_1) // -1 if not used
|
||||
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
|
||||
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||
|
||||
// The pixel number in horizontal and vertical
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
#define EXAMPLE_LCD_H_RES 412
|
||||
#define EXAMPLE_LCD_V_RES 412
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
#define EXAMPLE_LCD_H_RES 320
|
||||
#define EXAMPLE_LCD_V_RES 386
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
#define EXAMPLE_LCD_H_RES 454
|
||||
#define EXAMPLE_LCD_V_RES 454
|
||||
#endif
|
||||
|
||||
#if CONFIG_LV_COLOR_DEPTH == 32
|
||||
#define LCD_BIT_PER_PIXEL (24)
|
||||
#elif CONFIG_LV_COLOR_DEPTH == 16
|
||||
#define LCD_BIT_PER_PIXEL (16)
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your touch spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if CONFIG_EXAMPLE_LCD_TOUCH_ENABLED
|
||||
#define EXAMPLE_TOUCH_HOST (I2C_NUM_0)
|
||||
#define EXAMPLE_PIN_NUM_TOUCH_SCL (GPIO_NUM_18)
|
||||
#define EXAMPLE_PIN_NUM_TOUCH_SDA (GPIO_NUM_8)
|
||||
#define EXAMPLE_PIN_NUM_TOUCH_RST (-1) // -1 if not used
|
||||
#define EXAMPLE_PIN_NUM_TOUCH_INT (GPIO_NUM_2) // -1 if not used
|
||||
|
||||
esp_lcd_touch_handle_t tp = NULL;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to LVGL ///////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_LVGL_BUFF_SIZE (EXAMPLE_LCD_H_RES * 20)
|
||||
#define EXAMPLE_LVGL_TICK_PERIOD_MS 2
|
||||
#define EXAMPLE_LVGL_TASK_MAX_DELAY_MS 500
|
||||
#define EXAMPLE_LVGL_TASK_MIN_DELAY_MS 2
|
||||
#define EXAMPLE_LVGL_TASK_STACK_SIZE (4 * 1024)
|
||||
#define EXAMPLE_LVGL_TASK_PRIORITY 2
|
||||
|
||||
static bool example_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx)
|
||||
{
|
||||
lv_disp_drv_t *disp_driver = (lv_disp_drv_t *)user_ctx;
|
||||
lv_disp_flush_ready(disp_driver);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void example_lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
|
||||
{
|
||||
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
|
||||
const int offsetx1 = area->x1;
|
||||
const int offsetx2 = area->x2;
|
||||
const int offsety1 = area->y1;
|
||||
const int offsety2 = area->y2;
|
||||
|
||||
#if LCD_BIT_PER_PIXEL == 24
|
||||
uint8_t *to = (uint8_t *)color_map;
|
||||
uint8_t temp = 0;
|
||||
uint16_t pixel_num = (offsetx2 - offsetx1 + 1) * (offsety2 - offsety1 + 1);
|
||||
|
||||
// Special dealing for first pixel
|
||||
temp = color_map[0].ch.blue;
|
||||
*to++ = color_map[0].ch.red;
|
||||
*to++ = color_map[0].ch.green;
|
||||
*to++ = temp;
|
||||
// Normal dealing for other pixels
|
||||
for (int i = 1; i < pixel_num; i++) {
|
||||
*to++ = color_map[i].ch.red;
|
||||
*to++ = color_map[i].ch.green;
|
||||
*to++ = color_map[i].ch.blue;
|
||||
}
|
||||
#endif
|
||||
|
||||
// copy a buffer's content to a specific area of the display
|
||||
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
|
||||
}
|
||||
|
||||
/* Rotate display and touch, when rotated screen in LVGL. Called when driver parameters are updated. */
|
||||
static void example_lvgl_update_cb(lv_disp_drv_t *drv)
|
||||
{
|
||||
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
|
||||
|
||||
switch (drv->rotated) {
|
||||
case LV_DISP_ROT_NONE:
|
||||
// Rotate LCD display
|
||||
esp_lcd_panel_swap_xy(panel_handle, false);
|
||||
esp_lcd_panel_mirror(panel_handle, true, false);
|
||||
break;
|
||||
case LV_DISP_ROT_90:
|
||||
// Rotate LCD display
|
||||
esp_lcd_panel_swap_xy(panel_handle, true);
|
||||
esp_lcd_panel_mirror(panel_handle, true, true);
|
||||
break;
|
||||
case LV_DISP_ROT_180:
|
||||
// Rotate LCD display
|
||||
esp_lcd_panel_swap_xy(panel_handle, false);
|
||||
esp_lcd_panel_mirror(panel_handle, false, true);
|
||||
break;
|
||||
case LV_DISP_ROT_270:
|
||||
// Rotate LCD display
|
||||
esp_lcd_panel_swap_xy(panel_handle, true);
|
||||
esp_lcd_panel_mirror(panel_handle, false, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void example_lvgl_rounder_cb(struct _lv_disp_drv_t *disp_drv, lv_area_t *area)
|
||||
{
|
||||
uint16_t x1 = area->x1;
|
||||
uint16_t x2 = area->x2;
|
||||
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71 || CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
uint16_t y1 = area->y1;
|
||||
uint16_t y2 = area->y2;
|
||||
|
||||
// round the start of coordinate down to the nearest 2M number
|
||||
area->x1 = (x1 >> 1) << 1;
|
||||
area->y1 = (y1 >> 1) << 1;
|
||||
// round the end of coordinate up to the nearest 2N+1 number
|
||||
area->x2 = ((x2 >> 1) << 1) + 1;
|
||||
area->y2 = ((y2 >> 1) << 1) + 1;
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
// round the start of coordinate down to the nearest 4M number
|
||||
area->x1 = (x1 >> 2) << 2;
|
||||
// round the end of coordinate up to the nearest 4N+3 number
|
||||
area->x2 = ((x2 >> 2) << 2) + 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_EXAMPLE_LCD_TOUCH_ENABLED
|
||||
static SemaphoreHandle_t touch_mux = NULL;
|
||||
|
||||
static void example_lvgl_touch_cb(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
{
|
||||
esp_lcd_touch_handle_t tp = (esp_lcd_touch_handle_t)drv->user_data;
|
||||
assert(tp);
|
||||
|
||||
uint16_t tp_x;
|
||||
uint16_t tp_y;
|
||||
uint8_t tp_cnt = 0;
|
||||
#if EXAMPLE_PIN_NUM_TOUCH_INT >= 0
|
||||
/* Read data from touch controller into memory */
|
||||
if (xSemaphoreTake(touch_mux, 0) == pdTRUE) {
|
||||
esp_lcd_touch_read_data(tp);
|
||||
}
|
||||
#else
|
||||
esp_lcd_touch_read_data(tp);
|
||||
#endif
|
||||
|
||||
/* Read data from touch controller */
|
||||
bool tp_pressed = esp_lcd_touch_get_coordinates(tp, &tp_x, &tp_y, NULL, &tp_cnt, 1);
|
||||
if (tp_pressed && tp_cnt > 0) {
|
||||
data->point.x = tp_x;
|
||||
data->point.y = tp_y;
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
ESP_LOGD(TAG, "Touch position: %d,%d", tp_x, tp_y);
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
}
|
||||
|
||||
static void example_touch_isr_cb(esp_lcd_touch_handle_t tp)
|
||||
{
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
xSemaphoreGiveFromISR(touch_mux, &xHigherPriorityTaskWoken);
|
||||
|
||||
if (xHigherPriorityTaskWoken) {
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void example_increase_lvgl_tick(void *arg)
|
||||
{
|
||||
/* Tell LVGL how many milliseconds has elapsed */
|
||||
lv_tick_inc(EXAMPLE_LVGL_TICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
static bool example_lvgl_lock(int timeout_ms)
|
||||
{
|
||||
assert(lvgl_mux && "bsp_display_start must be called first");
|
||||
|
||||
const TickType_t timeout_ticks = (timeout_ms == -1) ? portMAX_DELAY : pdMS_TO_TICKS(timeout_ms);
|
||||
return xSemaphoreTake(lvgl_mux, timeout_ticks) == pdTRUE;
|
||||
}
|
||||
|
||||
static void example_lvgl_unlock(void)
|
||||
{
|
||||
assert(lvgl_mux && "bsp_display_start must be called first");
|
||||
xSemaphoreGive(lvgl_mux);
|
||||
}
|
||||
|
||||
static void example_lvgl_port_task(void *arg)
|
||||
{
|
||||
ESP_LOGI(TAG, "Starting LVGL task");
|
||||
uint32_t task_delay_ms = EXAMPLE_LVGL_TASK_MAX_DELAY_MS;
|
||||
while (1) {
|
||||
// Lock the mutex due to the LVGL APIs are not thread-safe
|
||||
if (example_lvgl_lock(-1)) {
|
||||
task_delay_ms = lv_timer_handler();
|
||||
// Release the mutex
|
||||
example_lvgl_unlock();
|
||||
}
|
||||
if (task_delay_ms > EXAMPLE_LVGL_TASK_MAX_DELAY_MS) {
|
||||
task_delay_ms = EXAMPLE_LVGL_TASK_MAX_DELAY_MS;
|
||||
} else if (task_delay_ms < EXAMPLE_LVGL_TASK_MIN_DELAY_MS) {
|
||||
task_delay_ms = EXAMPLE_LVGL_TASK_MIN_DELAY_MS;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(task_delay_ms));
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
// static const gc9b71_lcd_init_cmd_t lcd_init_cmds[] = {
|
||||
// // {cmd, { data }, data_size, delay_ms}
|
||||
// {0xfe, (uint8_t []){0x00}, 0, 0},
|
||||
// {0xef, (uint8_t []){0x00}, 0, 0},
|
||||
// {0x80, (uint8_t []){0x11}, 1, 0},
|
||||
// {0x81, (uint8_t []){0x70}, 1, 0},
|
||||
// ...
|
||||
// };
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
// static const spd2010_lcd_init_cmd_t lcd_init_cmds[] = {
|
||||
// // {cmd, { data }, data_size, delay_ms}
|
||||
// {0xFF, (uint8_t []){0x20, 0x10, 0x10}, 3, 0},
|
||||
// {0x0C, (uint8_t []){0x11}, 1, 0},
|
||||
// {0x10, (uint8_t []){0x02}, 1, 0},
|
||||
// {0x11, (uint8_t []){0x11}, 1, 0},
|
||||
// ...
|
||||
// };
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
// static const sh8601_lcd_init_cmd_t lcd_init_cmds[] = {
|
||||
// // {cmd, { data }, data_size, delay_ms}
|
||||
// {0x44, (uint8_t []){0x00, 0xc8}, 2, 0},
|
||||
// {0x35, (uint8_t []){0x00}, 0, 0},
|
||||
// {0x53, (uint8_t []){0x20}, 1, 25},
|
||||
// {0x29, (uint8_t []){0x00}, 0, 120},
|
||||
// ...
|
||||
// };
|
||||
#endif
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
static lv_disp_draw_buf_t disp_buf; // contains internal graphic buffer(s) called draw buffer(s)
|
||||
static lv_disp_drv_t disp_drv; // contains callback functions
|
||||
|
||||
if (EXAMPLE_PIN_NUM_BK_LIGHT >= 0) {
|
||||
ESP_LOGI(TAG, "Turn off LCD backlight");
|
||||
gpio_config_t bk_gpio_config = {
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT
|
||||
};
|
||||
ESP_ERROR_CHECK(gpio_config(&bk_gpio_config));
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Initialize SPI bus");
|
||||
const spi_bus_config_t buscfg =
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
GC9B71_PANEL_BUS_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_PCLK, EXAMPLE_PIN_NUM_LCD_DATA0,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA1, EXAMPLE_PIN_NUM_LCD_DATA2,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA3, EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES * LCD_BIT_PER_PIXEL / 8);
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
SPD2010_PANEL_BUS_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_PCLK, EXAMPLE_PIN_NUM_LCD_DATA0,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA1, EXAMPLE_PIN_NUM_LCD_DATA2,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA3, EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES * LCD_BIT_PER_PIXEL / 8);
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
SH8601_PANEL_BUS_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_PCLK, EXAMPLE_PIN_NUM_LCD_DATA0,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA1, EXAMPLE_PIN_NUM_LCD_DATA2,
|
||||
EXAMPLE_PIN_NUM_LCD_DATA3, EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES * LCD_BIT_PER_PIXEL / 8);
|
||||
#endif
|
||||
ESP_ERROR_CHECK(spi_bus_initialize(EXAMPLE_LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));
|
||||
|
||||
ESP_LOGI(TAG, "Install panel IO");
|
||||
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||
const esp_lcd_panel_io_spi_config_t io_config =
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
GC9B71_PANEL_IO_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_CS, example_notify_lvgl_flush_ready, &disp_drv);
|
||||
gc9b71_vendor_config_t vendor_config = {
|
||||
// .init_cmds = lcd_init_cmds, // Uncomment these line if use custom initialization commands
|
||||
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(gc9b71_lcd_init_cmd_t),
|
||||
.flags = {
|
||||
.use_qspi_interface = 1,
|
||||
},
|
||||
};
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
SPD2010_PANEL_IO_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_CS, example_notify_lvgl_flush_ready, &disp_drv);
|
||||
spd2010_vendor_config_t vendor_config = {
|
||||
// .init_cmds = lcd_init_cmds, // Uncomment these line if use custom initialization commands
|
||||
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(spd2010_lcd_init_cmd_t),
|
||||
.flags = {
|
||||
.use_qspi_interface = 1,
|
||||
},
|
||||
};
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
SH8601_PANEL_IO_QSPI_CONFIG(EXAMPLE_PIN_NUM_LCD_CS, example_notify_lvgl_flush_ready, &disp_drv);
|
||||
sh8601_vendor_config_t vendor_config = {
|
||||
// .init_cmds = lcd_init_cmds, // Uncomment these line if use custom initialization commands
|
||||
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(sh8601_lcd_init_cmd_t),
|
||||
.flags = {
|
||||
.use_qspi_interface = 1,
|
||||
},
|
||||
};
|
||||
#endif
|
||||
// Attach the LCD to the SPI bus
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)EXAMPLE_LCD_HOST, &io_config, &io_handle));
|
||||
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
|
||||
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
|
||||
.bits_per_pixel = LCD_BIT_PER_PIXEL,
|
||||
.vendor_config = &vendor_config,
|
||||
};
|
||||
ESP_LOGI(TAG, "Install LCD driver");
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_gc9b71(io_handle, &panel_config, &panel_handle));
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_spd2010(io_handle, &panel_config, &panel_handle));
|
||||
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_sh8601(io_handle, &panel_config, &panel_handle));
|
||||
#endif
|
||||
|
||||
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
|
||||
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
|
||||
// user can flush pre-defined pattern to the screen before we turn on the screen or backlight
|
||||
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
|
||||
|
||||
#if CONFIG_EXAMPLE_LCD_TOUCH_ENABLED
|
||||
ESP_LOGI(TAG, "Initialize I2C bus");
|
||||
const i2c_config_t i2c_conf = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = EXAMPLE_PIN_NUM_TOUCH_SDA,
|
||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.scl_io_num = EXAMPLE_PIN_NUM_TOUCH_SCL,
|
||||
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.master.clk_speed = 400 * 1000,
|
||||
};
|
||||
ESP_ERROR_CHECK(i2c_param_config(EXAMPLE_TOUCH_HOST, &i2c_conf));
|
||||
ESP_ERROR_CHECK(i2c_driver_install(EXAMPLE_TOUCH_HOST, i2c_conf.mode, 0, 0, 0));
|
||||
|
||||
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
|
||||
#if CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_SPD2010
|
||||
const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_SPD2010_CONFIG();
|
||||
#elif CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_CST816S
|
||||
const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
|
||||
#endif
|
||||
// Attach the TOUCH to the I2C bus
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)EXAMPLE_TOUCH_HOST, &tp_io_config, &tp_io_handle));
|
||||
|
||||
touch_mux = xSemaphoreCreateBinary();
|
||||
assert(touch_mux);
|
||||
|
||||
const esp_lcd_touch_config_t tp_cfg = {
|
||||
.x_max = EXAMPLE_LCD_H_RES,
|
||||
.y_max = EXAMPLE_LCD_V_RES,
|
||||
.rst_gpio_num = EXAMPLE_PIN_NUM_TOUCH_RST,
|
||||
.int_gpio_num = EXAMPLE_PIN_NUM_TOUCH_INT,
|
||||
.levels = {
|
||||
.reset = 0,
|
||||
.interrupt = 0,
|
||||
},
|
||||
.flags = {
|
||||
.swap_xy = 0,
|
||||
.mirror_x = 0,
|
||||
.mirror_y = 0,
|
||||
},
|
||||
.interrupt_callback = example_touch_isr_cb,
|
||||
};
|
||||
|
||||
ESP_LOGI(TAG, "Initialize touch controller");
|
||||
#if CONFIG_EXAMPLE_LCD_CONTROLLER_SPD2010
|
||||
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_spd2010(tp_io_handle, &tp_cfg, &tp));
|
||||
#elif CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_CST816S
|
||||
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_cst816s(tp_io_handle, &tp_cfg, &tp));
|
||||
#endif
|
||||
#endif // CONFIG_EXAMPLE_LCD_TOUCH_ENABLED
|
||||
|
||||
if (EXAMPLE_PIN_NUM_BK_LIGHT >= 0) {
|
||||
ESP_LOGI(TAG, "Turn on LCD backlight");
|
||||
gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Initialize LVGL library");
|
||||
lv_init();
|
||||
// alloc draw buffers used by LVGL
|
||||
// it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized
|
||||
lv_color_t *buf1 = heap_caps_malloc(EXAMPLE_LVGL_BUFF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
|
||||
assert(buf1);
|
||||
lv_color_t *buf2 = heap_caps_malloc(EXAMPLE_LVGL_BUFF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
|
||||
assert(buf2);
|
||||
// initialize LVGL draw buffers
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, buf2, EXAMPLE_LVGL_BUFF_SIZE);
|
||||
|
||||
ESP_LOGI(TAG, "Register display driver to LVGL");
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
disp_drv.hor_res = EXAMPLE_LCD_H_RES;
|
||||
disp_drv.ver_res = EXAMPLE_LCD_V_RES;
|
||||
disp_drv.flush_cb = example_lvgl_flush_cb;
|
||||
disp_drv.rounder_cb = example_lvgl_rounder_cb;
|
||||
disp_drv.drv_update_cb = example_lvgl_update_cb;
|
||||
disp_drv.draw_buf = &disp_buf;
|
||||
disp_drv.user_data = panel_handle;
|
||||
lv_disp_t *disp = lv_disp_drv_register(&disp_drv);
|
||||
|
||||
ESP_LOGI(TAG, "Install LVGL tick timer");
|
||||
// Tick interface for LVGL (using esp_timer to generate 2ms periodic event)
|
||||
const esp_timer_create_args_t lvgl_tick_timer_args = {
|
||||
.callback = &example_increase_lvgl_tick,
|
||||
.name = "lvgl_tick"
|
||||
};
|
||||
esp_timer_handle_t lvgl_tick_timer = NULL;
|
||||
ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer));
|
||||
ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000));
|
||||
|
||||
#if CONFIG_EXAMPLE_LCD_TOUCH_ENABLED
|
||||
static lv_indev_drv_t indev_drv; // Input device driver (Touch)
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.disp = disp;
|
||||
indev_drv.read_cb = example_lvgl_touch_cb;
|
||||
indev_drv.user_data = tp;
|
||||
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
#else
|
||||
(void)disp;
|
||||
#endif
|
||||
|
||||
lvgl_mux = xSemaphoreCreateMutex();
|
||||
assert(lvgl_mux);
|
||||
xTaskCreate(example_lvgl_port_task, "LVGL", EXAMPLE_LVGL_TASK_STACK_SIZE, NULL, EXAMPLE_LVGL_TASK_PRIORITY, NULL);
|
||||
|
||||
ESP_LOGI(TAG, "Display LVGL demos");
|
||||
// Lock the mutex due to the LVGL APIs are not thread-safe
|
||||
if (example_lvgl_lock(-1)) {
|
||||
// lv_demo_widgets(); /* A widgets example */
|
||||
lv_demo_music(); /* A modern, smartphone-like music player demo. */
|
||||
// lv_demo_stress(); /* A stress test for LVGL. */
|
||||
// lv_demo_benchmark(); /* A demo to measure the performance of LVGL or to compare different settings. */
|
||||
|
||||
// Release the mutex
|
||||
example_lvgl_unlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
dependencies:
|
||||
idf: ">5.0.4,!=5.1.1"
|
||||
|
||||
esp_lcd_touch_cst816s:
|
||||
version: "^1"
|
||||
public: true
|
||||
|
||||
esp_lcd_touch_spd2010:
|
||||
version: "^0.0.1"
|
||||
public: true
|
||||
|
||||
esp_lcd_gc9b71:
|
||||
version: "*"
|
||||
override_path: "../../../../../components/display/lcd/esp_lcd_gc9b71"
|
||||
public: true
|
||||
|
||||
esp_lcd_sh8601:
|
||||
version: "*"
|
||||
override_path: "../../../../../components/display/lcd/esp_lcd_sh8601"
|
||||
public: true
|
||||
|
||||
esp_lcd_spd2010:
|
||||
version: "*"
|
||||
override_path: "../../../../../components/display/lcd/esp_lcd_spd2010"
|
||||
public: true
|
||||
|
||||
lvgl/lvgl:
|
||||
version: "^8"
|
||||
public: true
|
||||
@@ -0,0 +1,5 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, , 0x6000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
factory, app, factory, , 3M,
|
||||
|
@@ -0,0 +1 @@
|
||||
CONFIG_EXAMPLE_LCD_TOUCH_ENABLED=y
|
||||
@@ -0,0 +1,2 @@
|
||||
CONFIG_EXAMPLE_LCD_CONTROLLER_GC9B71=y
|
||||
CONFIG_EXAMPLE_LCD_TOUCH_ENABLED=y
|
||||
@@ -0,0 +1 @@
|
||||
CONFIG_EXAMPLE_LCD_CONTROLLER_SH8601=y
|
||||
@@ -0,0 +1,17 @@
|
||||
# This file was generated using idf.py save-defconfig. It can be edited manually.
|
||||
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
|
||||
#
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_LV_COLOR_16_SWAP=y
|
||||
CONFIG_LV_MEM_CUSTOM=y
|
||||
CONFIG_LV_MEMCPY_MEMSET_STD=y
|
||||
CONFIG_LV_USE_PERF_MONITOR=y
|
||||
CONFIG_LV_FONT_MONTSERRAT_12=y
|
||||
CONFIG_LV_FONT_MONTSERRAT_16=y
|
||||
CONFIG_LV_USE_DEMO_WIDGETS=y
|
||||
CONFIG_LV_USE_DEMO_BENCHMARK=y
|
||||
CONFIG_LV_USE_DEMO_STRESS=y
|
||||
CONFIG_LV_USE_DEMO_MUSIC=y
|
||||
CONFIG_LV_DEMO_MUSIC_AUTO_PLAY=y
|
||||
@@ -0,0 +1,6 @@
|
||||
# This file was generated using idf.py save-defconfig. It can be edited manually.
|
||||
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
|
||||
#
|
||||
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
||||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
|
||||
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
|
||||
@@ -0,0 +1,11 @@
|
||||
dependencies:
|
||||
cmake_utilities: 0.*
|
||||
idf: '>5.0.4,!=5.1.1'
|
||||
description: ESP LCD SPD2010(SPI & QSPI)
|
||||
issues: https://github.com/espressif/esp-iot-solution/issues
|
||||
repository: git://github.com/espressif/esp-iot-solution.git
|
||||
repository_info:
|
||||
commit_sha: 1f855ac00e3fdb33773c8ba5893d4f98f1d9b576
|
||||
path: components/display/lcd/esp_lcd_spd2010
|
||||
url: https://github.com/espressif/esp-iot-solution/tree/master/components/display/lcd/esp_lcd_spd2010
|
||||
version: 1.0.2
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LCD panel initialization commands.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int cmd; /*<! The specific LCD command */
|
||||
const void *data; /*<! Buffer that holds the command specific data */
|
||||
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
|
||||
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
|
||||
} spd2010_lcd_init_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief LCD panel vendor configuration.
|
||||
*
|
||||
* @note This structure can be used to select interface type and override default initialization commands.
|
||||
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
const spd2010_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array.
|
||||
* The array should be declared as `static const` and positioned outside the function.
|
||||
* Please refer to `vendor_specific_init_default` in source file
|
||||
*/
|
||||
uint16_t init_cmds_size; /*<! Number of commands in above array */
|
||||
struct {
|
||||
unsigned int use_qspi_interface: 1; /*<! Set to 1 if use QSPI interface, default is SPI interface */
|
||||
} flags;
|
||||
} spd2010_vendor_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel for model SPD2010
|
||||
*
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @param[in] panel_dev_config General panel device configuration (Use `vendor_config` to select QSPI interface or override default initialization commands)
|
||||
* @param[out] ret_panel Returned LCD panel handle
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Otherwise: Fail
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_spd2010(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
/**
|
||||
* @brief LCD panel bus configuration structure
|
||||
*
|
||||
*/
|
||||
#define SPD2010_PANEL_BUS_SPI_CONFIG(sclk, mosi, max_trans_sz) \
|
||||
{ \
|
||||
.sclk_io_num = sclk, \
|
||||
.mosi_io_num = mosi, \
|
||||
.miso_io_num = -1, \
|
||||
.quadhd_io_num = -1, \
|
||||
.quadwp_io_num = -1, \
|
||||
.max_transfer_sz = max_trans_sz, \
|
||||
}
|
||||
#define SPD2010_PANEL_BUS_QSPI_CONFIG(sclk, d0, d1, d2, d3, max_trans_sz) \
|
||||
{ \
|
||||
.sclk_io_num = sclk, \
|
||||
.data0_io_num = d0, \
|
||||
.data1_io_num = d1, \
|
||||
.data2_io_num = d2, \
|
||||
.data3_io_num = d3, \
|
||||
.max_transfer_sz = max_trans_sz, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LCD panel IO configuration structure
|
||||
*
|
||||
*/
|
||||
#define SPD2010_PANEL_IO_SPI_CONFIG(cs, dc, cb, cb_ctx) \
|
||||
{ \
|
||||
.cs_gpio_num = cs, \
|
||||
.dc_gpio_num = dc, \
|
||||
.spi_mode = 3, \
|
||||
.pclk_hz = 80 * 1000 * 1000, \
|
||||
.trans_queue_depth = 10, \
|
||||
.on_color_trans_done = cb, \
|
||||
.user_ctx = cb_ctx, \
|
||||
.lcd_cmd_bits = 8, \
|
||||
.lcd_param_bits = 8, \
|
||||
}
|
||||
#define SPD2010_PANEL_IO_QSPI_CONFIG(cs, cb, cb_ctx) \
|
||||
{ \
|
||||
.cs_gpio_num = cs, \
|
||||
.dc_gpio_num = -1, \
|
||||
.spi_mode = 3, \
|
||||
.pclk_hz = 20 * 1000 * 1000, \
|
||||
.trans_queue_depth = 10, \
|
||||
.on_color_trans_done = cb, \
|
||||
.user_ctx = cb_ctx, \
|
||||
.lcd_cmd_bits = 32, \
|
||||
.lcd_param_bits = 8, \
|
||||
.flags = { \
|
||||
.quad_mode = true, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
202
managed_components/espressif__esp_lcd_spd2010/license.txt
Normal file
202
managed_components/espressif__esp_lcd_spd2010/license.txt
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,6 @@
|
||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(test_esp_lcd_spd2010)
|
||||
@@ -0,0 +1 @@
|
||||
idf_component_register(SRCS "test_esp_lcd_spd2010.c")
|
||||
@@ -0,0 +1,6 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
idf: ">5.0.4,!=5.1.1"
|
||||
esp_lcd_spd2010:
|
||||
version: "*"
|
||||
override_path: "../../../esp_lcd_spd2010"
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_lcd_panel_io_interface.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "unity.h"
|
||||
#include "unity_test_runner.h"
|
||||
#include "unity_test_utils_memory.h"
|
||||
|
||||
#include "esp_lcd_spd2010.h"
|
||||
|
||||
#define TEST_LCD_HOST SPI2_HOST
|
||||
#define TEST_LCD_H_RES (412)
|
||||
#define TEST_LCD_V_RES (412)
|
||||
#define TEST_LCD_BIT_PER_PIXEL (16)
|
||||
|
||||
#define TEST_PIN_NUM_LCD_CS (GPIO_NUM_9)
|
||||
#define TEST_PIN_NUM_LCD_PCLK (GPIO_NUM_10)
|
||||
#define TEST_PIN_NUM_LCD_DATA0 (GPIO_NUM_11)
|
||||
#define TEST_PIN_NUM_LCD_DATA1 (GPIO_NUM_12)
|
||||
#define TEST_PIN_NUM_LCD_DATA2 (GPIO_NUM_13)
|
||||
#define TEST_PIN_NUM_LCD_DATA3 (GPIO_NUM_14)
|
||||
#define TEST_PIN_NUM_LCD_RST (GPIO_NUM_17)
|
||||
#define TEST_PIN_NUM_LCD_DC (GPIO_NUM_8)
|
||||
#define TEST_PIN_NUM_BK_LIGHT (GPIO_NUM_0) // set to -1 if not used
|
||||
#define TEST_LCD_BK_LIGHT_ON_LEVEL (1)
|
||||
#define TEST_LCD_BK_LIGHT_OFF_LEVEL !TEST_LCD_BK_LIGHT_ON_LEVEL
|
||||
|
||||
#define TEST_DELAY_TIME_MS (3000)
|
||||
|
||||
static char *TAG = "spd2010_test";
|
||||
static SemaphoreHandle_t refresh_finish = NULL;
|
||||
|
||||
IRAM_ATTR static bool test_notify_refresh_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx)
|
||||
{
|
||||
BaseType_t need_yield = pdFALSE;
|
||||
|
||||
xSemaphoreGiveFromISR(refresh_finish, &need_yield);
|
||||
return (need_yield == pdTRUE);
|
||||
}
|
||||
|
||||
static void test_draw_bitmap(esp_lcd_panel_handle_t panel_handle)
|
||||
{
|
||||
refresh_finish = xSemaphoreCreateBinary();
|
||||
TEST_ASSERT_NOT_NULL(refresh_finish);
|
||||
|
||||
uint16_t row_line = TEST_LCD_V_RES / TEST_LCD_BIT_PER_PIXEL;
|
||||
uint8_t byte_per_pixel = TEST_LCD_BIT_PER_PIXEL / 8;
|
||||
uint8_t *color = (uint8_t *)heap_caps_calloc(1, row_line * TEST_LCD_H_RES * byte_per_pixel, MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(color);
|
||||
|
||||
for (int j = 0; j < TEST_LCD_BIT_PER_PIXEL; j++) {
|
||||
for (int i = 0; i < row_line * TEST_LCD_H_RES; i++) {
|
||||
for (int k = 0; k < byte_per_pixel; k++) {
|
||||
color[i * byte_per_pixel + k] = (SPI_SWAP_DATA_TX(BIT(j), TEST_LCD_BIT_PER_PIXEL) >> (k * 8)) & 0xff;
|
||||
}
|
||||
}
|
||||
TEST_ESP_OK(esp_lcd_panel_draw_bitmap(panel_handle, 0, j * row_line, TEST_LCD_H_RES, (j + 1) * row_line, color));
|
||||
xSemaphoreTake(refresh_finish, portMAX_DELAY);
|
||||
}
|
||||
free(color);
|
||||
vSemaphoreDelete(refresh_finish);
|
||||
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_TIME_MS));
|
||||
}
|
||||
|
||||
TEST_CASE("test spd2010 to draw color bar with SPI interface", "[spd2010][spi]")
|
||||
{
|
||||
#if TEST_PIN_NUM_BK_LIGHT >= 0
|
||||
ESP_LOGI(TAG, "Turn on LCD backlight");
|
||||
gpio_config_t bk_gpio_config = {
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pin_bit_mask = 1ULL << TEST_PIN_NUM_BK_LIGHT
|
||||
};
|
||||
TEST_ESP_OK(gpio_config(&bk_gpio_config));
|
||||
TEST_ESP_OK(gpio_set_level(TEST_PIN_NUM_BK_LIGHT, TEST_LCD_BK_LIGHT_ON_LEVEL));
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Initialize SPI bus");
|
||||
const spi_bus_config_t buscfg = SPD2010_PANEL_BUS_SPI_CONFIG(TEST_PIN_NUM_LCD_PCLK,
|
||||
TEST_PIN_NUM_LCD_DATA0,
|
||||
TEST_LCD_H_RES * TEST_LCD_V_RES * TEST_LCD_BIT_PER_PIXEL / 8);
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));
|
||||
|
||||
ESP_LOGI(TAG, "Install panel IO");
|
||||
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||
const esp_lcd_panel_io_spi_config_t io_config = SPD2010_PANEL_IO_SPI_CONFIG(TEST_PIN_NUM_LCD_CS, TEST_PIN_NUM_LCD_DC,
|
||||
test_notify_refresh_ready, NULL);
|
||||
// Attach the LCD to the SPI bus
|
||||
TEST_ESP_OK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TEST_LCD_HOST, &io_config, &io_handle));
|
||||
|
||||
ESP_LOGI(TAG, "Install SPD2010 panel driver");
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = TEST_PIN_NUM_LCD_RST,
|
||||
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
|
||||
.bits_per_pixel = TEST_LCD_BIT_PER_PIXEL,
|
||||
};
|
||||
TEST_ESP_OK(esp_lcd_new_panel_spd2010(io_handle, &panel_config, &panel_handle));
|
||||
esp_lcd_panel_reset(panel_handle);
|
||||
esp_lcd_panel_init(panel_handle);
|
||||
esp_lcd_panel_disp_on_off(panel_handle, true);
|
||||
|
||||
test_draw_bitmap(panel_handle);
|
||||
|
||||
TEST_ESP_OK(esp_lcd_panel_del(panel_handle));
|
||||
TEST_ESP_OK(esp_lcd_panel_io_del(io_handle));
|
||||
TEST_ESP_OK(spi_bus_free(TEST_LCD_HOST));
|
||||
|
||||
#if TEST_PIN_NUM_BK_LIGHT >= 0
|
||||
TEST_ESP_OK(gpio_reset_pin(TEST_PIN_NUM_BK_LIGHT));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("test spd2010 to draw color bar with QSPI interface", "[spd2010][qspi]")
|
||||
{
|
||||
#if TEST_PIN_NUM_BK_LIGHT >= 0
|
||||
ESP_LOGI(TAG, "Turn on LCD backlight");
|
||||
gpio_config_t bk_gpio_config = {
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pin_bit_mask = 1ULL << TEST_PIN_NUM_BK_LIGHT
|
||||
};
|
||||
TEST_ESP_OK(gpio_config(&bk_gpio_config));
|
||||
TEST_ESP_OK(gpio_set_level(TEST_PIN_NUM_BK_LIGHT, TEST_LCD_BK_LIGHT_ON_LEVEL));
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Initialize SPI bus");
|
||||
const spi_bus_config_t buscfg = SPD2010_PANEL_BUS_QSPI_CONFIG(TEST_PIN_NUM_LCD_PCLK,
|
||||
TEST_PIN_NUM_LCD_DATA0,
|
||||
TEST_PIN_NUM_LCD_DATA1,
|
||||
TEST_PIN_NUM_LCD_DATA2,
|
||||
TEST_PIN_NUM_LCD_DATA3,
|
||||
TEST_LCD_H_RES * TEST_LCD_V_RES * TEST_LCD_BIT_PER_PIXEL / 8);
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));
|
||||
|
||||
ESP_LOGI(TAG, "Install panel IO");
|
||||
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||
const esp_lcd_panel_io_spi_config_t io_config = SPD2010_PANEL_IO_QSPI_CONFIG(TEST_PIN_NUM_LCD_CS, test_notify_refresh_ready, NULL);
|
||||
// Attach the LCD to the SPI bus
|
||||
TEST_ESP_OK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TEST_LCD_HOST, &io_config, &io_handle));
|
||||
|
||||
ESP_LOGI(TAG, "Install SPD2010 panel driver");
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
const spd2010_vendor_config_t vendor_config = {
|
||||
.flags = {
|
||||
.use_qspi_interface = 1,
|
||||
},
|
||||
};
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = TEST_PIN_NUM_LCD_RST,
|
||||
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
|
||||
.bits_per_pixel = TEST_LCD_BIT_PER_PIXEL,
|
||||
.vendor_config = (void *) &vendor_config,
|
||||
};
|
||||
TEST_ESP_OK(esp_lcd_new_panel_spd2010(io_handle, &panel_config, &panel_handle));
|
||||
esp_lcd_panel_reset(panel_handle);
|
||||
esp_lcd_panel_init(panel_handle);
|
||||
esp_lcd_panel_disp_on_off(panel_handle, true);
|
||||
|
||||
test_draw_bitmap(panel_handle);
|
||||
|
||||
TEST_ESP_OK(esp_lcd_panel_del(panel_handle));
|
||||
TEST_ESP_OK(esp_lcd_panel_io_del(io_handle));
|
||||
TEST_ESP_OK(spi_bus_free(TEST_LCD_HOST));
|
||||
|
||||
#if TEST_PIN_NUM_BK_LIGHT >= 0
|
||||
TEST_ESP_OK(gpio_reset_pin(TEST_PIN_NUM_BK_LIGHT));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Some resources are lazy allocated in the LCD driver, the threadhold is left for that case
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (300)
|
||||
|
||||
static size_t before_free_8bit;
|
||||
static size_t before_free_32bit;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
unity_utils_check_leak(before_free_8bit, after_free_8bit, "8BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||
unity_utils_check_leak(before_free_32bit, after_free_32bit, "32BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
/**
|
||||
* __ ___ ___ ____ ___ _ ___
|
||||
* / _\ / _ \/ \___ \ / _ \/ |/ _ \
|
||||
* \ \ / /_)/ /\ / __) | | | | | | | |
|
||||
* _\ \/ ___/ /_// / __/| |_| | | |_| |
|
||||
* \__/\/ /___,' |_____|\___/|_|\___/
|
||||
*/
|
||||
printf(" __ ___ ___ ____ ___ _ ___\r\n");
|
||||
printf("/ _\\ / _ \\/ \\___ \\ / _ \\/ |/ _ \\\r\n");
|
||||
printf("\\ \\ / /_)/ /\\ / __) | | | | | | | |\r\n");
|
||||
printf("_\\ \\/ ___/ /_// / __/| |_| | | |_| |\r\n");
|
||||
printf("\\__/\\/ /___,' |_____|\\___/|_|\\___/\r\n");
|
||||
unity_run_menu();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
|
||||
@pytest.mark.target('esp32s3')
|
||||
@pytest.mark.env('esp32_s3_lcd_ev_board')
|
||||
def test_usb_stream(dut: Dut)-> None:
|
||||
dut.run_all_single_board_cases()
|
||||
@@ -0,0 +1,10 @@
|
||||
# For IDF 5.0
|
||||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_ESP_TASK_WDT_EN=n
|
||||
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
|
||||
|
||||
# For IDF4.4
|
||||
CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y
|
||||
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
|
||||
CONFIG_ESP_TASK_WDT=n
|
||||
Reference in New Issue
Block a user