33#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_IDF_TARGET_ESP32S3)
35#include <esp_lcd_panel_io.h>
36#include <esp_lcd_panel_ops.h>
37#include <esp_lcd_panel_rgb.h>
38#include <esp_lcd_panel_vendor.h>
44#define RGB_MAX_PIXEL_CLOCK_HZ (8000000UL)
46#define BOARD_TFT_WIDTH (480)
47#define BOARD_TFT_HEIGHT (480)
49#define BOARD_TFT_BL (46)
51#define BOARD_TFT_HSYNC (47)
52#define BOARD_TFT_VSYNC (41)
53#define BOARD_TFT_DE (45)
54#define BOARD_TFT_PCLK (42)
56#define BOARD_TFT_DATA0 (44)
57#define BOARD_TFT_DATA1 (21)
58#define BOARD_TFT_DATA2 (18)
59#define BOARD_TFT_DATA3 (17)
60#define BOARD_TFT_DATA4 (16)
61#define BOARD_TFT_DATA5 (15)
63#define BOARD_TFT_DATA6 (14)
64#define BOARD_TFT_DATA7 (13)
65#define BOARD_TFT_DATA8 (12)
66#define BOARD_TFT_DATA9 (11)
67#define BOARD_TFT_DATA10 (10)
68#define BOARD_TFT_DATA11 (9)
70#define BOARD_TFT_DATA12 (43)
71#define BOARD_TFT_DATA13 (7)
72#define BOARD_TFT_DATA14 (6)
73#define BOARD_TFT_DATA15 (5)
74#define BOARD_TFT_DATA16 (3)
75#define BOARD_TFT_DATA17 (2)
77#define BOARD_TFT_RST (6)
78#define BOARD_TFT_CS (3)
79#define BOARD_TFT_MOSI (4)
80#define BOARD_TFT_SCLK (5)
88DRAM_ATTR
static const lcd_init_cmd_t st7701_2_1_inches[] = {
89 {0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}, 0x05},
90 {0xC0, {0x3b, 0x00}, 0x02},
91 {0xC1, {0x0b, 0x02}, 0x02},
92 {0xC2, {0x07, 0x02}, 0x02},
95 {0xb0, {0x00, 0x11, 0x16, 0x0e, 0x11, 0x06, 0x05, 0x09, 0x08, 0x21, 0x06, 0x13, 0x10, 0x29, 0x31, 0x18}, 0x10},
96 {0xb1, {0x00, 0x11, 0x16, 0x0e, 0x11, 0x07, 0x05, 0x09, 0x09, 0x21, 0x05, 0x13, 0x11, 0x2a, 0x31, 0x18}, 0x10},
97 {0xFF, {0x77, 0x01, 0x00, 0x00, 0x11}, 0x05},
100 {0xb2, {0x81}, 0x01},
101 {0xb3, {0x80}, 0x01},
102 {0xb5, {0x43}, 0x01},
103 {0xb7, {0x85}, 0x01},
104 {0xb8, {0x20}, 0x01},
105 {0xc1, {0x78}, 0x01},
106 {0xc2, {0x78}, 0x01},
107 {0xc3, {0x8c}, 0x01},
108 {0xd0, {0x88}, 0x01},
109 {0xe0, {0x00, 0x00, 0x02}, 0x03},
110 {0xe1, {0x03, 0xa0, 0x00, 0x00, 0x04, 0xa0, 0x00, 0x00, 0x00, 0x20, 0x20}, 0x0b},
111 {0xe2, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x0d},
112 {0xe3, {0x00, 0x00, 0x11, 0x00}, 0x04},
113 {0xe4, {0x22, 0x00}, 0x02},
114 {0xe5, {0x05, 0xec, 0xa0, 0xa0, 0x07, 0xee, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x10},
115 {0xe6, {0x00, 0x00, 0x11, 0x00}, 0x04},
116 {0xe7, {0x22, 0x00}, 0x02},
117 {0xe8, {0x06, 0xed, 0xa0, 0xa0, 0x08, 0xef, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x10},
118 {0xeb, {0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00}, 0x07},
119 {0xed, {0xff, 0xff, 0xff, 0xba, 0x0a, 0xbf, 0x45, 0xff, 0xff, 0x54, 0xfb, 0xa0, 0xab, 0xff, 0xff, 0xff}, 0x10},
120 {0xef, {0x10, 0x0d, 0x04, 0x08, 0x3f, 0x1f}, 0x06},
121 {0xFF, {0x77, 0x01, 0x00, 0x00, 0x13}, 0x05},
122 {0xef, {0x08}, 0x01},
123 {0xFF, {0x77, 0x01, 0x00, 0x00, 0x00}, 0x05},
124 {0x36, {0x08}, 0x01},
125 {0x3a, {0x66}, 0x01},
126 {0x11, {0x00}, 0x80},
127 {0x29, {0x00}, 0x80},
138uint8_t power_enable = 2;
140static const lcd_init_cmd_t *_init_cmd = st7701_2_1_inches;
141esp_lcd_panel_handle_t _panelDrv;
142std::vector < uint16_t > draw_buf(BOARD_TFT_WIDTH * BOARD_TFT_HEIGHT * 2, 0x000);
144void writeCommand(
const uint8_t
cmd)
150void writeData(
const uint8_t *data,
int len)
156 uint16_t pdat = (*(data +
i)) | 1 << 8;
165 Serial.begin(115200);
184 const uint8_t chip_address = XL9555_UNKNOWN_ADDRESS;
188 Serial.println(
"Failed to find XL9555 - check your wiring!");
207 Wire.setClock(1000000UL);
208 uint32_t start = millis();
213 while (_init_cmd[
i].databytes != 0xff) {
214 writeCommand(_init_cmd[
i].
cmd);
215 writeData(_init_cmd[
i].data, _init_cmd[
i].databytes & 0x1F);
216 if (_init_cmd[
i].databytes & 0x80) {
222 uint32_t end = millis();
224 Serial.printf(
"Initialization took %u milliseconds\n", end - start);
230 Wire.setClock(400000UL);
233 esp_lcd_rgb_panel_config_t panel_config = {
234 .clk_src = LCD_CLK_SRC_PLL160M,
237 .pclk_hz = RGB_MAX_PIXEL_CLOCK_HZ,
238 .h_res = BOARD_TFT_WIDTH,
239 .v_res = BOARD_TFT_HEIGHT,
241 .hsync_pulse_width = 1,
242 .hsync_back_porch = 30,
243 .hsync_front_porch = 50,
244 .vsync_pulse_width = 1,
245 .vsync_back_porch = 30,
246 .vsync_front_porch = 20,
252 .pclk_active_neg = 1,
257 .sram_trans_align = 0,
258 .psram_trans_align = 64,
259 .hsync_gpio_num = BOARD_TFT_HSYNC,
260 .vsync_gpio_num = BOARD_TFT_VSYNC,
261 .de_gpio_num = BOARD_TFT_DE,
262 .pclk_gpio_num = BOARD_TFT_PCLK,
264#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3,0,0)
265 .disp_gpio_num = GPIO_NUM_NC,
313 .disp_gpio_num = GPIO_NUM_NC,
314 .on_frame_trans_done = NULL,
323 log_d(
"new rgb panel");
324 ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &_panelDrv));
325 ESP_ERROR_CHECK(esp_lcd_panel_init(_panelDrv));
327 pinMode(BOARD_TFT_BL, OUTPUT);
328 digitalWrite(BOARD_TFT_BL, HIGH);
333 std::fill(draw_buf.begin(), draw_buf.end(), random(0x0000, 0xFFFF));
334 esp_lcd_panel_draw_bitmap(_panelDrv, 0, 0, BOARD_TFT_WIDTH, BOARD_TFT_HEIGHT, draw_buf.data());
341 Serial.begin(115200);
346 Serial.println(
"The example only support your esp32s3 platform"); delay(1000);
bool begin(SensorCommCustom::CustomCallback callback, uint8_t addr)
Initialize the sensor using custom callback interface.
void pinMode(uint8_t pin, uint8_t mode)
Set the direction of a GPIO pin.
void digitalWrite(uint8_t pin, bool value)
Write a digital value to an output pin.
Software SPI master class for driving GPIO expanders via bit-banging.
bool beginSPI(IoExpanderBase &base, int mosi, int miso, int sck, int cs)
Initialize the software SPI interface.
uint16_t transfer9(uint16_t val)
Transfer 9 bits over SPI.
Concrete driver for the XL9555 16‑bit I2C GPIO expander.
IoExpanderPCA9570 expander