|
17 | 17 |
|
18 | 18 | #if ESP_PANEL_USE_LCD
|
19 | 19 | /**
|
20 |
| - * LCD Controller Name. Choose one of the following: |
21 |
| - * - GC9A01, GC9B71, GC9503 |
22 |
| - * - ILI9341 |
23 |
| - * - NV3022B |
24 |
| - * - SH8601 |
25 |
| - * - SPD2010 |
26 |
| - * - ST7262, ST7701, ST7789, ST7796, ST77916, ST77922 |
| 20 | + * LCD Controller Name. |
27 | 21 | * LCD Controller of M5CoreS3 is ILI9342C, but the driver is compatible with ILI9341.
|
28 | 22 | */
|
29 | 23 | #define ESP_PANEL_LCD_NAME ILI9341
|
|
41 | 35 | */
|
42 | 36 | #define ESP_PANEL_LCD_BUS_SKIP_INIT_HOST (0) // 0/1
|
43 | 37 | /**
|
44 |
| - * LCD Bus Type. Choose one of the following: |
45 |
| - * - ESP_PANEL_BUS_TYPE_I2C (not ready) |
46 |
| - * - ESP_PANEL_BUS_TYPE_SPI |
47 |
| - * - ESP_PANEL_BUS_TYPE_QSPI |
48 |
| - * - ESP_PANEL_BUS_TYPE_I80 (not ready) |
49 |
| - * - ESP_PANEL_BUS_TYPE_RGB (only supported for ESP32-S3) |
| 38 | + * LCD Bus Type. |
50 | 39 | */
|
51 | 40 | #define ESP_PANEL_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_SPI)
|
52 | 41 | /**
|
|
73 | 62 | #define ESP_PANEL_LCD_SPI_CMD_BITS (8) // Typically set to 8
|
74 | 63 | #define ESP_PANEL_LCD_SPI_PARAM_BITS (8) // Typically set to 8
|
75 | 64 |
|
76 |
| -#elif ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI |
77 |
| - |
78 |
| - #define ESP_PANEL_LCD_BUS_HOST_ID (1) // Typically set to 1 |
79 |
| - #define ESP_PANEL_LCD_SPI_IO_CS (5) |
80 |
| -#if !ESP_PANEL_LCD_BUS_SKIP_INIT_HOST |
81 |
| - #define ESP_PANEL_LCD_SPI_IO_SCK (9) |
82 |
| - #define ESP_PANEL_LCD_SPI_IO_DATA0 (10) |
83 |
| - #define ESP_PANEL_LCD_SPI_IO_DATA1 (11) |
84 |
| - #define ESP_PANEL_LCD_SPI_IO_DATA2 (12) |
85 |
| - #define ESP_PANEL_LCD_SPI_IO_DATA3 (13) |
86 |
| -#endif |
87 |
| - #define ESP_PANEL_LCD_SPI_MODE (0) // 0/1/2/3, typically set to 0 |
88 |
| - #define ESP_PANEL_LCD_SPI_CLK_HZ (40 * 1000 * 1000) |
89 |
| - // Should be an integer divisor of 80M, typically set to 40M |
90 |
| - #define ESP_PANEL_LCD_SPI_TRANS_QUEUE_SZ (10) // Typically set to 10 |
91 |
| - #define ESP_PANEL_LCD_SPI_CMD_BITS (32) // Typically set to 32 |
92 |
| - #define ESP_PANEL_LCD_SPI_PARAM_BITS (8) // Typically set to 8 |
93 |
| - |
94 |
| -#elif ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB |
95 |
| - |
96 |
| - #define ESP_PANEL_LCD_RGB_CLK_HZ (16 * 1000 * 1000) |
97 |
| - #define ESP_PANEL_LCD_RGB_HPW (10) |
98 |
| - #define ESP_PANEL_LCD_RGB_HBP (10) |
99 |
| - #define ESP_PANEL_LCD_RGB_HFP (20) |
100 |
| - #define ESP_PANEL_LCD_RGB_VPW (10) |
101 |
| - #define ESP_PANEL_LCD_RGB_VBP (10) |
102 |
| - #define ESP_PANEL_LCD_RGB_VFP (10) |
103 |
| - #define ESP_PANEL_LCD_RGB_PCLK_ACTIVE_NEG (0) // 0: rising edge, 1: falling edge |
104 |
| - #define ESP_PANEL_LCD_RGB_DATA_WIDTH (16) // 8 | 16 |
105 |
| - #define ESP_PANEL_LCD_RGB_PIXEL_BITS (16) // 24 | 16 |
106 |
| - #define ESP_PANEL_LCD_RGB_FRAME_BUF_NUM (1) // 1/2/3 |
107 |
| - #define ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE (0) // Bounce buffer size in bytes. This function is used to avoid screen drift. |
108 |
| - // To enable the bounce buffer, set it to a non-zero value. Typically set to `ESP_PANEL_LCD_WIDTH * 10` |
109 |
| - // The size of the Bounce Buffer must satisfy `width_of_lcd * height_of_lcd = size_of_buffer * N`, |
110 |
| - // where N is an even number. |
111 |
| - #define ESP_PANEL_LCD_RGB_IO_HSYNC (46) |
112 |
| - #define ESP_PANEL_LCD_RGB_IO_VSYNC (3) |
113 |
| - #define ESP_PANEL_LCD_RGB_IO_DE (17) // -1 if not used |
114 |
| - #define ESP_PANEL_LCD_RGB_IO_PCLK (9) |
115 |
| - #define ESP_PANEL_LCD_RGB_IO_DISP (-1) // -1 if not used |
116 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA0 (10) |
117 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA1 (11) |
118 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA2 (12) |
119 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA3 (13) |
120 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA4 (14) |
121 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA5 (21) |
122 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA6 (47) |
123 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA7 (48) |
124 |
| -#if ESP_PANEL_LCD_RGB_DATA_WIDTH > 8 |
125 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA8 (45) |
126 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA9 (38) |
127 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA10 (39) |
128 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA11 (40) |
129 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA12 (41) |
130 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA13 (42) |
131 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA14 (2) |
132 |
| - #define ESP_PANEL_LCD_RGB_IO_DATA15 (1) |
133 |
| -#endif |
134 |
| -#if !ESP_PANEL_LCD_BUS_SKIP_INIT_HOST |
135 |
| - #define ESP_PANEL_LCD_3WIRE_SPI_IO_CS (0) |
136 |
| - #define ESP_PANEL_LCD_3WIRE_SPI_IO_SCK (1) |
137 |
| - #define ESP_PANEL_LCD_3WIRE_SPI_IO_SDA (2) |
138 |
| - #define ESP_PANEL_LCD_3WIRE_SPI_CS_USE_EXPNADER (0) // 0/1 |
139 |
| - #define ESP_PANEL_LCD_3WIRE_SPI_SCL_USE_EXPNADER (0) // 0/1 |
140 |
| - #define ESP_PANEL_LCD_3WIRE_SPI_SDA_USE_EXPNADER (0) // 0/1 |
141 |
| - #define ESP_PANEL_LCD_3WIRE_SPI_SCL_ACTIVE_EDGE (0) // 0: rising edge, 1: falling edge |
142 |
| - #define ESP_PANEL_LCD_FLAGS_AUTO_DEL_PANEL_IO (0) // Delete the panel IO instance automatically if set to 1. |
143 |
| - // If the 3-wire SPI pins are sharing other pins of the RGB interface to save GPIOs, |
144 |
| - // Please set it to 1 to release the panel IO and its pins (except CS signal). |
145 |
| - #define ESP_PANEL_LCD_FLAGS_MIRROR_BY_CMD (!ESP_PANEL_LCD_FLAGS_AUTO_DEL_PANEL_IO) |
146 |
| - // The `mirror()` function will be implemented by LCD command if set to 1. |
147 |
| -#endif |
148 |
| - |
149 |
| -#else |
150 |
| - |
151 |
| -#error "The function is not ready and will be implemented in the future." |
152 |
| - |
153 | 65 | #endif /* ESP_PANEL_LCD_BUS_TYPE */
|
154 | 66 |
|
155 | 67 | /**
|
|
207 | 119 | #define ESP_PANEL_USE_TOUCH (1) // 0/1
|
208 | 120 | #if ESP_PANEL_USE_TOUCH
|
209 | 121 | /**
|
210 |
| - * Touch controller name. Choose one of the following: |
211 |
| - * - CST816S |
212 |
| - * - FT5x06 |
213 |
| - * - GT911, GT1151 |
214 |
| - * - ST1633, ST7123 |
215 |
| - * - TT21100 |
216 |
| - * - XPT2046 |
| 122 | + * Touch controller name. |
217 | 123 | * Touch Controller of M5CoreS3 is FT6336U, but the driver is compatible with FT5x06.
|
218 | 124 | */
|
219 | 125 | #define ESP_PANEL_TOUCH_NAME FT5x06
|
|
229 | 135 | */
|
230 | 136 | #define ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1
|
231 | 137 | /**
|
232 |
| - * Touch panel bus type. Choose one of the following: |
233 |
| - * - ESP_PANEL_BUS_TYPE_I2C |
234 |
| - * - ESP_PANEL_BUS_TYPE_SPI |
| 138 | + * Touch panel bus type. |
235 | 139 | */
|
236 | 140 | #define ESP_PANEL_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C)
|
237 | 141 | /* Touch panel bus parameters */
|
|
248 | 152 | #define ESP_PANEL_TOUCH_I2C_IO_SDA (12)
|
249 | 153 | #endif
|
250 | 154 |
|
251 |
| -#elif ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI |
252 |
| - |
253 |
| - #define ESP_PANEL_TOUCH_BUS_HOST_ID (1) // Typically set to 1 |
254 |
| - #define ESP_PANEL_TOUCH_SPI_IO_CS (5) |
255 |
| -#if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST |
256 |
| - #define ESP_PANEL_TOUCH_SPI_IO_SCK (7) |
257 |
| - #define ESP_PANEL_TOUCH_SPI_IO_MOSI (6) |
258 |
| - #define ESP_PANEL_TOUCH_SPI_IO_MISO (9) |
259 |
| -#endif |
260 |
| - #define ESP_PANEL_TOUCH_SPI_CLK_HZ (1 * 1000 * 1000) |
261 |
| - // Should be an integer divisor of 80M, typically set to 1M |
262 |
| - |
263 |
| -#else |
264 |
| - |
265 |
| -#error "The function is not ready and will be implemented in the future." |
266 |
| - |
267 | 155 | #endif /* ESP_PANEL_TOUCH_BUS_TYPE */
|
268 | 156 |
|
269 | 157 | /* Touch Transformation Flags */
|
|
285 | 173 | ///////////////////////////// Please update the following macros to configure the backlight ////////////////////////////
|
286 | 174 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
287 | 175 | #define ESP_PANEL_USE_BACKLIGHT (0) // 0/1
|
288 |
| -#if ESP_PANEL_USE_BACKLIGHT |
289 |
| -/* IO num of backlight pin */ |
290 |
| -#define ESP_PANEL_BACKLIGHT_IO (45) |
291 |
| -#define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level |
292 |
| - |
293 |
| -/* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */ |
294 |
| -#define ESP_PANEL_BACKLIGHT_IDLE_OFF (0) // 0: on, 1: off |
295 |
| - |
296 |
| -/* Set to 1 if use PWM for brightness control */ |
297 |
| -#define ESP_PANEL_LCD_BL_USE_PWM (1) // 0/1 |
298 |
| -#endif /* ESP_PANEL_USE_BACKLIGHT */ |
299 | 176 |
|
300 | 177 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
301 | 178 | ///////////////////////////// Please update the following macros to configure the IO expander //////////////////////////
|
302 | 179 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
303 | 180 | /* Set to 0 if not using IO Expander */
|
304 | 181 | #define ESP_PANEL_USE_EXPANDER (0) // 0/1
|
305 |
| -#if ESP_PANEL_USE_EXPANDER |
306 |
| -/** |
307 |
| - * IO expander name. Choose one of the following: |
308 |
| - * - CH422G |
309 |
| - * - HT8574 |
310 |
| - * - TCA95xx_8bit |
311 |
| - * - TCA95xx_16bit |
312 |
| - */ |
313 |
| -#define ESP_PANEL_EXPANDER_NAME TCA95xx_8bit |
314 |
| - |
315 |
| -/* IO expander Settings */ |
316 |
| -/** |
317 |
| - * If set to 1, the driver will skip to initialize the corresponding host. Users need to initialize the host in advance. |
318 |
| - * It is useful if other devices use the same host. Please ensure that the host is initialized only once. |
319 |
| - */ |
320 |
| -#define ESP_PANEL_EXPANDER_SKIP_INIT_HOST (0) // 0/1 |
321 |
| -/* IO expander parameters */ |
322 |
| -#define ESP_PANEL_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, |
323 |
| - // the I2C address may be different, and confirmation based on |
324 |
| - // the actual hardware connection is required |
325 |
| -#if !ESP_PANEL_EXPANDER_SKIP_INIT_HOST |
326 |
| - #define ESP_PANEL_EXPANDER_HOST_ID (0) // Typically set to 0 |
327 |
| - #define ESP_PANEL_EXPANDER_I2C_CLK_HZ (400 * 1000) |
328 |
| - // Typically set to 400K |
329 |
| - #define ESP_PANEL_EXPANDER_I2C_SCL_PULLUP (1) // 0/1 |
330 |
| - #define ESP_PANEL_EXPANDER_I2C_SDA_PULLUP (1) // 0/1 |
331 |
| - #define ESP_PANEL_EXPANDER_I2C_IO_SCL (18) |
332 |
| - #define ESP_PANEL_EXPANDER_I2C_IO_SDA (8) |
333 |
| -#endif |
334 |
| -#endif /* ESP_PANEL_USE_EXPANDER */ |
335 | 182 |
|
336 | 183 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
337 | 184 | ///////////////////////////// Please utilize the following macros to execute any additional code if required. //////////
|
338 | 185 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
339 |
| -#define ESP_PANEL_BEGIN_START_FUNCTION( panel ) \ |
340 |
| - { \ |
341 |
| - Serial.println("in function ESP_PANEL_BEGIN_END_FUNCTION\n"); \ |
342 |
| - static const uint8_t AXP_ADDR = 0x34; \ |
343 |
| - static const uint8_t I2C_MASTER_TIMEOUT_MS = 0; \ |
344 |
| - static i2c_port_t i2c_master_port = I2C_NUM_0; \ |
345 |
| - \ |
346 |
| - uint8_t read_value = 0; \ |
347 |
| - uint8_t write_value = 0; \ |
348 |
| - uint8_t reg_addr = 0; \ |
349 |
| - uint8_t write_buf[2] = {0}; \ |
350 |
| - \ |
351 |
| - write_buf[0] = 0x90; \ |
352 |
| - write_buf[1] = 0xBF; \ |
353 |
| - i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
354 |
| - write_buf[0] = 0x02; \ |
355 |
| - write_buf[1] = 0b00000101; \ |
356 |
| - i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
357 |
| - write_buf[0] = 0x03; \ |
358 |
| - write_buf[1] = 0b00000011; \ |
359 |
| - i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
360 |
| - write_buf[0] = 0x04; \ |
361 |
| - write_buf[1] = 0b00011000; \ |
362 |
| - i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
363 |
| - write_buf[0] = 0x05; \ |
364 |
| - write_buf[1] = 0b00001100; \ |
365 |
| - i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
366 |
| - write_buf[0] = 0x11; \ |
367 |
| - write_buf[1] = 0b00010000; \ |
368 |
| - i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
369 |
| - write_buf[0] = 0x12; \ |
370 |
| - write_buf[1] = 0b11111111; \ |
371 |
| - i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
372 |
| - write_buf[0] = 0x13; \ |
373 |
| - write_buf[1] = 0b11111111; \ |
374 |
| - i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \ |
375 |
| - \ |
| 186 | +#define ESP_PANEL_BEGIN_START_FUNCTION( panel ) \ |
| 187 | + { \ |
| 188 | + const uint8_t AXP_ADDR = 0x34; \ |
| 189 | + const uint8_t I2C_MASTER_TIMEOUT_MS = 1000; \ |
| 190 | + const i2c_port_t i2c_master_port = I2C_NUM_0; \ |
| 191 | + \ |
| 192 | + uint8_t read_value = 0; \ |
| 193 | + uint8_t write_value = 0; \ |
| 194 | + uint8_t reg_addr = 0; \ |
| 195 | + uint8_t write_buf[2] = {0}; \ |
| 196 | + \ |
| 197 | + ESP_LOGD(TAG, "Start AXP2101 Power"); \ |
| 198 | + write_buf[0] = 0x90; \ |
| 199 | + write_buf[1] = 0xBF; \ |
| 200 | + i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 201 | + write_buf[0] = 0x02; \ |
| 202 | + write_buf[1] = 0b00000101; \ |
| 203 | + i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 204 | + write_buf[0] = 0x03; \ |
| 205 | + write_buf[1] = 0b00000011; \ |
| 206 | + i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 207 | + write_buf[0] = 0x04; \ |
| 208 | + write_buf[1] = 0b00011000; \ |
| 209 | + i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 210 | + write_buf[0] = 0x05; \ |
| 211 | + write_buf[1] = 0b00001100; \ |
| 212 | + i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 213 | + write_buf[0] = 0x11; \ |
| 214 | + write_buf[1] = 0b00010000; \ |
| 215 | + i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 216 | + write_buf[0] = 0x12; \ |
| 217 | + write_buf[1] = 0b11111111; \ |
| 218 | + i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 219 | + write_buf[0] = 0x13; \ |
| 220 | + write_buf[1] = 0b11111111; \ |
| 221 | + i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \ |
| 222 | + \ |
376 | 223 | }
|
377 | 224 | // #define ESP_PANEL_BEGIN_EXPANDER_START_FUNCTION( panel )
|
378 | 225 | // #define ESP_PANEL_BEGIN_EXPANDER_END_FUNCTION( panel )
|
|
0 commit comments