Skip to content

Commit 7d13ee8

Browse files
committed
Move display configuration into the library component.
1 parent 1e04a2b commit 7d13ee8

File tree

6 files changed

+86
-58
lines changed

6 files changed

+86
-58
lines changed

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,18 @@ To run the demo, attach ILI9341, ILI9488 or ST7735 based display module to ESP32
166166

167167
---
168168

169-
*To run the demo on* **ESP-WROWER-KIT v3** *select the following pin configuration:*
170-
* mosi: 23
171-
* miso: 25
172-
* sck: 19
173-
* CS: 22 (display CS)
174-
* DC: 21 (display DC)
175-
* TCS: 0 (touch screen CS), not used
176-
* RST: 18 (display RESET)
177-
* BKLIT: 5 (Display Back light)
169+
#### Display Kits
178170

179-
Also set **TFT_RGB_BGR** to 0x00 and **TFT_INVERT_ROTATION1** to 1 in *tftspi.h*
171+
Predefined display configurations are available that will set pins, display size, and inversion properly for the specified kit.
180172

181-
**You can also select EXAMPLE_ESP_WROVER_KIT in menuconfig to automaticaly define correct configuration**
173+
Access these through the `idf.py menuconfig` in Components->TFT Display
174+
175+
Configurations are available for:
176+
177+
"ESP-WROVER-KIT v3 Display (ST7789V)"
178+
"ESP-WROVER-KIT v4.1 Display (ILI9341)"
179+
"Adafruit TFT Feather Display"
180+
"M5Stack TFT Display"
182181

183182
---
184183

@@ -198,17 +197,15 @@ Clone the repository
198197

199198
`git clone https://github.com/loboris/ESP32_TFT_library.git`
200199

201-
Execute menuconfig and configure your Serial flash config and other settings. Included *sdkconfig.defaults* sets some defaults to be used.
202-
203-
Navigate to **TFT Display DEMO Configuration** and set **SPIFFS** options.
200+
Execute `idf.py menuconfig` and configure your Serial flash config and other settings. Included *sdkconfig.defaults* sets some defaults to be used.
204201

205-
Select if you want to use **wifi** (recommended) to get the time from **NTP** server and set your WiFi SSID and password.
202+
Navigate to **Components -> TFT Display** and set **display** options or select a pre-defined display configuration for a kit.
206203

207-
`make menuconfig`
204+
To enable **Wifi** in the demo (recommended - gets time from NTP), select **TFT Display DEMO Configuration** from the top-level menu and select those options.
208205

209206
Make and flash the example.
210207

211-
`make all && make flash`
208+
`idf.py build && idf.py -p <PORT> flash monitor`
212209

213210
---
214211

@@ -224,6 +221,12 @@ Make and flash the example.
224221

225222
You can also prepare different SFPIFFS **image** and flash it to ESP32. *This feature is only tested on Linux.*
226223

224+
If you change the SPIFFS image, review the SPIFFS configuration as well. This would also need to be updated if the partition table is changed.
225+
226+
`idf.py menuconfig`
227+
Navigate to **Components -> TFT SPIFFS** and set **SPIFFS** options.
228+
229+
227230
Files to be included on spiffs are already in **components/spiffs_image/image/** directory. You can add or remove the files you want to include.
228231

229232
Then execute:

components/spiffs/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
menu "TFT SPIFFS Configuration"
1+
menu "TFT SPIFFS"
22

33
config SPIFFS_BASE_ADDR
44
int "SPIFFS Base address"

components/tft/Kconfig

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
menu "TFT Display"
22

3+
config TFT_PREDEFINED_DISPLAY_TYPE
4+
int
5+
default 0 if TFT_PREDEFINED_DISPLAY_TYPE0
6+
default 1 if TFT_PREDEFINED_DISPLAY_TYPE1
7+
default 2 if TFT_PREDEFINED_DISPLAY_TYPE2
8+
default 3 if TFT_PREDEFINED_DISPLAY_TYPE3
9+
default 4 if TFT_PREDEFINED_DISPLAY_TYPE4
10+
11+
choice
12+
prompt "Select predefined display configuration"
13+
default TFT_PREDEFINED_DISPLAY_TYPE0
14+
help
15+
Select predefined display configuration
16+
17+
config TFT_PREDEFINED_DISPLAY_TYPE0
18+
bool "None"
19+
config TFT_PREDEFINED_DISPLAY_TYPE1
20+
bool "ESP-WROVER-KIT v3 Display (ST7789V)"
21+
config TFT_PREDEFINED_DISPLAY_TYPE4
22+
bool "ESP-WROVER-KIT v4.1 Display (ILI9341)"
23+
config TFT_PREDEFINED_DISPLAY_TYPE2
24+
bool "Adafruit TFT Feather Display"
25+
config TFT_PREDEFINED_DISPLAY_TYPE3
26+
bool "M5Stack TFT Display"
27+
endchoice
28+
29+
config TFT_DISPLAY_CONTROLLER_MODEL
30+
int
31+
default 0 if TFT_DISPLAY_CONTROLLER_ILI9341
32+
default 1 if TFT_DISPLAY_CONTROLLER_ILI9488
33+
default 2 if TFT_DISPLAY_CONTROLLER_ST7789V
34+
default 3 if TFT_DISPLAY_CONTROLLER_ST7735
35+
default 4 if TFT_DISPLAY_CONTROLLER_ST7735R
36+
default 5 if TFT_DISPLAY_CONTROLLER_ST7735B
37+
38+
choice
39+
prompt "Select a display controller model."
40+
default TFT_DISPLAY_CONTROLLER_ILI9341
41+
help
42+
Select the controller for your display. If an TFT_PREDEFINED_DISPLAY_TYPE is set, this will be overridden.
43+
44+
config TFT_DISPLAY_CONTROLLER_ILI9341
45+
bool "ILI9341"
46+
config TFT_DISPLAY_CONTROLLER_ILI9488
47+
bool "ILI9488"
48+
config TFT_DISPLAY_CONTROLLER_ST7789V
49+
bool "ST7789V"
50+
config TFT_DISPLAY_CONTROLLER_ST7735
51+
bool "ST7735"
52+
config TFT_DISPLAY_CONTROLLER_ST7735R
53+
bool "ST7735R"
54+
config TFT_DISPLAY_CONTROLLER_ST7735B
55+
bool "ST7735B"
56+
endchoice
57+
358
config TFT_INVERT_ROTATION1
459
bool "Invert rotation1."
560
default n

components/tft/tftspi.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define DISP_TYPE_ST7735R 4
3636
#define DISP_TYPE_ST7735B 5
3737

38-
#if CONFIG_EXAMPLE_DISPLAY_TYPE == 1
38+
#if CONFIG_TFT_PREDEFINED_DISPLAY_TYPE == 1
3939

4040
// ** Set the correct configuration for ESP-WROVER-KIT v3
4141
// --------------------------------------------------------
@@ -64,7 +64,7 @@
6464
#define PIN_BCKL_OFF 1 // GPIO value for backlight OFF
6565
// --------------------------------------------------------
6666

67-
#elif CONFIG_EXAMPLE_DISPLAY_TYPE == 2
67+
#elif CONFIG_TFT_PREDEFINED_DISPLAY_TYPE == 2
6868

6969
// ** Set the correct configuration for Adafruit TFT Feather
7070
// ---------------------------------------------------------
@@ -93,7 +93,7 @@
9393
#define PIN_BCKL_OFF 1 // GPIO value for backlight OFF
9494
// ---------------------------------------------------------
9595

96-
#elif CONFIG_EXAMPLE_DISPLAY_TYPE == 3
96+
#elif CONFIG_TFT_PREDEFINED_DISPLAY_TYPE == 3
9797

9898
// ** Set the correct configuration for M5Stack TFT
9999
// ---------------------------------------------------------
@@ -123,7 +123,7 @@
123123
#define PIN_BCKL_OFF 0 // GPIO value for backlight OFF
124124
// ---------------------------------------------------------
125125

126-
#elif CONFIG_EXAMPLE_DISPLAY_TYPE == 4
126+
#elif CONFIG_TFT_PREDEFINED_DISPLAY_TYPE == 4
127127

128128
// ** Set the correct configuration for ESP-WROVER-KIT v4.1
129129
// --------------------------------------------------------
@@ -223,10 +223,15 @@
223223

224224
#define DEFAULT_GAMMA_CURVE 0
225225
#define DEFAULT_SPI_CLOCK 26000000
226+
227+
#if defined(CONFIG_TFT_DISPLAY_CONTROLLER_MODEL)
228+
#define DEFAULT_DISP_TYPE CONFIG_TFT_DISPLAY_CONTROLLER_MODEL
229+
#else
226230
#define DEFAULT_DISP_TYPE DISP_TYPE_ILI9341
231+
#endif
227232
//----------------------------------------------------------------------------
228233

229-
#endif // CONFIG_EXAMPLE_ESP_WROVER_KIT
234+
#endif // CONFIG_PREDEFINED_DISPLAY_TYPE
230235

231236

232237
// ##############################################################

main/Kconfig.projbuild

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
11
menu "TFT Display DEMO Configuration"
22

3-
config EXAMPLE_DISPLAY_TYPE
4-
int
5-
default 0 if EXAMPLE_DISPLAY_TYPE0
6-
default 1 if EXAMPLE_DISPLAY_TYPE1
7-
default 2 if EXAMPLE_DISPLAY_TYPE2
8-
default 3 if EXAMPLE_DISPLAY_TYPE3
9-
default 4 if EXAMPLE_DISPLAY_TYPE4
10-
11-
choice
12-
prompt "Select predefined display configuration"
13-
default EXAMPLE_DISPLAY_TYPE0
14-
help
15-
Select predefined display configuration
16-
17-
config EXAMPLE_DISPLAY_TYPE0
18-
bool "None"
19-
config EXAMPLE_DISPLAY_TYPE1
20-
bool "ESP-WROVER-KIT v3 Display (ST7789V)"
21-
config EXAMPLE_DISPLAY_TYPE4
22-
bool "ESP-WROVER-KIT v4.1 Display (ILI9341)"
23-
config EXAMPLE_DISPLAY_TYPE2
24-
bool "Adafruit TFT Feather display"
25-
config EXAMPLE_DISPLAY_TYPE3
26-
bool "M5Stack TFT display"
27-
endchoice
28-
293
config EXAMPLE_USE_WIFI
304
bool "Use wifi in TFT Demo"
315
default n

main/tft_demo.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,15 +1237,6 @@ void app_main()
12371237

12381238
// === SET GLOBAL VARIABLES ==========================
12391239

1240-
// ===================================================
1241-
// ==== Set display type =====
1242-
//tft_disp_type = DEFAULT_DISP_TYPE;
1243-
//tft_disp_type = DISP_TYPE_ILI9341;
1244-
tft_disp_type = DISP_TYPE_ST7735B;
1245-
//tft_disp_type = DISP_TYPE_ILI9488;
1246-
//tft_disp_type = DISP_TYPE_ST7735B;
1247-
// ===================================================
1248-
12491240
// ===================================================
12501241
// ==== Set maximum spi clock for display read ====
12511242
// operations, function 'find_rd_speed()' ====

0 commit comments

Comments
 (0)