-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathESP32_S3_BOX_3.h
211 lines (182 loc) · 9.45 KB
/
ESP32_S3_BOX_3.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
// *INDENT-OFF*
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// Please update the following macros to configure the LCD panel /////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Set to 1 when using an LCD panel */
#define ESP_PANEL_USE_LCD (1) // 0/1
#if ESP_PANEL_USE_LCD
/**
* LCD Controller Name.
*/
#define ESP_PANEL_LCD_NAME ILI9341
/* LCD resolution in pixels */
#define ESP_PANEL_LCD_WIDTH (320)
#define ESP_PANEL_LCD_HEIGHT (240)
/* LCD Bus Settings */
/**
* If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance.
* It is useful if other devices use the same host. Please ensure that the host is initialized only once.
*/
#define ESP_PANEL_LCD_BUS_SKIP_INIT_HOST (0) // 0/1
/**
* LCD Bus Type.
*/
#define ESP_PANEL_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_SPI)
/**
* LCD Bus Parameters.
*
* Please refer to https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/lcd.html and
* https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html for more details.
*
*/
#if ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI
#define ESP_PANEL_LCD_BUS_HOST_ID (1) // Typically set to 1
#define ESP_PANEL_LCD_SPI_IO_CS (5)
#if !ESP_PANEL_LCD_BUS_SKIP_INIT_HOST
#define ESP_PANEL_LCD_SPI_IO_SCK (7)
#define ESP_PANEL_LCD_SPI_IO_MOSI (6)
#define ESP_PANEL_LCD_SPI_IO_MISO (-1) // -1 if not used
#endif
#define ESP_PANEL_LCD_SPI_IO_DC (4)
#define ESP_PANEL_LCD_SPI_MODE (0) // 0/1/2/3, typically set to 0
#define ESP_PANEL_LCD_SPI_CLK_HZ (40 * 1000 * 1000)
// Should be an integer divisor of 80M, typically set to 40M
#define ESP_PANEL_LCD_SPI_TRANS_QUEUE_SZ (10) // Typically set to 10
#define ESP_PANEL_LCD_SPI_CMD_BITS (8) // Typically set to 8
#define ESP_PANEL_LCD_SPI_PARAM_BITS (8) // Typically set to 8
#endif /* ESP_PANEL_LCD_BUS_TYPE */
/**
* LCD Vendor 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. 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. Formatter: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... })
* ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command)
*/
#define ESP_PANEL_LCD_VENDOR_INIT_CMD() \
{ \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC8, {0xFF, 0x93, 0x42}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x0E, 0x0E}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC5, {0xD0}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x02}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xB4, {0x02}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xE0, {0x00, 0x03, 0x08, 0x06, 0x13, 0x09, 0x39, 0x39, 0x48, 0x02, 0x0a, 0x08, \
0x17, 0x17, 0x0F}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xE1, {0x00, 0x28, 0x29, 0x01, 0x0d, 0x03, 0x3f, 0x33, 0x52, 0x04, 0x0f, 0x0e, \
0x37, 0x38, 0x0F}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xB1, {00, 0x1B}), \
ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xB7, {0x06}), \
ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(100, 0x11), \
}
/* LCD Color Settings */
/* LCD color depth in bits */
#define ESP_PANEL_LCD_COLOR_BITS (16) // 8/16/18/24
/*
* LCD RGB Element Order. Choose one of the following:
* - 0: RGB
* - 1: BGR
*/
#define ESP_PANEL_LCD_BGR_ORDER (1) // 0/1
#define ESP_PANEL_LCD_INEVRT_COLOR (0) // 0/1
/* LCD Transformation Flags */
#define ESP_PANEL_LCD_SWAP_XY (0) // 0/1
#define ESP_PANEL_LCD_MIRROR_X (1) // 0/1
#define ESP_PANEL_LCD_MIRROR_Y (1) // 0/1
/* LCD Other Settings */
/* IO num of RESET pin, set to -1 if not use */
#define ESP_PANEL_LCD_IO_RST (48)
#define ESP_PANEL_LCD_RST_LEVEL (1) // 0: low level, 1: high level
#endif /* ESP_PANEL_USE_LCD */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// Please update the following macros to configure the touch panel ///////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Set to 1 when using an touch panel */
#define ESP_PANEL_USE_TOUCH (1) // 0/1
#if ESP_PANEL_USE_TOUCH
/**
* Touch controller name.
*/
#define ESP_PANEL_TOUCH_NAME GT911
/* Touch resolution in pixels */
#define ESP_PANEL_TOUCH_H_RES (ESP_PANEL_LCD_WIDTH) // Typically set to the same value as the width of LCD
#define ESP_PANEL_TOUCH_V_RES (ESP_PANEL_LCD_HEIGHT) // Typically set to the same value as the height of LCD
/* Touch Panel Bus Settings */
/**
* If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance.
* It is useful if other devices use the same host. Please ensure that the host is initialized only once.
*/
#define ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1
/**
* Touch panel bus type.
*/
#define ESP_PANEL_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C)
/* Touch panel bus parameters */
#if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C
#define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0
#define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address
#if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST
#define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000)
// Typically set to 400K
#define ESP_PANEL_TOUCH_I2C_SCL_PULLUP (0) // 0/1
#define ESP_PANEL_TOUCH_I2C_SDA_PULLUP (0) // 0/1
#define ESP_PANEL_TOUCH_I2C_IO_SCL (18)
#define ESP_PANEL_TOUCH_I2C_IO_SDA (8)
#endif
#endif
/* Touch Transformation Flags */
#define ESP_PANEL_TOUCH_SWAP_XY (0) // 0/1
#define ESP_PANEL_TOUCH_MIRROR_X (0) // 0/1
#define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1
/* Touch Other Settings */
/* IO num of RESET pin, set to -1 if not use */
#define ESP_PANEL_TOUCH_IO_RST (-1)
#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level
/* IO num of INT pin, set to -1 if not use */
#define ESP_PANEL_TOUCH_IO_INT (3)
#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level
#endif /* ESP_PANEL_USE_TOUCH */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Please update the following macros to configure the backlight ////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ESP_PANEL_USE_BACKLIGHT (1) // 0/1
#if ESP_PANEL_USE_BACKLIGHT
/* IO num of backlight pin */
#define ESP_PANEL_BACKLIGHT_IO (47)
#define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level
/* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */
#define ESP_PANEL_BACKLIGHT_IDLE_OFF (0) // 0: on, 1: off
/* Set to 1 if use PWM for brightness control */
#define ESP_PANEL_LCD_BL_USE_PWM (1) // 0/1
#endif /* ESP_PANEL_USE_BACKLIGHT */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Please update the following macros to configure the IO expander //////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Set to 0 if not using IO Expander */
#define ESP_PANEL_USE_EXPANDER (0) // 0/1
// #define ESP_PANEL_BEGIN_START_FUNCTION( panel )
// #define ESP_PANEL_BEGIN_EXPANDER_START_FUNCTION( panel )
// #define ESP_PANEL_BEGIN_EXPANDER_END_FUNCTION( panel )
#define ESP_PANEL_BEGIN_LCD_START_FUNCTION( panel ) \
{ \
/* Maintain the touch INT signal in a low state during the reset process to set its I2C address to `0x5D` */ \
gpio_set_direction((gpio_num_t)ESP_PANEL_TOUCH_IO_INT, GPIO_MODE_OUTPUT); \
gpio_set_level((gpio_num_t)ESP_PANEL_TOUCH_IO_INT, 0); \
vTaskDelay(pdMS_TO_TICKS(10)); \
}
// #define ESP_PANEL_BEGIN_LCD_END_FUNCTION( panel )
// #define ESP_PANEL_BEGIN_TOUCH_START_FUNCTION( panel )
// #define ESP_PANEL_BEGIN_TOUCH_END_FUNCTION( panel )
// #define ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION( panel )
// #define ESP_PANEL_BEGIN_BACKLIGHT_END_FUNCTION( panel )
// #define ESP_PANEL_BEGIN_END_FUNCTION( panel )
// *INDENT-OFF*