Created Installing TFT_eSPI on PlatformIO (markdown)

Ricard Bitria Ribes
2020-02-08 13:37:49 +01:00
parent 6d8db30f8f
commit f00ac80e09

@@ -0,0 +1,32 @@
# Installation: PlatformIO
This guide will setup [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) for **PlatformIO** development platform.
### 1. Install PlatformIO
Go to [PlatformIO page](https://platformio.org/platformio-ide) and follow the instructions to install it into your favourite IDE.
In this guide 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).
### 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:
![imagen](https://user-images.githubusercontent.com/26528164/74084716-edd2da80-4a71-11ea-9437-b20d7952783a.png)
### 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:
![imagen](https://user-images.githubusercontent.com/26528164/74084691-af3d2000-4a71-11ea-9841-8e6f9f1da76f.png)
*More info on `lib_deps`[here](https://docs.platformio.org/en/latest/projectconf/section_env_library.html).*
### 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.
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.
- 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.
Your code now looks like this:
### 4. Include header
Add the line `#include <TFT_eSPI.h>`at the top of your files.
Enjoy! ;)