51
51
* - GC9503
52
52
* - ST7701
53
53
*/
54
- #define EXAMPLE_LCD_NAME ST7701
55
- #define EXAMPLE_LCD_WIDTH (480 )
56
- #define EXAMPLE_LCD_HEIGHT (480 )
57
- #define EXAMPLE_LCD_COLOR_BITS (18 )
58
- #define EXAMPLE_LCD_RGB_DATA_WIDTH (16 )
59
- #define EXAMPLE_LCD_RGB_TIMING_FREQ_HZ (16 * 1000 * 1000 )
60
- #define EXAMPLE_LCD_RGB_TIMING_HPW (10 )
61
- #define EXAMPLE_LCD_RGB_TIMING_HBP (10 )
62
- #define EXAMPLE_LCD_RGB_TIMING_HFP (20 )
63
- #define EXAMPLE_LCD_RGB_TIMING_VPW (10 )
64
- #define EXAMPLE_LCD_RGB_TIMING_VBP (10 )
65
- #define EXAMPLE_LCD_RGB_TIMING_VFP (10 )
54
+ #define EXAMPLE_LCD_NAME ST7701
55
+ #define EXAMPLE_LCD_WIDTH (480 )
56
+ #define EXAMPLE_LCD_HEIGHT (480 )
57
+ // | 8-bit RGB888 | 16-bit RGB565 |
58
+ #define EXAMPLE_LCD_COLOR_BITS (18 ) // | 24 | 16/18/24 |
59
+ #define EXAMPLE_LCD_RGB_DATA_WIDTH (16 ) // | 8 | 16 |
60
+ #define EXAMPLE_LCD_RGB_TIMING_FREQ_HZ (16 * 1000 * 1000 )
61
+ #define EXAMPLE_LCD_RGB_TIMING_HPW (10 )
62
+ #define EXAMPLE_LCD_RGB_TIMING_HBP (10 )
63
+ #define EXAMPLE_LCD_RGB_TIMING_HFP (20 )
64
+ #define EXAMPLE_LCD_RGB_TIMING_VPW (10 )
65
+ #define EXAMPLE_LCD_RGB_TIMING_VBP (10 )
66
+ #define EXAMPLE_LCD_RGB_TIMING_VFP (10 )
67
+ #define EXAMPLE_LCD_USE_EXTERNAL_CMD (0 )
68
+ #if EXAMPLE_LCD_USE_EXTERNAL_CMD
66
69
/* *
67
70
* LCD initialization commands.
68
71
*
77
80
* 2. Formater: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... }) and
78
81
* ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command)
79
82
*/
80
- // const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
81
- // {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
82
- // {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0},
83
- // {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0},
84
- // {0x29, (uint8_t []){0x00}, 0, 120},
85
- // // or
86
- // ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}),
87
- // ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}),
88
- // ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}),
89
- // ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29),
90
- // };
83
+ const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
84
+ // {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
85
+ // {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0},
86
+ // {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0},
87
+ // {0x29, (uint8_t []){0x00}, 0, 120},
88
+ // // or
89
+ // ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}),
90
+ // ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}),
91
+ // ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}),
92
+ // ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29),
93
+ };
94
+ #endif
91
95
92
96
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
93
97
// ////////////////// Please update the following configuration according to your board spec ////////////////////////////
97
101
#define EXAMPLE_LCD_PIN_NUM_RGB_HSYNC (16 )
98
102
#define EXAMPLE_LCD_PIN_NUM_RGB_DE (18 )
99
103
#define EXAMPLE_LCD_PIN_NUM_RGB_PCLK (21 )
100
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA0 (4 )
101
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA1 (5 )
102
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA2 (6 )
103
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA3 (7 )
104
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA4 (15 )
105
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA5 (8 )
106
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA6 (20 )
107
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA7 (3 )
104
+ // | RGB565 | RGB666 | RGB888 |
105
+ // |--------|--------|--------|
106
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA0 (4 ) // | B0 | B0-1 | B0-3 |
107
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA1 (5 ) // | B1 | B2 | B4 |
108
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA2 (6 ) // | B2 | B3 | B5 |
109
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA3 (7 ) // | B3 | B4 | B6 |
110
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA4 (15 ) // | B4 | B5 | B7 |
111
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA5 (8 ) // | G0 | G0 | G0-2 |
112
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA6 (20 ) // | G1 | G1 | G3 |
113
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA7 (3 ) // | G2 | G2 | G4 |
108
114
#if EXAMPLE_LCD_RGB_DATA_WIDTH > 8
109
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA8 (46 )
110
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA9 (9 )
111
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA10 (10 )
112
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA11 (11 )
113
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA12 (12 )
114
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA13 (13 )
115
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA14 (14 )
116
- #define EXAMPLE_LCD_PIN_NUM_RGB_DATA15 (0 )
115
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA8 (46 ) // | G3 | G3 | G5 |
116
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA9 (9 ) // | G4 | G4 | G6 |
117
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA10 (10 ) // | G5 | G5 | G7 |
118
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA11 (11 ) // | R0 | R0-1 | R0-3 |
119
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA12 (12 ) // | R1 | R2 | R4 |
120
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA13 (13 ) // | R2 | R3 | R5 |
121
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA14 (14 ) // | R3 | R4 | R6 |
122
+ #define EXAMPLE_LCD_PIN_NUM_RGB_DATA15 (0 ) // | R4 | R5 | R7 |
117
123
#endif
118
124
#define EXAMPLE_LCD_PIN_NUM_SPI_CS (39 )
119
125
#define EXAMPLE_LCD_PIN_NUM_SPI_SCK (48 )
120
126
#define EXAMPLE_LCD_PIN_NUM_SPI_SDA (47 )
121
- #define EXAMPLE_LCD_PIN_NUM_RST (-1 )
122
- #define EXAMPLE_LCD_PIN_NUM_BK_LIGHT (38 )
127
+ #define EXAMPLE_LCD_PIN_NUM_RST (-1 ) // Set to -1 if not used
128
+ #define EXAMPLE_LCD_PIN_NUM_BK_LIGHT (38 ) // Set to -1 if not used
123
129
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL (1 )
124
130
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
125
131
132
138
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
133
139
#define EXAMPLE_LCD_FPS_COUNT_MAX (100 )
134
140
135
- DRAM_ATTR int frame_count = 0 ;
136
141
DRAM_ATTR int fps = 0 ;
137
- DRAM_ATTR long start_time = 0 ;
138
142
139
143
IRAM_ATTR bool onVsyncEndCallback (void *user_data)
140
144
{
141
- long frame_start_time = *(long *)user_data;
145
+ DRAM_ATTR static int frame_count = 0 ;
146
+ DRAM_ATTR static long frame_start_time = 0 ;
147
+
142
148
if (frame_start_time == 0 ) {
143
- (*( long *)user_data) = millis ();
149
+ frame_start_time = millis ();
144
150
145
151
return false ;
146
152
}
@@ -149,7 +155,7 @@ IRAM_ATTR bool onVsyncEndCallback(void *user_data)
149
155
if (frame_count >= EXAMPLE_LCD_FPS_COUNT_MAX) {
150
156
fps = EXAMPLE_LCD_FPS_COUNT_MAX * 1000 / (millis () - frame_start_time);
151
157
frame_count = 0 ;
152
- (*( long *)user_data) = millis ();
158
+ frame_start_time = millis ();
153
159
}
154
160
155
161
return false ;
@@ -204,13 +210,16 @@ void setup()
204
210
205
211
Serial.println (" Create LCD device" );
206
212
ESP_PanelLcd *lcd = new EXAMPLE_LCD_CLASS (EXAMPLE_LCD_NAME, lcd_bus, EXAMPLE_LCD_COLOR_BITS, EXAMPLE_LCD_PIN_NUM_RST);
207
- // lcd->configVendorCommands(lcd_init_cmd, sizeof(lcd_init_cmd)/sizeof(lcd_init_cmd[0]));
213
+ #if EXAMPLE_LCD_USE_EXTERNAL_CMD
214
+ // Configure external initialization commands, should called before `init()`
215
+ lcd->configVendorCommands (lcd_init_cmd, sizeof (lcd_init_cmd)/sizeof (lcd_init_cmd[0 ]));
216
+ #endif
208
217
lcd->init ();
209
218
lcd->reset ();
210
219
lcd->begin ();
211
220
lcd->displayOn ();
212
221
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
213
- lcd->attachRefreshFinishCallback (onVsyncEndCallback, ( void *)&start_time );
222
+ lcd->attachRefreshFinishCallback (onVsyncEndCallback, nullptr );
214
223
#endif
215
224
216
225
Serial.println (" Draw color bar from top left to bottom right, the order is B - G - R" );
0 commit comments