Snapshot of JC3636W518EN kit before demo folder cleanup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
9ee85bfd86
1862 files changed
+668877
No files matched your search
+235
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* | Supported ESP SoCs | ESP32-S3 |
|
||||
* | ------------------ | -------- |
|
||||
*
|
||||
* | Supported LCD Controllers | GC9503 | ST7701 |
|
||||
* | ------------------------- | ------ | ------ |
|
||||
*
|
||||
* # 3-wire SPI + RGB LCD Example
|
||||
*
|
||||
* The example demonstrates how to develop different model LCDs with "3-wire SPI + RGB" interface using standalone drivers and test them by displaying color bars.
|
||||
*
|
||||
* ## How to use
|
||||
*
|
||||
* 1. [Configure drivers](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-drivers) if needed.
|
||||
* 2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-supported-development-boards)
|
||||
* 4. Verify and upload the example to your ESP board.
|
||||
*
|
||||
* ## Serial Output
|
||||
*
|
||||
* ```
|
||||
* ...
|
||||
* 3-wire SPI + RGB LCD example start
|
||||
* Initialize backlight and turn it off
|
||||
* Create 3-wire SPI + RGB LCD bus
|
||||
* Create LCD device
|
||||
* Draw color bar from top left to bottom right, the order is B - G - R
|
||||
* Turn on the backlight
|
||||
* 3-wire SPI + RGB LCD example end
|
||||
* RGB refresh rate: 0
|
||||
* RGB refresh rate: 60
|
||||
* RGB refresh rate: 60
|
||||
* RGB refresh rate: 60
|
||||
* ...
|
||||
* ```
|
||||
*
|
||||
* ## Troubleshooting
|
||||
*
|
||||
* Please check the [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP_Panel_Library.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Currently, the library supports the following "3-wire SPI + RGB" LCDs:
|
||||
* - GC9503
|
||||
* - ST7701
|
||||
*/
|
||||
#define EXAMPLE_LCD_NAME ST7701
|
||||
#define EXAMPLE_LCD_WIDTH (480)
|
||||
#define EXAMPLE_LCD_HEIGHT (480)
|
||||
#define EXAMPLE_LCD_COLOR_BITS (18)
|
||||
#define EXAMPLE_LCD_RGB_DATA_WIDTH (16)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_FREQ_HZ (16 * 1000 * 1000)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_HPW (10)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_HBP (10)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_HFP (20)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_VPW (10)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_VBP (10)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_VFP (10)
|
||||
/**
|
||||
* LCD initialization commands.
|
||||
*
|
||||
* Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for
|
||||
* initialization sequence code.
|
||||
*
|
||||
* Please uncomment and change the following macro definitions, then use `configVendorCommands()` to pass them in the
|
||||
* same format if needed. Otherwise, the LCD driver will use the default initialization sequence code.
|
||||
*
|
||||
* There are two formats for the sequence code:
|
||||
* 1. Raw data: {command, (uint8_t []){ data0, data1, ... }, data_size, delay_ms}
|
||||
* 2. Formater: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... }) and
|
||||
* ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command)
|
||||
*/
|
||||
// const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
|
||||
// {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
|
||||
// {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0},
|
||||
// {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0},
|
||||
// {0x29, (uint8_t []){0x00}, 0, 120},
|
||||
// // or
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29),
|
||||
// };
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your board spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DISP (-1)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_VSYNC (17)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_HSYNC (16)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DE (18)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_PCLK (21)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA0 (4)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA1 (5)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA2 (6)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA3 (7)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA4 (15)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA5 (8)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA6 (20)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA7 (3)
|
||||
#if EXAMPLE_LCD_RGB_DATA_WIDTH > 8
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA8 (46)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA9 (9)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA10 (10)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA11 (11)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA12 (12)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA13 (13)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA14 (14)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA15 (0)
|
||||
#endif
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_CS (39)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_SCK (48)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_SDA (47)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RST (-1)
|
||||
#define EXAMPLE_LCD_PIN_NUM_BK_LIGHT (38)
|
||||
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL (1)
|
||||
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||
|
||||
/* Enable or disable printing RGB refresh rate */
|
||||
#define EXAMPLE_ENABLE_PRINT_LCD_FPS (1)
|
||||
|
||||
#define _EXAMPLE_LCD_CLASS(name, ...) ESP_PanelLcd_##name(__VA_ARGS__)
|
||||
#define EXAMPLE_LCD_CLASS(name, ...) _EXAMPLE_LCD_CLASS(name, ##__VA_ARGS__)
|
||||
|
||||
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
|
||||
#define EXAMPLE_LCD_FPS_COUNT_MAX (100)
|
||||
|
||||
DRAM_ATTR int frame_count = 0;
|
||||
DRAM_ATTR int fps = 0;
|
||||
DRAM_ATTR long start_time = 0;
|
||||
|
||||
IRAM_ATTR bool onVsyncEndCallback(void *user_data)
|
||||
{
|
||||
long frame_start_time = *(long *)user_data;
|
||||
if (frame_start_time == 0) {
|
||||
(*(long *)user_data) = millis();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
frame_count++;
|
||||
if (frame_count >= EXAMPLE_LCD_FPS_COUNT_MAX) {
|
||||
fps = EXAMPLE_LCD_FPS_COUNT_MAX * 1000 / (millis() - frame_start_time);
|
||||
frame_count = 0;
|
||||
(*(long *)user_data) = millis();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("3-wire SPI + RGB LCD example start");
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Initialize backlight and turn it off");
|
||||
ESP_PanelBacklight *backlight = new ESP_PanelBacklight(EXAMPLE_LCD_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL, true);
|
||||
backlight->begin();
|
||||
backlight->off();
|
||||
#endif
|
||||
|
||||
Serial.println("Create 3-wire SPI + RGB LCD bus");
|
||||
#if EXAMPLE_LCD_RGB_DATA_WIDTH == 8
|
||||
ESP_PanelBus_RGB *lcd_bus = new ESP_PanelBus_RGB(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_CS, EXAMPLE_LCD_PIN_NUM_SPI_SCK,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_SDA,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA0, EXAMPLE_LCD_PIN_NUM_RGB_DATA1,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA2, EXAMPLE_LCD_PIN_NUM_RGB_DATA3,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA4, EXAMPLE_LCD_PIN_NUM_RGB_DATA5,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA6, EXAMPLE_LCD_PIN_NUM_RGB_DATA7,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_HSYNC, EXAMPLE_LCD_PIN_NUM_RGB_VSYNC,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_PCLK, EXAMPLE_LCD_PIN_NUM_RGB_DE,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DISP);
|
||||
#elif EXAMPLE_LCD_RGB_DATA_WIDTH == 16
|
||||
ESP_PanelBus_RGB *lcd_bus = new ESP_PanelBus_RGB(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_CS, EXAMPLE_LCD_PIN_NUM_SPI_SCK,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_SDA,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA0, EXAMPLE_LCD_PIN_NUM_RGB_DATA1,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA2, EXAMPLE_LCD_PIN_NUM_RGB_DATA3,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA4, EXAMPLE_LCD_PIN_NUM_RGB_DATA5,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA6, EXAMPLE_LCD_PIN_NUM_RGB_DATA7,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA8, EXAMPLE_LCD_PIN_NUM_RGB_DATA9,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA10, EXAMPLE_LCD_PIN_NUM_RGB_DATA11,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA12, EXAMPLE_LCD_PIN_NUM_RGB_DATA13,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA14, EXAMPLE_LCD_PIN_NUM_RGB_DATA15,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_HSYNC, EXAMPLE_LCD_PIN_NUM_RGB_VSYNC,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_PCLK, EXAMPLE_LCD_PIN_NUM_RGB_DE,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DISP);
|
||||
#endif
|
||||
lcd_bus->configRgbTimingFreqHz(EXAMPLE_LCD_RGB_TIMING_FREQ_HZ);
|
||||
lcd_bus->configRgbTimingPorch(EXAMPLE_LCD_RGB_TIMING_HPW, EXAMPLE_LCD_RGB_TIMING_HBP, EXAMPLE_LCD_RGB_TIMING_HFP,
|
||||
EXAMPLE_LCD_RGB_TIMING_VPW, EXAMPLE_LCD_RGB_TIMING_VBP, EXAMPLE_LCD_RGB_TIMING_VFP);
|
||||
// lcd_bus->configRgbBounceBufferSize(EXAMPLE_LCD_WIDTH * 10); // Set bounce buffer to avoid screen drift
|
||||
lcd_bus->begin();
|
||||
|
||||
Serial.println("Create LCD device");
|
||||
ESP_PanelLcd *lcd = new EXAMPLE_LCD_CLASS(EXAMPLE_LCD_NAME, lcd_bus, EXAMPLE_LCD_COLOR_BITS, EXAMPLE_LCD_PIN_NUM_RST);
|
||||
// lcd->configVendorCommands(lcd_init_cmd, sizeof(lcd_init_cmd)/sizeof(lcd_init_cmd[0]));
|
||||
lcd->init();
|
||||
lcd->reset();
|
||||
lcd->begin();
|
||||
lcd->displayOn();
|
||||
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
|
||||
lcd->attachRefreshFinishCallback(onVsyncEndCallback, (void *)&start_time);
|
||||
#endif
|
||||
|
||||
Serial.println("Draw color bar from top left to bottom right, the order is B - G - R");
|
||||
lcd->colorBarTest(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT);
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Turn on the backlight");
|
||||
backlight->on();
|
||||
#endif
|
||||
|
||||
Serial.println("3-wire SPI + RGB LCD example end");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(1000);
|
||||
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
|
||||
Serial.println("RGB refresh rate: " + String(fps));
|
||||
#else
|
||||
Serial.println("IDLE loop");
|
||||
#endif
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////// Debug Configurations /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Set to 1 if assert on error. Otherwise print error message */
|
||||
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1
|
||||
|
||||
/* Set to 1 if print log message for debug */
|
||||
#define ESP_PANEL_ENABLE_LOG (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////// Touch Driver Configurations //////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Maximum point number */
|
||||
#define ESP_PANEL_TOUCH_MAX_POINTS (5)
|
||||
/* Maximum button number */
|
||||
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)
|
||||
|
||||
/**
|
||||
* XPT2046 related
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
|
||||
/**
|
||||
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
|
||||
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
|
||||
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
|
||||
/**
|
||||
* Keep internal Vref enabled.
|
||||
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
|
||||
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
|
||||
/**
|
||||
* Convert touch coordinates to screen coordinates.
|
||||
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
|
||||
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
|
||||
* screen coordinate.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
|
||||
/**
|
||||
* Enable data structure locking.
|
||||
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
|
||||
* XPT2046 and when reading position data via API.
|
||||
* WARNING: enabling this option may result in unintended crashes.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
|
||||
* the current version of `ESP_Panel_Board_Custom.h` in the library. The detailed rules are as follows:
|
||||
*
|
||||
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
|
||||
* and must be replaced with the file from the library.
|
||||
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
|
||||
* default values. It is recommended to replace it with the file from the library.
|
||||
* 3. Even if the patch version is not consistent, it will not affect normal functionality.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MAJOR 0
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MINOR 1
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_PATCH 1
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
| Supported ESP SoCs | ESP32-S3 |
|
||||
| ------------------ | -------- |
|
||||
|
||||
| Supported LCD Controllers | GC9503 | ST7701 |
|
||||
| ------------------------- | ------ | ------ |
|
||||
|
||||
# 3-wire SPI + RGB LCD Example
|
||||
|
||||
The example demonstrates how to develop different model LCDs with "3-wire SPI + RGB" interface using standalone drivers and test them by displaying color bars.
|
||||
|
||||
## How to use
|
||||
|
||||
1. [Configure drivers](../../../README.md#configuring-drivers) if needed.
|
||||
2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](../../../README.md#configuring-supported-development-boards)
|
||||
4. Verify and upload the example to your ESP board.
|
||||
|
||||
## Serial Output
|
||||
|
||||
```
|
||||
...
|
||||
3-wire SPI + RGB LCD example start
|
||||
Initialize backlight and turn it off
|
||||
Create 3-wire SPI + RGB LCD bus
|
||||
Create LCD device
|
||||
Draw color bar from top left to bottom right, the order is B - G - R
|
||||
Turn on the backlight
|
||||
3-wire SPI + RGB LCD example end
|
||||
RGB refresh rate: 0
|
||||
RGB refresh rate: 60
|
||||
RGB refresh rate: 60
|
||||
RGB refresh rate: 60
|
||||
...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please check the [FAQ](../../../README.md#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////// Debug Configurations /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Set to 1 if assert on error. Otherwise print error message */
|
||||
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1
|
||||
|
||||
/* Set to 1 if print log message for debug */
|
||||
#define ESP_PANEL_ENABLE_LOG (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////// Touch Driver Configurations //////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Maximum point number */
|
||||
#define ESP_PANEL_TOUCH_MAX_POINTS (5)
|
||||
/* Maximum button number */
|
||||
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)
|
||||
|
||||
/**
|
||||
* XPT2046 related
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
|
||||
/**
|
||||
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
|
||||
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
|
||||
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
|
||||
/**
|
||||
* Keep internal Vref enabled.
|
||||
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
|
||||
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
|
||||
/**
|
||||
* Convert touch coordinates to screen coordinates.
|
||||
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
|
||||
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
|
||||
* screen coordinate.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
|
||||
/**
|
||||
* Enable data structure locking.
|
||||
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
|
||||
* XPT2046 and when reading position data via API.
|
||||
* WARNING: enabling this option may result in unintended crashes.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
|
||||
* the current version of `ESP_Panel_Board_Custom.h` in the library. The detailed rules are as follows:
|
||||
*
|
||||
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
|
||||
* and must be replaced with the file from the library.
|
||||
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
|
||||
* default values. It is recommended to replace it with the file from the library.
|
||||
* 3. Even if the patch version is not consistent, it will not affect normal functionality.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MAJOR 0
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MINOR 1
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_PATCH 1
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
* | Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
* | ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
*
|
||||
* | Supported LCD Controllers | GC9B71 | SH8601 | SPD2010 | ST77916 | ST77922 |
|
||||
* | ------------------------- | ------ | ------ | ------- | ------- | ------- |
|
||||
*
|
||||
* # QSPI LCD Example
|
||||
*
|
||||
* The example demonstrates how to develop different model LCDs with QSPI interface using standalone drivers and test them by displaying color bars.
|
||||
*
|
||||
* ## How to use
|
||||
*
|
||||
* 1. [Configure drivers](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-drivers) if needed.
|
||||
* 2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-supported-development-boards)
|
||||
* 4. Verify and upload the example to your ESP board.
|
||||
*
|
||||
* ## Serial Output
|
||||
*
|
||||
* ```
|
||||
* ...
|
||||
* QSPI LCD example start
|
||||
* Create QSPI LCD bus
|
||||
* Create LCD device
|
||||
* Draw color bar from top left to bottom right, the order is B - G - R
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* QSPI LCD example end
|
||||
* IDLE loop
|
||||
* IDLE loop
|
||||
* IDLE loop
|
||||
* ...
|
||||
* ```
|
||||
*
|
||||
* ## Troubleshooting
|
||||
*
|
||||
* Please check the [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP_Panel_Library.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Currently, the library supports the following SPI LCDs:
|
||||
* - GC9B71
|
||||
* - SH8601
|
||||
* - SPD2010
|
||||
* - ST77916, ST77922
|
||||
*/
|
||||
#define EXAMPLE_LCD_NAME ST77922
|
||||
#define EXAMPLE_LCD_WIDTH (532)
|
||||
#define EXAMPLE_LCD_HEIGHT (300)
|
||||
#define EXAMPLE_LCD_COLOR_BITS (16)
|
||||
#define EXAMPLE_LCD_SPI_FREQ_HZ (40 * 1000 * 1000)
|
||||
/**
|
||||
* LCD initialization commands.
|
||||
*
|
||||
* Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for
|
||||
* initialization sequence code.
|
||||
*
|
||||
* Please uncomment and change the following macro definitions, then use `configVendorCommands()` to pass them in the
|
||||
* same format if needed. Otherwise, the LCD driver will use the default initialization sequence code.
|
||||
*
|
||||
* There are two formats for the sequence code:
|
||||
* 1. Raw data: {command, (uint8_t []){ data0, data1, ... }, data_size, delay_ms}
|
||||
* 2. Formater: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... }) and
|
||||
* ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command)
|
||||
*/
|
||||
// const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
|
||||
// {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
|
||||
// {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0},
|
||||
// {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0},
|
||||
// {0x29, (uint8_t []){0x00}, 0, 120},
|
||||
// // or
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29),
|
||||
// };
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your board spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_CS (9)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_SCK (10)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_DATA0 (11)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_DATA1 (12)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_DATA2 (13)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_DATA3 (14)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RST (3)
|
||||
#define EXAMPLE_LCD_PIN_NUM_BK_LIGHT (-1)
|
||||
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL (1)
|
||||
|
||||
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||
|
||||
/* Enable or disable the attachment of a callback function that is called after each bitmap drawing is completed */
|
||||
#define EXAMPLE_ENABLE_ATTACH_CALLBACK (1)
|
||||
|
||||
#define _EXAMPLE_LCD_CLASS(name, ...) ESP_PanelLcd_##name(__VA_ARGS__)
|
||||
#define EXAMPLE_LCD_CLASS(name, ...) _EXAMPLE_LCD_CLASS(name, ##__VA_ARGS__)
|
||||
|
||||
#if EXAMPLE_ENABLE_ATTACH_CALLBACK
|
||||
IRAM_ATTR bool onDrawBitmapFinishCallback(void *user_data)
|
||||
{
|
||||
esp_rom_printf("Draw bitmap finish callback\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("QSPI LCD example start");
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Initialize backlight control pin and turn it off");
|
||||
ESP_PanelBacklight *backlight = new ESP_PanelBacklight(EXAMPLE_LCD_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL, true);
|
||||
backlight->begin();
|
||||
backlight->off();
|
||||
#endif
|
||||
|
||||
Serial.println("Create QSPI LCD bus");
|
||||
ESP_PanelBus_QSPI *panel_bus = new ESP_PanelBus_QSPI(EXAMPLE_LCD_PIN_NUM_SPI_CS, EXAMPLE_LCD_PIN_NUM_SPI_SCK,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_DATA0, EXAMPLE_LCD_PIN_NUM_SPI_DATA1,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_DATA2, EXAMPLE_LCD_PIN_NUM_SPI_DATA3);
|
||||
panel_bus->configQspiFreqHz(EXAMPLE_LCD_SPI_FREQ_HZ);
|
||||
panel_bus->begin();
|
||||
|
||||
Serial.println("Create LCD device");
|
||||
ESP_PanelLcd *lcd = new EXAMPLE_LCD_CLASS(EXAMPLE_LCD_NAME, panel_bus, EXAMPLE_LCD_COLOR_BITS, EXAMPLE_LCD_PIN_NUM_RST);
|
||||
lcd->init();
|
||||
lcd->reset();
|
||||
// lcd->configVendorCommands(lcd_init_cmd, sizeof(lcd_init_cmd)/sizeof(lcd_init_cmd[0]));
|
||||
lcd->begin();
|
||||
lcd->displayOn();
|
||||
#if EXAMPLE_ENABLE_ATTACH_CALLBACK
|
||||
lcd->attachRefreshFinishCallback(onDrawBitmapFinishCallback, NULL);
|
||||
#endif
|
||||
|
||||
Serial.println("Draw color bar from top left to bottom right, the order is B - G - R");
|
||||
lcd->colorBarTest(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT);
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Turn on the backlight");
|
||||
backlight->on();
|
||||
#endif
|
||||
|
||||
Serial.println("QSPI LCD example end");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(1000);
|
||||
Serial.println("IDLE loop");
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
| Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
| ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
|
||||
| Supported LCD Controllers | GC9B71 | SH8601 | SPD2010 | ST77916 | ST77922 |
|
||||
| ------------------------- | ------ | ------ | ------- | ------- | ------- |
|
||||
|
||||
# QSPI LCD Example
|
||||
|
||||
The example demonstrates how to develop different model LCDs with QSPI interface using standalone drivers and test them by displaying color bars.
|
||||
|
||||
## How to use
|
||||
|
||||
1. [Configure drivers](../../../README.md#configuring-drivers) if needed.
|
||||
2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](../../../README.md#configuring-supported-development-boards)
|
||||
4. Verify and upload the example to your ESP board.
|
||||
|
||||
## Serial Output
|
||||
|
||||
```
|
||||
...
|
||||
QSPI LCD example start
|
||||
Create QSPI LCD bus
|
||||
Create LCD device
|
||||
Draw color bar from top left to bottom right, the order is B - G - R
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
QSPI LCD example end
|
||||
IDLE loop
|
||||
IDLE loop
|
||||
IDLE loop
|
||||
...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please check the [FAQ](../../../README.md#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////// Debug Configurations /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Set to 1 if assert on error. Otherwise print error message */
|
||||
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1
|
||||
|
||||
/* Set to 1 if print log message for debug */
|
||||
#define ESP_PANEL_ENABLE_LOG (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////// Touch Driver Configurations //////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Maximum point number */
|
||||
#define ESP_PANEL_TOUCH_MAX_POINTS (5)
|
||||
/* Maximum button number */
|
||||
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)
|
||||
|
||||
/**
|
||||
* XPT2046 related
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
|
||||
/**
|
||||
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
|
||||
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
|
||||
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
|
||||
/**
|
||||
* Keep internal Vref enabled.
|
||||
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
|
||||
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
|
||||
/**
|
||||
* Convert touch coordinates to screen coordinates.
|
||||
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
|
||||
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
|
||||
* screen coordinate.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
|
||||
/**
|
||||
* Enable data structure locking.
|
||||
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
|
||||
* XPT2046 and when reading position data via API.
|
||||
* WARNING: enabling this option may result in unintended crashes.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
|
||||
* the current version of `ESP_Panel_Board_Custom.h` in the library. The detailed rules are as follows:
|
||||
*
|
||||
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
|
||||
* and must be replaced with the file from the library.
|
||||
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
|
||||
* default values. It is recommended to replace it with the file from the library.
|
||||
* 3. Even if the patch version is not consistent, it will not affect normal functionality.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MAJOR 0
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MINOR 1
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_PATCH 1
|
||||
@@ -0,0 +1,36 @@
|
||||
| Supported ESP SoCs | ESP32-S3 |
|
||||
| ------------------ | -------- |
|
||||
|
||||
| Supported LCD Controllers | ST7262 |
|
||||
| ------------------------- | ------ |
|
||||
|
||||
# Single RGB LCD Example
|
||||
|
||||
The example demonstrates how to develop different model LCDs with RGB (without 3-wire SPI) interface using standalone drivers and test them by displaying color bars.
|
||||
|
||||
## How to use
|
||||
|
||||
1. [Configure drivers](../../../README.md#configuring-drivers) if needed.
|
||||
2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](../../../README.md#configuring-supported-development-boards)
|
||||
4. Verify and upload the example to your ESP board.
|
||||
|
||||
## Serial Output
|
||||
|
||||
```
|
||||
...
|
||||
RGB LCD example start
|
||||
Create RGB LCD bus
|
||||
Create LCD device
|
||||
Draw color bar from top left to bottom right, the order is B - G - R
|
||||
RGB LCD example end
|
||||
RGB refresh rate: 0
|
||||
RGB refresh rate: 0
|
||||
RGB refresh rate: 31
|
||||
RGB refresh rate: 31
|
||||
...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please check the [FAQ](../../../README.md#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* | Supported ESP SoCs | ESP32-S3 |
|
||||
* | ------------------ | -------- |
|
||||
*
|
||||
* | Supported LCD Controllers | ST7262 |
|
||||
* | ------------------------- | ------ |
|
||||
*
|
||||
* # Single RGB LCD Example
|
||||
*
|
||||
* The example demonstrates how to develop different model LCDs with RGB (without 3-wire SPI) interface using standalone drivers and test them by displaying color bars.
|
||||
*
|
||||
* ## How to use
|
||||
*
|
||||
* 1. [Configure drivers](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-drivers) if needed.
|
||||
* 2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-supported-development-boards)
|
||||
* 4. Verify and upload the example to your ESP board.
|
||||
*
|
||||
* ## Serial Output
|
||||
*
|
||||
* ```
|
||||
* ...
|
||||
* RGB LCD example start
|
||||
* Create RGB LCD bus
|
||||
* Create LCD device
|
||||
* Draw color bar from top left to bottom right, the order is B - G - R
|
||||
* RGB LCD example end
|
||||
* RGB refresh rate: 0
|
||||
* RGB refresh rate: 0
|
||||
* RGB refresh rate: 31
|
||||
* RGB refresh rate: 31
|
||||
* ...
|
||||
* ```
|
||||
*
|
||||
* ## Troubleshooting
|
||||
*
|
||||
* Please check the [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP_Panel_Library.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Currently, the library supports the following RGB (without 3-wire SPI) LCDs:
|
||||
* - ST7262
|
||||
*/
|
||||
#define EXAMPLE_LCD_NAME ST7262
|
||||
#define EXAMPLE_LCD_WIDTH (800)
|
||||
#define EXAMPLE_LCD_HEIGHT (480)
|
||||
#define EXAMPLE_LCD_COLOR_BITS (24)
|
||||
#define EXAMPLE_LCD_RGB_DATA_WIDTH (16)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_FREQ_HZ (16 * 1000 * 1000)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_HPW (40)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_HBP (40)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_HFP (48)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_VPW (23)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_VBP (32)
|
||||
#define EXAMPLE_LCD_RGB_TIMING_VFP (13)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your board spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DISP (-1)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_VSYNC (3)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_HSYNC (46)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DE (17)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_PCLK (9)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA0 (10)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA1 (11)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA2 (12)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA3 (13)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA4 (14)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA5 (21)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA6 (47)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA7 (48)
|
||||
#if EXAMPLE_LCD_RGB_DATA_WIDTH > 8
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA8 (45)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA9 (38)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA10 (39)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA11 (40)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA12 (41)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA13 (42)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA14 (2)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA15 (1)
|
||||
#endif
|
||||
#define EXAMPLE_LCD_PIN_NUM_RST (-1)
|
||||
#define EXAMPLE_LCD_PIN_NUM_BK_LIGHT (-1)
|
||||
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL (1)
|
||||
|
||||
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||
|
||||
/* Enable or disable printing RGB refresh rate */
|
||||
#define EXAMPLE_ENABLE_PRINT_LCD_FPS (1)
|
||||
|
||||
#define _EXAMPLE_LCD_CLASS(name, ...) ESP_PanelLcd_##name(__VA_ARGS__)
|
||||
#define EXAMPLE_LCD_CLASS(name, ...) _EXAMPLE_LCD_CLASS(name, ##__VA_ARGS__)
|
||||
|
||||
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
|
||||
#define EXAMPLE_LCD_FPS_COUNT_MAX (100)
|
||||
|
||||
DRAM_ATTR int frame_count = 0;
|
||||
DRAM_ATTR int fps = 0;
|
||||
DRAM_ATTR long start_time = 0;
|
||||
|
||||
IRAM_ATTR bool onVsyncEndCallback(void *user_data)
|
||||
{
|
||||
long frame_start_time = *(long *)user_data;
|
||||
if (frame_start_time == 0) {
|
||||
(*(long *)user_data) = millis();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
frame_count++;
|
||||
if (frame_count >= EXAMPLE_LCD_FPS_COUNT_MAX) {
|
||||
fps = EXAMPLE_LCD_FPS_COUNT_MAX * 1000 / (millis() - frame_start_time);
|
||||
frame_count = 0;
|
||||
(*(long *)user_data) = millis();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("RGB LCD example start");
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Initialize backlight control pin and turn it off");
|
||||
ESP_PanelBacklight *backlight = new ESP_PanelBacklight(EXAMPLE_LCD_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL, true);
|
||||
backlight->begin();
|
||||
backlight->off();
|
||||
#endif
|
||||
|
||||
Serial.println("Create RGB LCD bus");
|
||||
#if EXAMPLE_LCD_RGB_DATA_WIDTH == 8
|
||||
ESP_PanelBus_RGB *panel_bus = new ESP_PanelBus_RGB(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA0, EXAMPLE_LCD_PIN_NUM_RGB_DATA1,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA2, EXAMPLE_LCD_PIN_NUM_RGB_DATA3,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA4, EXAMPLE_LCD_PIN_NUM_RGB_DATA5,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA6, EXAMPLE_LCD_PIN_NUM_RGB_DATA7,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_HSYNC, EXAMPLE_LCD_PIN_NUM_RGB_VSYNC,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_PCLK, EXAMPLE_LCD_PIN_NUM_RGB_DE,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DISP);
|
||||
#elif EXAMPLE_LCD_RGB_DATA_WIDTH == 16
|
||||
ESP_PanelBus_RGB *panel_bus = new ESP_PanelBus_RGB(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA0, EXAMPLE_LCD_PIN_NUM_RGB_DATA1,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA2, EXAMPLE_LCD_PIN_NUM_RGB_DATA3,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA4, EXAMPLE_LCD_PIN_NUM_RGB_DATA5,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA6, EXAMPLE_LCD_PIN_NUM_RGB_DATA7,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA8, EXAMPLE_LCD_PIN_NUM_RGB_DATA9,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA10, EXAMPLE_LCD_PIN_NUM_RGB_DATA11,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA12, EXAMPLE_LCD_PIN_NUM_RGB_DATA13,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DATA14, EXAMPLE_LCD_PIN_NUM_RGB_DATA15,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_HSYNC, EXAMPLE_LCD_PIN_NUM_RGB_VSYNC,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_PCLK, EXAMPLE_LCD_PIN_NUM_RGB_DE,
|
||||
EXAMPLE_LCD_PIN_NUM_RGB_DISP);
|
||||
#endif
|
||||
panel_bus->configRgbTimingFreqHz(EXAMPLE_LCD_RGB_TIMING_FREQ_HZ);
|
||||
panel_bus->configRgbTimingPorch(EXAMPLE_LCD_RGB_TIMING_HPW, EXAMPLE_LCD_RGB_TIMING_HBP, EXAMPLE_LCD_RGB_TIMING_HFP,
|
||||
EXAMPLE_LCD_RGB_TIMING_VPW, EXAMPLE_LCD_RGB_TIMING_VBP, EXAMPLE_LCD_RGB_TIMING_VFP);
|
||||
// panel_bus->configRgbBounceBufferSize(EXAMPLE_LCD_WIDTH * 10); // Set bounce buffer to avoid screen drift
|
||||
panel_bus->begin();
|
||||
|
||||
Serial.println("Create LCD device");
|
||||
ESP_PanelLcd *lcd = new EXAMPLE_LCD_CLASS(EXAMPLE_LCD_NAME, panel_bus, EXAMPLE_LCD_COLOR_BITS, EXAMPLE_LCD_PIN_NUM_RST);
|
||||
lcd->init();
|
||||
lcd->reset();
|
||||
lcd->begin();
|
||||
#if EXAMPLE_LCD_PIN_NUM_RGB_DISP >= 0
|
||||
lcd->displayOn();
|
||||
#endif
|
||||
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
|
||||
lcd->attachRefreshFinishCallback(onVsyncEndCallback, (void *)&start_time);
|
||||
#endif
|
||||
|
||||
Serial.println("Draw color bar from top left to bottom right, the order is B - G - R");
|
||||
lcd->colorBarTest(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT);
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Turn on the backlight");
|
||||
backlight->on();
|
||||
#endif
|
||||
|
||||
Serial.println("RGB LCD example end");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(1000);
|
||||
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
|
||||
Serial.println("RGB refresh rate: " + String(fps));
|
||||
#else
|
||||
Serial.println("IDLE loop");
|
||||
#endif
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////// Debug Configurations /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Set to 1 if assert on error. Otherwise print error message */
|
||||
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1
|
||||
|
||||
/* Set to 1 if print log message for debug */
|
||||
#define ESP_PANEL_ENABLE_LOG (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////// Touch Driver Configurations //////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Maximum point number */
|
||||
#define ESP_PANEL_TOUCH_MAX_POINTS (5)
|
||||
/* Maximum button number */
|
||||
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)
|
||||
|
||||
/**
|
||||
* XPT2046 related
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
|
||||
/**
|
||||
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
|
||||
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
|
||||
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
|
||||
/**
|
||||
* Keep internal Vref enabled.
|
||||
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
|
||||
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
|
||||
/**
|
||||
* Convert touch coordinates to screen coordinates.
|
||||
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
|
||||
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
|
||||
* screen coordinate.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
|
||||
/**
|
||||
* Enable data structure locking.
|
||||
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
|
||||
* XPT2046 and when reading position data via API.
|
||||
* WARNING: enabling this option may result in unintended crashes.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
|
||||
* the current version of `ESP_Panel_Board_Custom.h` in the library. The detailed rules are as follows:
|
||||
*
|
||||
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
|
||||
* and must be replaced with the file from the library.
|
||||
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
|
||||
* default values. It is recommended to replace it with the file from the library.
|
||||
* 3. Even if the patch version is not consistent, it will not affect normal functionality.
|
||||
*
|
||||
*/
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MAJOR 0
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_MINOR 1
|
||||
#define ESP_PANEL_CONF_FILE_VERSION_PATCH 1
|
||||
@@ -0,0 +1,51 @@
|
||||
| Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
| ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
|
||||
| Supported LCD Controllers | GC9A01 | GC9B71 | ILI9341 | NV3022B | SH8601 | SPD2010 | ST7789 | ST77916 | ST77922 |
|
||||
| ------------------------- | ------ | ------ | ------- | ------- | ------ | ------- | ------ | ------- | ------- |
|
||||
|
||||
# SPI LCD Example
|
||||
|
||||
The example demonstrates how to develop different model LCDs with SPI interface using standalone drivers and test them by displaying color bars.
|
||||
|
||||
## How to use
|
||||
|
||||
1. [Configure drivers](../../../README.md#configuring-drivers) if needed.
|
||||
2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](../../../README.md#configuring-supported-development-boards)
|
||||
4. Verify and upload the example to your ESP board.
|
||||
|
||||
## Serial Output
|
||||
|
||||
```
|
||||
...
|
||||
SPI LCD example start
|
||||
Initialize backlight control pin and turn it off
|
||||
Create SPI LCD bus
|
||||
Create LCD device
|
||||
Draw color bar from top left to bottom right, the order is B - G - R
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Draw bitmap finish callback
|
||||
Turn on the backlight
|
||||
SPI LCD example end
|
||||
IDLE loop
|
||||
...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please check the [FAQ](../../../README.md#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* | Supported ESP SoCs | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||
* | ------------------ | ----- | -------- | -------- | -------- | -------- | -------- |
|
||||
*
|
||||
* | Supported LCD Controllers | GC9A01 | GC9B71 | ILI9341 | NV3022B | SH8601 | SPD2010 | ST7789 | ST77916 | ST77922 |
|
||||
* | ------------------------- | ------ | ------ | ------- | ------- | ------ | ------- | ------ | ------- | ------- |
|
||||
*
|
||||
* # SPI LCD Example
|
||||
*
|
||||
* The example demonstrates how to develop different model LCDs with SPI interface using standalone drivers and test them by displaying color bars.
|
||||
*
|
||||
* ## How to use
|
||||
*
|
||||
* 1. [Configure drivers](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-drivers) if needed.
|
||||
* 2. Modify the macros in the example to match the parameters according to your hardware.
|
||||
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-supported-development-boards)
|
||||
* 4. Verify and upload the example to your ESP board.
|
||||
*
|
||||
* ## Serial Output
|
||||
*
|
||||
* ```
|
||||
* ...
|
||||
* SPI LCD example start
|
||||
* Initialize backlight control pin and turn it off
|
||||
* Create SPI LCD bus
|
||||
* Create LCD device
|
||||
* Draw color bar from top left to bottom right, the order is B - G - R
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Draw bitmap finish callback
|
||||
* Turn on the backlight
|
||||
* SPI LCD example end
|
||||
* IDLE loop
|
||||
* ...
|
||||
* ```
|
||||
*
|
||||
* ## Troubleshooting
|
||||
*
|
||||
* Please check the [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP_Panel_Library.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Currently, the library supports the following SPI LCDs:
|
||||
* - GC9A01, GC9B71
|
||||
* - ILI9341
|
||||
* - NV3022B
|
||||
* - SH8601
|
||||
* - SPD2010
|
||||
* - ST7789, ST77916, ST77922
|
||||
*/
|
||||
#define EXAMPLE_LCD_NAME ILI9341
|
||||
#define EXAMPLE_LCD_WIDTH (320)
|
||||
#define EXAMPLE_LCD_HEIGHT (240)
|
||||
#define EXAMPLE_LCD_COLOR_BITS (16)
|
||||
#define EXAMPLE_LCD_SPI_FREQ_HZ (40 * 1000 * 1000)
|
||||
/**
|
||||
* LCD initialization commands.
|
||||
*
|
||||
* Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for
|
||||
* initialization sequence code.
|
||||
*
|
||||
* Please uncomment and change the following macro definitions, then use `configVendorCommands()` to pass them in the
|
||||
* same format if needed. Otherwise, the LCD driver will use the default initialization sequence code.
|
||||
*
|
||||
* There are two formats for the sequence code:
|
||||
* 1. Raw data: {command, (uint8_t []){ data0, data1, ... }, data_size, delay_ms}
|
||||
* 2. Formater: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... }) and
|
||||
* ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command)
|
||||
*/
|
||||
// const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
|
||||
// {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
|
||||
// {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0},
|
||||
// {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0},
|
||||
// {0x29, (uint8_t []){0x00}, 0, 120},
|
||||
// // or
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}),
|
||||
// ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29),
|
||||
// };
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Please update the following configuration according to your board spec ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_CS (5)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_DC (4)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_SCK (7)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_SDA (6)
|
||||
#define EXAMPLE_LCD_PIN_NUM_SPI_SDO (-1)
|
||||
#define EXAMPLE_LCD_PIN_NUM_RST (-1)
|
||||
#define EXAMPLE_LCD_PIN_NUM_BK_LIGHT (45)
|
||||
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL (1)
|
||||
|
||||
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||
|
||||
/* Enable or disable the attachment of a callback function that is called after each bitmap drawing is completed */
|
||||
#define EXAMPLE_ENABLE_ATTACH_CALLBACK (1)
|
||||
|
||||
#define _EXAMPLE_LCD_CLASS(name, ...) ESP_PanelLcd_##name(__VA_ARGS__)
|
||||
#define EXAMPLE_LCD_CLASS(name, ...) _EXAMPLE_LCD_CLASS(name, ##__VA_ARGS__)
|
||||
|
||||
#if EXAMPLE_ENABLE_ATTACH_CALLBACK
|
||||
IRAM_ATTR bool onDrawBitmapFinishCallback(void *user_data)
|
||||
{
|
||||
esp_rom_printf("Draw bitmap finish callback\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("SPI LCD example start");
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Initialize backlight control pin and turn it off");
|
||||
ESP_PanelBacklight *backlight = new ESP_PanelBacklight(EXAMPLE_LCD_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL, true);
|
||||
backlight->begin();
|
||||
backlight->off();
|
||||
#endif
|
||||
|
||||
Serial.println("Create SPI LCD bus");
|
||||
ESP_PanelBus_SPI *panel_bus = new ESP_PanelBus_SPI(EXAMPLE_LCD_PIN_NUM_SPI_CS, EXAMPLE_LCD_PIN_NUM_SPI_DC,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_SCK, EXAMPLE_LCD_PIN_NUM_SPI_SDA,
|
||||
EXAMPLE_LCD_PIN_NUM_SPI_SDO);
|
||||
panel_bus->configSpiFreqHz(EXAMPLE_LCD_SPI_FREQ_HZ);
|
||||
panel_bus->begin();
|
||||
|
||||
Serial.println("Create LCD device");
|
||||
ESP_PanelLcd *lcd = new EXAMPLE_LCD_CLASS(EXAMPLE_LCD_NAME, panel_bus, EXAMPLE_LCD_COLOR_BITS, EXAMPLE_LCD_PIN_NUM_RST);
|
||||
lcd->init();
|
||||
lcd->reset();
|
||||
// lcd->configVendorCommands(lcd_init_cmd, sizeof(lcd_init_cmd)/sizeof(lcd_init_cmd[0]));
|
||||
lcd->begin();
|
||||
lcd->displayOn();
|
||||
#if EXAMPLE_ENABLE_ATTACH_CALLBACK
|
||||
lcd->attachRefreshFinishCallback(onDrawBitmapFinishCallback, NULL);
|
||||
#endif
|
||||
|
||||
Serial.println("Draw color bar from top left to bottom right, the order is B - G - R");
|
||||
lcd->colorBarTest(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT);
|
||||
|
||||
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
|
||||
Serial.println("Turn on the backlight");
|
||||
backlight->on();
|
||||
#endif
|
||||
|
||||
Serial.println("SPI LCD example end");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(1000);
|
||||
Serial.println("IDLE loop");
|
||||
}
|
||||
Reference in new issue
Block a user