Commit 55477b58 authored by Bodmer's avatar Bodmer

Update for setup within sketch option

The TFT configuration (user setup) can now be included inside an Arduino IDE sketch providing the instructions in the example Generic->Sketch_with_tft_setup are followed. See ReadMe tab in that sketch for the instructions.
parent 333f0f84
This diff is collapsed.
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.4.75" #define TFT_ESPI_VERSION "2.4.76"
// Bit level feature flags // Bit level feature flags
// Bit 0 set: viewport capability // Bit 0 set: viewport capability
......
// This header file contains a list of user setup files and defines which one the // This header file contains a list of user setup files and defines which one the
// compiler uses when the IDE performs a Verify/Compile or Upload. // compiler uses when the IDE performs a Verify/Compile or Upload.
// //
// Users can create configurations for different Espressif boards and TFT displays. // Users can create configurations for different boards and TFT displays.
// This makes selecting between hardware setups easy by "uncommenting" one line. // This makes selecting between hardware setups easy by "uncommenting" one line.
// The advantage of this hardware configuration method is that the examples provided // The advantage of this hardware configuration method is that the examples provided
...@@ -14,10 +14,24 @@ ...@@ -14,10 +14,24 @@
// Customised User_Setup files are stored in the "User_Setups" folder. // Customised User_Setup files are stored in the "User_Setups" folder.
// The following lines allow the user setup to be included in the sketch, see
// "Sketch_with_tft_setup" generic example. Do not edit lines 19 to 26!
#if __has_include(<tft_setup.h>)
#include <tft_setup.h>
#ifndef USER_SETUP_LOADED
#define USER_SETUP_LOADED
#endif
#endif
#ifndef USER_SETUP_LOADED // Lets PlatformIO users define settings in #ifndef USER_SETUP_LOADED // Lets PlatformIO users define settings in
// platformio.ini, see notes in "Tools" folder. // platformio.ini, see notes in "Tools" folder.
// Only ONE line below should be uncommented. Add extra lines and files as needed.
///////////////////////////////////////////////////////
// User configuration selection lines are below //
///////////////////////////////////////////////////////
// Only ONE line below should be uncommented to define your setup. Add extra lines and files as needed.
#include <User_Setup.h> // Default setup is root library folder #include <User_Setup.h> // Default setup is root library folder
......
/*
It is possible to bypass the blockage put in place by the Arduino IDE so that a setup file can be included
by a sketch.
The procedure is as follows:
1. Find the folder containing the boards.txt file for the processor board package you are using. To do this
click the IDE menu "File->Preferences". At the bottom of that window click the link to the preferences.txt
file. This will open a folder. Navigate to find the folder containing the "boards.txt" file for the
processor you are using. Exampe paths for RP2040 and ESP32 are:
C:\Users\xxxxx\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.5.2
C:\Users\xxxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.4
2. Copy the platform.local.txt file to that folder. A copy of the "platform.local.txt" is in this sketch
folder, press Ctrl+K to open the folder.
3. Close the Arduino IDE and open it again so the added file is recognised.
4. This setup is already complete in this sketch, but to adapt you own sketches, open the a sketch and add a
new tab, "tft_set.h" in the main sketch, put all the tft library setup information in that header. Now
include this header in the main sketch BEFORE loading the TFT_eSPI library.
IMPORTANT: You will need to remember to add the platform.local.txt file again if you upgrade the IDE or
the board package version). Note that the file must be added to each processor board package you are using.
*/
// THIS SKETCH IS A TEMPLATE EXAMPLE NLY AND IS NOT INTENDED TO BE RUN UNLESS MODIFIED!
// See ReadMe tab for instructions to add a "user setup" configuration file to your sketch
// Important: include tft_setup.h before including the library
#include "tft_setup.h"
#include <SPI.h>
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
void setup(void) {
tft.init();
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 0, 4);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.println("Hello World");
}
void loop() {
}
// This is a configuration setup file example for an RP2040 processor
// Adapt as required for your own hardware configuration
#define RP2040_PIO_SPI
#define GC9A01_DRIVER
#define TFT_WIDTH 240
#define TFT_HEIGHT 240
#define TFT_MOSI 10
#define TFT_MISO 9
#define TFT_SCLK 8
#define TFT_CS 7 // Chip select control pin
#define TFT_DC 4 // Data Command control pin
#define TFT_RST 5 // Reset pin (could connect to Arduino RESET pin)
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
#define SPI_FREQUENCY 66000000
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "2.4.75", "version": "2.4.76",
"keywords": "Arduino, tft, display, ttgo, LilyPi, WT32-SC01, ePaper, display, Pico, RP2040 Nano Connect, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, ST7796, RM68140, SSD1351, SSD1963, ILI9225, HX8357D, GC9A01, R61581", "keywords": "Arduino, tft, display, ttgo, LilyPi, WT32-SC01, ePaper, display, Pico, RP2040 Nano Connect, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, ST7796, RM68140, SSD1351, SSD1963, ILI9225, HX8357D, GC9A01, R61581",
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32", "description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=2.4.75 version=2.4.76
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment