mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-03 20:54:42 +02:00
Updated Installing on PlatformIO (markdown)
@@ -1,17 +1,17 @@
|
|||||||
# Installation: PlatformIO
|
# Installation: PlatformIO
|
||||||
This guide will setup [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) for **PlatformIO** development platform.
|
This guide will setup [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) for **PlatformIO** development platform.
|
||||||
### 1. Install PlatformIO
|
### 1. Install PlatformIO
|
||||||
Go to [PlatformIO page](https://platformio.org/platformio-ide) and follow the instructions to install it into your favourite IDE.
|
If you haven't done it yet go to [PlatformIO page](https://platformio.org/platformio-ide) and follow the instructions to install it into your favorite IDE.
|
||||||
|
|
||||||
We will use [VSCode](https://code.visualstudio.com/) as an example. Install instructions and guides for VSCode can be found [here](https://docs.platformio.org/en/latest/ide/vscode.html).
|
We will use [VSCode](https://code.visualstudio.com/) here as an example. Install instructions and guides for VSCode can be found [here](https://docs.platformio.org/en/latest/ide/vscode.html).
|
||||||
|
|
||||||
### 2. Create a project
|
### 2. Create a project
|
||||||
Follow [this guide](https://docs.platformio.org/en/latest/ide/vscode.html#quick-start) to setup your project. Once you are done open the platformio.ini file. You should see something like this:
|
Follow [this guide](https://docs.platformio.org/en/latest/ide/vscode.html#quick-start) to set up your project. Once you have your project ready go to the file explorer at the left of your screen and open the platformio.ini file. You should see something like this:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 3. Add TFT_eSPI to your project
|
### 3. Add TFT_eSPI to your project
|
||||||
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:
|
There are different ways to include libraries in PlatformIO, but the simplest way is to add the line `lib_deps = TFT_eSPI` in the platform.ini file. It should look like this:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -20,15 +20,16 @@ PlatformIO will automatically download and install TFT_eSPI in your project the
|
|||||||
*More info on `lib_deps` [here](https://docs.platformio.org/en/latest/projectconf/section_env_library.html).*
|
*More info on `lib_deps` [here](https://docs.platformio.org/en/latest/projectconf/section_env_library.html).*
|
||||||
|
|
||||||
### 4. Configure library
|
### 4. Configure library
|
||||||
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.
|
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.
|
||||||
|
|
||||||
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.
|
One cool thing 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 losing 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.
|
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, as you would in regular C/C++ files, 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`. **Aways define `USER_SETUP_LOADED` if using `build_flags` with the TFT_eSPI library**.
|
||||||
- Next include the User_SetupXX_XXXX.h file that maches your configuration.
|
- Next include the User_SetupXX_XXXX.h file that matches your configuration. Use `-include $PROJECT_LIBDEPS_DIR/$PIOENV/TFT_eSPI_ID1559/User_Setups/SetupXX_XXXX.h`
|
||||||
Your code now looks like this:
|
|
||||||
|
Your _build_flags_ now looks like this:
|
||||||
```INI
|
```INI
|
||||||
build_flags =
|
build_flags =
|
||||||
-D USER_SETUP_LOADED=1
|
-D USER_SETUP_LOADED=1
|
||||||
@@ -94,6 +95,6 @@ The final `platformio.ini` file may look like this:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 5. Include header
|
### 5. Include header
|
||||||
Add the line `#include <TFT_eSPI.h>`at the top of your files.
|
Once you have configured the library for your screen add the line `#include <TFT_eSPI.h>`at the beginning of your code.
|
||||||
|
|
||||||
Enjoy! ;)
|
Enjoy! ;)
|
Reference in New Issue
Block a user