add some code

This commit is contained in:
2025-09-05 13:25:11 +08:00
parent 9ff0a99e7a
commit 3cf1229a85
8911 changed files with 2535396 additions and 0 deletions

View File

@@ -0,0 +1 @@
fa88abfc19a312eb5e6f2ffa187e0a9faf67e01e758bfb979d3f9d92561a494f

View File

@@ -0,0 +1,21 @@
# ChangeLog
## v1.0.1 - 2025-01-03
### Modified:
* for the NV3023 LCD controller
## v1.0.0 - 2024-08-12
### Enhancements:
* Component version maintenance, code improvement, and documentation enhancement
## v0.0.1 - 2023-12-01
### Enhancements:
* Implement the driver for the NV3022B LCD controller
* Support SPI interface

View File

@@ -0,0 +1 @@
{"version": "1.0", "algorithm": "sha256", "created_at": "2025-05-21T15:17:53.144291+00:00", "files": [{"path": "CMakeLists.txt", "size": 257, "hash": "695b590f81395824c1e0761201195976471d193cdc99e4c692b5fea2de43edae"}, {"path": "CHANGELOG.md", "size": 332, "hash": "dc7b0a9566a64fd9c4df3ccf458f91c05eacb7ff822202748917b1cc30db643c"}, {"path": "idf_component.yml", "size": 207, "hash": "a38d0e203d54089d056af1c0003c61728a4207b223773b3671e44abe1c5b0a46"}, {"path": "README.md", "size": 3517, "hash": "52a2ef841b3796a61a75c459bc87569449557f10239f6bac65cf2034b7e71dca"}, {"path": "esp_lcd_nv3023.c", "size": 13426, "hash": "91fbfcdd787ed7ea984226ccc114d75acb080845b3a449aae7ce82681da18830"}, {"path": "license.txt", "size": 11358, "hash": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30"}, {"path": "include/esp_lcd_nv3023.h", "size": 3819, "hash": "4945c69da2164fe09e17f293a3b0e027f9cdc1613916ad10a236167b1c7b2038"}]}

View File

@@ -0,0 +1,7 @@
idf_component_register(SRCS "esp_lcd_nv3023.c"
INCLUDE_DIRS "include"
REQUIRES "esp_lcd"
PRIV_REQUIRES "driver")
include(package_manager)
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})

View File

@@ -0,0 +1,78 @@
# ESP LCD NV3023
Modified from [here]().
Implementation of the NV3023 LCD controller with esp_lcd component.
| LCD controller | Communication interface | Component name | Link to datasheet |
| :------------: | :---------------------: | :------------: | :---------------: |
| NV3023 | SPI | esp_lcd_nv3023 | [Specification](https://admin.osptek.com/uploads/NV_3023_A_Datasheet_20191218_73d75e6d84.pdf) |
### Supported Display
- 0.85' TFT 128 x128
-
## Add to project
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).
```
MakerM0/esp_lcd_nv3023:
git: https://github.com/MakerM0/esp_lcd_nv3023.git
```
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).
## Example use
```c
ESP_LOGI(TAG, "Initialize SPI bus");
const spi_bus_config_t bus_config = NV3023_PANEL_BUS_SPI_CONFIG(EXAMPLE_PIN_NUM_LCD_PCLK, EXAMPLE_PIN_NUM_LCD_MOSI,
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 = NV3023_PANEL_IO_SPI_CONFIG(EXAMPLE_PIN_NUM_LCD_CS, EXAMPLE_PIN_NUM_LCD_DC,
example_callback, &example_callback_ctx);
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)EXAMPLE_LCD_HOST, &io_config, &io_handle));
/**
* Uncomment these lines if use custom initialization commands.
* The array should be declared as "static const" and positioned outside the function.
*/
// static const nv3023_lcd_init_cmd_t lcd_init_cmds[] = {
// // {cmd, { data }, data_size, delay_ms}
// {0xFD, (uint8_t []){0x06, 0x08}, 2, 0},
// {0x61, (uint8_t []){0x07, 0x07}, 2, 0},
// {0x73, (uint8_t []){0x70}, 1, 0},
// {0x73, (uint8_t []){0x00}, 1, 0},
// ...
// };
ESP_LOGI(TAG, "Install NV3023 panel driver");
esp_lcd_panel_handle_t panel_handle = NULL;
// nv3023_vendor_config_t vendor_config = { // Uncomment these lines if use custom initialization commands
// .init_cmds = lcd_init_cmds,
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(nv3023_lcd_init_cmd_t),
// };
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST, // Set to -1 if not use
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) // Implemented by LCD command `36h`
.color_space = ESP_LCD_COLOR_SPACE_RGB,
#else
.rgb_endian = LCD_RGB_ENDIAN_RGB,
#endif
.bits_per_pixel = 16, // Implemented by LCD command `3Ah` (12/16/18)
// .vendor_config = &vendor_config, // Uncomment this line if use custom initialization commands
};
ESP_ERROR_CHECK(esp_lcd_new_panel_nv3023(io_handle, &panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
ESP_ERROR_CHECK(esp_lcd_panel_disp_off(panel_handle, false));
#else
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
#endif
```

View File

@@ -0,0 +1,372 @@
/*
* 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 "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 "driver/gpio.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_lcd_nv3023.h"
static const char *TAG = "lcd_panel.nv3023";
static esp_err_t panel_nv3023_del(esp_lcd_panel_t *panel);
static esp_err_t panel_nv3023_reset(esp_lcd_panel_t *panel);
static esp_err_t panel_nv3023_init(esp_lcd_panel_t *panel);
static esp_err_t panel_nv3023_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_nv3023_invert_color(esp_lcd_panel_t *panel, bool invert_color_data);
static esp_err_t panel_nv3023_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y);
static esp_err_t panel_nv3023_swap_xy(esp_lcd_panel_t *panel, bool swap_axes);
static esp_err_t panel_nv3023_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap);
static esp_err_t panel_nv3023_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;
bool reset_level;
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 nv3023_lcd_init_cmd_t *init_cmds;
uint16_t init_cmds_size;
} nv3023_panel_t;
esp_err_t esp_lcd_new_panel_nv3023(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_err_t ret = ESP_OK;
nv3023_panel_t *nv3023 = NULL;
gpio_config_t io_conf = { 0 };
ESP_GOTO_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
nv3023 = (nv3023_panel_t *)calloc(1, sizeof(nv3023_panel_t));
ESP_GOTO_ON_FALSE(nv3023, ESP_ERR_NO_MEM, err, TAG, "no mem for nv3023 panel");
if (panel_dev_config->reset_gpio_num >= 0) {
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.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");
}
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
switch (panel_dev_config->color_space) {
case ESP_LCD_COLOR_SPACE_RGB:
nv3023->madctl_val = 0;
break;
case ESP_LCD_COLOR_SPACE_BGR:
nv3023->madctl_val |= LCD_CMD_BGR_BIT;
break;
default:
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space");
break;
}
#else
switch (panel_dev_config->rgb_endian) {
case LCD_RGB_ENDIAN_RGB:
nv3023->madctl_val = 0;
break;
case LCD_RGB_ENDIAN_BGR:
nv3023->madctl_val |= LCD_CMD_BGR_BIT;
break;
default:
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb endian");
break;
}
#endif
switch (panel_dev_config->bits_per_pixel) {
case 12: // RGB444
nv3023->colmod_val = 0x33;
nv3023->fb_bits_per_pixel = 16;
break;
case 16: // RGB565
nv3023->colmod_val = 0x55;
nv3023->fb_bits_per_pixel = 16;
break;
case 18: // RGB666
nv3023->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
nv3023->fb_bits_per_pixel = 24;
break;
default:
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width");
break;
}
nv3023->io = io;
nv3023->reset_gpio_num = panel_dev_config->reset_gpio_num;
nv3023->reset_level = panel_dev_config->flags.reset_active_high;
if (panel_dev_config->vendor_config) {
nv3023->init_cmds = ((nv3023_vendor_config_t *)panel_dev_config->vendor_config)->init_cmds;
nv3023->init_cmds_size = ((nv3023_vendor_config_t *)panel_dev_config->vendor_config)->init_cmds_size;
}
nv3023->base.del = panel_nv3023_del;
nv3023->base.reset = panel_nv3023_reset;
nv3023->base.init = panel_nv3023_init;
nv3023->base.draw_bitmap = panel_nv3023_draw_bitmap;
nv3023->base.invert_color = panel_nv3023_invert_color;
nv3023->base.set_gap = panel_nv3023_set_gap;
nv3023->base.mirror = panel_nv3023_mirror;
nv3023->base.swap_xy = panel_nv3023_swap_xy;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
nv3023->base.disp_off = panel_nv3023_disp_on_off;
#else
nv3023->base.disp_on_off = panel_nv3023_disp_on_off;
#endif
*ret_panel = &(nv3023->base);
ESP_LOGD(TAG, "new nv3023 panel @%p", nv3023);
ESP_LOGI(TAG, "LCD panel create success, version: %d.%d.%d", ESP_LCD_NV3023_VER_MAJOR, ESP_LCD_NV3023_VER_MINOR,
ESP_LCD_NV3023_VER_PATCH);
return ESP_OK;
err:
if (nv3023) {
if (panel_dev_config->reset_gpio_num >= 0) {
gpio_reset_pin(panel_dev_config->reset_gpio_num);
}
free(nv3023);
}
return ret;
}
static esp_err_t panel_nv3023_del(esp_lcd_panel_t *panel)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
if (nv3023->reset_gpio_num >= 0) {
gpio_reset_pin(nv3023->reset_gpio_num);
}
ESP_LOGD(TAG, "del nv3023 panel @%p", nv3023);
free(nv3023);
return ESP_OK;
}
static esp_err_t panel_nv3023_reset(esp_lcd_panel_t *panel)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
esp_lcd_panel_io_handle_t io = nv3023->io;
// perform hardware reset
if (nv3023->reset_gpio_num >= 0) {
gpio_set_level(nv3023->reset_gpio_num, nv3023->reset_level);
vTaskDelay(pdMS_TO_TICKS(10));
gpio_set_level(nv3023->reset_gpio_num, !nv3023->reset_level);
vTaskDelay(pdMS_TO_TICKS(120));
} else { // perform software reset
esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0);
vTaskDelay(pdMS_TO_TICKS(120));
}
return ESP_OK;
}
// Modified by MakerM0
// Driver: nv3023, 0.85'TFT
static const nv3023_lcd_init_cmd_t vendor_specific_init_default[] = {
// {cmd, { data }, data_size, delay_ms}
{0xff, (uint8_t []){0xa5}, 1, 0},
{0x3e, (uint8_t []){0x09}, 1, 0},
{0x3a, (uint8_t []){0x65}, 1, 0},
{0x82, (uint8_t []){0x00}, 1, 0},
{0x98, (uint8_t []){0x00}, 1, 0},
{0x63, (uint8_t []){0x0f}, 1, 0},
{0x64, (uint8_t []){0x0f}, 1, 0},
{0xb4, (uint8_t []){0x34}, 1, 0},
{0xb5, (uint8_t []){0x30}, 1, 0},
{0x83, (uint8_t []){0x03}, 1, 0},
{0x86, (uint8_t []){0x04}, 1, 0},
{0x87, (uint8_t []){0x16}, 1, 0},
{0x88, (uint8_t []){0x0a}, 1, 0},
{0x89, (uint8_t []){0x27}, 1, 0},
{0x93, (uint8_t []){0x63}, 1, 0},
{0x96, (uint8_t []){0x81}, 1, 0},
{0xc3, (uint8_t []){0x10}, 1, 0},
{0x98, (uint8_t []){0x00}, 1, 0},
{0xe6, (uint8_t []){0x00}, 1, 0},
{0x99, (uint8_t []){0x01}, 1, 0},
{0x70, (uint8_t []){0x09, 0x1d, 0x14, 0x0a, 0x11, 0x16, 0x38, 0x0b, 0x08, 0x3e, 0x07, 0x0d, 0x16, 0x0F,0x14,0x05}, 16, 0},
{0xa0, (uint8_t []){0x04, 0x28, 0x0c, 0x11, 0x0b, 0x23, 0x45, 0x07, 0x0a, 0x3b, 0x0d, 0x18, 0x14, 0x0F,0x19,0x08}, 16, 0},
{0xff, (uint8_t []){0x00}, 1, 0},
{0x11, (uint8_t []){0x00}, 0, 200},
// {0x36, (uint8_t []){0x88}, 1, 0},
// {0x2a, (uint8_t []){0x00, 0x00, 0x00, 0xef}, 4, 0},
// {0x2b, (uint8_t []){0x00, 0x00, 0x01, 0x1b}, 4, 0},
{0x29, (uint8_t []){0}, 0, 10},
{0x2c, (uint8_t []){0}, 0, 0},
};
static esp_err_t panel_nv3023_init(esp_lcd_panel_t *panel)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
esp_lcd_panel_io_handle_t io = nv3023->io;
// LCD goes into sleep mode and display will be turned off after power on reset, exit sleep mode first
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT, NULL, 0), TAG, "send command failed");
vTaskDelay(pdMS_TO_TICKS(100));
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) {
nv3023->madctl_val,
}, 1), TAG, "send command failed");
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD, (uint8_t[]) {
nv3023->colmod_val,
}, 1), TAG, "send command failed");
const nv3023_lcd_init_cmd_t *init_cmds = NULL;
uint16_t init_cmds_size = 0;
if (nv3023->init_cmds) {
init_cmds = nv3023->init_cmds;
init_cmds_size = nv3023->init_cmds_size;
} else {
init_cmds = vendor_specific_init_default;
init_cmds_size = sizeof(vendor_specific_init_default) / sizeof(nv3023_lcd_init_cmd_t);
}
bool is_cmd_overwritten = false;
for (int i = 0; i < init_cmds_size; i++) {
// Check if the command has been used or conflicts with the internal
switch (init_cmds[i].cmd) {
case LCD_CMD_MADCTL:
is_cmd_overwritten = true;
nv3023->madctl_val = ((uint8_t *)init_cmds[i].data)[0];
break;
case LCD_CMD_COLMOD:
is_cmd_overwritten = true;
nv3023->colmod_val = ((uint8_t *)init_cmds[i].data)[0];
break;
default:
is_cmd_overwritten = false;
break;
}
if (is_cmd_overwritten) {
ESP_LOGW(TAG, "The %02Xh command has been used and will be overwritten by external initialization sequence", init_cmds[i].cmd);
}
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(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));
}
ESP_LOGD(TAG, "send init commands success");
return ESP_OK;
}
static esp_err_t panel_nv3023_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_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 = nv3023->io;
x_start += nv3023->x_gap;
x_end += nv3023->x_gap;
y_start += nv3023->y_gap;
y_end += nv3023->y_gap;
// define an area of frame memory where MCU can access
esp_lcd_panel_io_tx_param(io, LCD_CMD_CASET, (uint8_t[]) {
(x_start >> 8) & 0xFF,
x_start & 0xFF,
((x_end - 1) >> 8) & 0xFF,
(x_end - 1) & 0xFF,
}, 4);
esp_lcd_panel_io_tx_param(io, LCD_CMD_RASET, (uint8_t[]) {
(y_start >> 8) & 0xFF,
y_start & 0xFF,
((y_end - 1) >> 8) & 0xFF,
(y_end - 1) & 0xFF,
}, 4);
// transfer frame buffer
size_t len = (x_end - x_start) * (y_end - y_start) * nv3023->fb_bits_per_pixel / 8;
esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, len);
return ESP_OK;
}
static esp_err_t panel_nv3023_invert_color(esp_lcd_panel_t *panel, bool invert_color_data)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
esp_lcd_panel_io_handle_t io = nv3023->io;
int command = 0;
if (invert_color_data) {
command = LCD_CMD_INVON;
} else {
command = LCD_CMD_INVOFF;
}
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed");
return ESP_OK;
}
static esp_err_t panel_nv3023_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
esp_lcd_panel_io_handle_t io = nv3023->io;
if (mirror_x) {
nv3023->madctl_val |= LCD_CMD_MX_BIT;
} else {
nv3023->madctl_val &= ~LCD_CMD_MX_BIT;
}
if (mirror_y) {
nv3023->madctl_val |= LCD_CMD_MY_BIT;
} else {
nv3023->madctl_val &= ~LCD_CMD_MY_BIT;
}
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) {
nv3023->madctl_val
}, 1), TAG, "send command failed");
return ESP_OK;
}
static esp_err_t panel_nv3023_swap_xy(esp_lcd_panel_t *panel, bool swap_axes)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
esp_lcd_panel_io_handle_t io = nv3023->io;
if (swap_axes) {
nv3023->madctl_val |= LCD_CMD_MV_BIT;
} else {
nv3023->madctl_val &= ~LCD_CMD_MV_BIT;
}
esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) {
nv3023->madctl_val
}, 1);
return ESP_OK;
}
static esp_err_t panel_nv3023_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
nv3023->x_gap = x_gap;
nv3023->y_gap = y_gap;
return ESP_OK;
}
static esp_err_t panel_nv3023_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
{
nv3023_panel_t *nv3023 = __containerof(panel, nv3023_panel_t, base);
esp_lcd_panel_io_handle_t io = nv3023->io;
int command = 0;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
on_off = !on_off;
#endif
if (on_off) {
command = LCD_CMD_DISPON;
} else {
command = LCD_CMD_DISPOFF;
}
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed");
return ESP_OK;
}

View File

@@ -0,0 +1,7 @@
dependencies:
cmake_utilities: 0.*
idf: '>=4.4'
description: ESP LCD NV3023(SPI)
repository: git://github.com/MakerM0/esp_lcd_nv3023.git
url: https://github.com/MakerM0/esp_lcd_nv3023.git
version: 1.0.0

View File

@@ -0,0 +1,96 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#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 */
} nv3023_lcd_init_cmd_t;
/**
* @brief LCD panel vendor configuration.
*
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
*
*/
typedef struct {
const nv3023_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
* 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 */
} nv3023_vendor_config_t;
/**
* @brief Create LCD panel for model nv3023
*
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
*
* @param[in] io LCD panel IO handle
* @param[in] panel_dev_config general panel device configuration
* @param[out] ret_panel Returned LCD panel handle
* @return
* - ESP_ERR_INVALID_ARG if parameter is invalid
* - ESP_ERR_NO_MEM if out of memory
* - ESP_OK on success
*/
esp_err_t esp_lcd_new_panel_nv3023(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
*
* @param[in] sclk SPI clock pin number
* @param[in] mosi SPI MOSI pin number
* @param[in] max_trans_sz Maximum transfer size in bytes
*
*/
#define NV3023_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, \
}
/**
* @brief LCD panel IO configuration structure
*
* @param[in] cs SPI chip select pin number
* @param[in] dc SPI data/command pin number
* @param[in] cb Callback function when SPI transfer is done
* @param[in] cb_ctx Callback function context
*
*/
#define NV3023_PANEL_IO_SPI_CONFIG(cs, dc, callback, callback_ctx) \
{ \
.cs_gpio_num = cs, \
.dc_gpio_num = dc, \
.spi_mode = 0, \
.pclk_hz = 40 * 1000 * 1000, \
.trans_queue_depth = 10, \
.on_color_trans_done = callback, \
.user_ctx = callback_ctx, \
.lcd_cmd_bits = 8, \
.lcd_param_bits = 8, \
}
#ifdef __cplusplus
}
#endif

View 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.