mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-09-26 15:00:56 +02:00
Updated Installing on PlatformIO (markdown)
@@ -11,28 +11,32 @@ Follow [this guide](https://docs.platformio.org/en/latest/ide/vscode.html#quick-
|
|||||||

|

|
||||||
|
|
||||||
### 3. Add TFT_eSPI to your project
|
### 3. Add TFT_eSPI to your project
|
||||||
There are different ways to add libraries in PlatformIO, but the simplest way is to add the line `lib_deps = TFT_eSPI`. Your file now looks like this:
|
There are different ways to include libraries in PlatformIO, but the simplest way is to add the line `lib_deps = TFT_eSPI`. Your file now looks like this:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
*More info on `lib_deps`[here](https://docs.platformio.org/en/latest/projectconf/section_env_library.html).*
|
PlatformIO will automatically download and install TFT_eSPI in your project the next time you build. Library files will be stored in `.pio/libdeps/env_name/TFT_eSPI_ID1559/` inside the project directory.
|
||||||
|
|
||||||
|
*More info on `lib_deps` [here](https://docs.platformio.org/en/latest/projectconf/section_env_library.html).*
|
||||||
|
|
||||||
### 4. Configure library
|
### 4. Configure library
|
||||||
We could modify the `User_Setup_Select.h` file and set our preferences but one cool thig about PlatformIO is that we can modify the library settings without editting the actual library files. This allows us to create different projects with different settings. Also we can update libraries to newer versions without loosing our settings.
|
Before using the library we have to select the tft driver, SPI pins, SPI frequency and other settings to properly control your screen. There are some pre-made setup files for the most common configurations, which can be found in the `User_Setups` folder. This configurations can be included by the `User_Setup_Select.h` file located in the root directory of the library.
|
||||||
|
|
||||||
We can achieve this by using PlatformIO's [`build_flags`](https://docs.platformio.org/en/latest/projectconf/section_env_build.html). Just instead of using #define, use the -D prefix.
|
We could modify the `User_Setup_Select.h` file and set our preferences, but one cool thig about PlatformIO is that we can modify the library settings without editing any library files. This allows us to create different projects using the same library, but with different settings. Also we can update libraries to newer versions without loosing our settings.
|
||||||
|
|
||||||
|
We can achieve this by using PlatformIO's [`build_flags`](https://docs.platformio.org/en/latest/projectconf/section_env_build.html). Instead of using #define, use the -D prefix.
|
||||||
|
|
||||||
- First of all we prevent user settings headers to be loaded by defining `USER_SETUP_LOADED`.
|
- First of all we prevent user settings headers to be loaded by defining `USER_SETUP_LOADED`.
|
||||||
- Next include the User_SetupXX_XXXX.h file that maches your configuration.
|
- Next include the User_SetupXX_XXXX.h file that maches your configuration.
|
||||||
Your code now looks like this:
|
Your code now looks like this:
|
||||||
```INI
|
```INI
|
||||||
build_flags =
|
build_flags =
|
||||||
-D USER_SETUP_LOADED=1
|
-D USER_SETUP_LOADED=1
|
||||||
-include $PROJECT_LIBDEPS_DIR/$PIOENV/TFT_eSPI_ID1559/User_Setups/Setup1_ILI9341.h
|
-include $PROJECT_LIBDEPS_DIR/$PIOENV/TFT_eSPI_ID1559/User_Setups/Setup1_ILI9341.h
|
||||||
```
|
```
|
||||||
|
|
||||||
- Optionally you can create your custom setup by defining the needed settings, here is an example:
|
- Optionally you can create your custom setup by defining the needed settings, here is an example:
|
||||||
```INI
|
```INI
|
||||||
-D ILI9163_DRIVER=1 ; Select ILI9163 driver
|
-D ILI9163_DRIVER=1 ; Select ILI9163 driver
|
||||||
-D TFT_WIDTH=128 ; Set TFT size
|
-D TFT_WIDTH=128 ; Set TFT size
|
||||||
-D TFT_HEIGHT=160
|
-D TFT_HEIGHT=160
|
||||||
@@ -44,7 +48,10 @@ build_flags =
|
|||||||
-D TFT_RST=-1 ; Reset pin
|
-D TFT_RST=-1 ; Reset pin
|
||||||
-D LOAD_GLCD=1 ; Load Fonts
|
-D LOAD_GLCD=1 ; Load Fonts
|
||||||
-D SPI_FREQUENCY=27000000 ; Set SPI frequency
|
-D SPI_FREQUENCY=27000000 ; Set SPI frequency
|
||||||
```
|
```
|
||||||
|
All available settings can be found in `User_Setup.h` file. Replace `#define` with `-D` as shown here:\
|
||||||
|
`#define TOUCH_CS 21` -> `-D TOUCH_CS=21` \
|
||||||
|
`#define LOAD_GLCD` -> `-D LOAD_GLCD`
|
||||||
***
|
***
|
||||||
The final `platformio.ini` file may look like this:
|
The final `platformio.ini` file may look like this:
|
||||||
- Using User_Setups:
|
- Using User_Setups:
|
||||||
|
Reference in New Issue
Block a user