SPFD5408 Library
Author: Joao Lopes
Versions:
0.9.0 - Beta 1: First public beta - 18/07/15
0.9.1 - Beta 2: Now works on Mega boards - 19/07/15
0.9.2 - Beta 3: Now works no Leornardo too - 29/07/15
*** Discontinued, please see below
This library is the Adafruit TFT Libraries changed to works in TFT 2.4 shields with the SPFD5408 controller. Tested on Arduino Uno, Leonardo and Mega. See it on action in: https://www.youtube.com/watch?v=Q8WvEjXvAws
It is based in the last version of Adafruit, inclusive with buttons features.
The TFT 2.4 is cheap TFT, that generally is from China, without documentation or libraries for it.
When we try to use the TFT 2.4 with SPFD5408 controller in sketches with Adafruit TFT libraries, several things can happen :
- White Screen
- All screen with noise
- Touch not works or is inverted (coordinate Y)
- The colors are inverted
- And other things
After trying for several days trying the solutions I found on the web, and none works 100%. So I decided to do an library specific to this controller.
I changed the Adafruit libraries for TFT: GFX , TFTLCD and TouchScreen. I join all in this one library, the library SPFD5408, to avoid problems with duplicate libraries and enables also have the original library Adafruit ready for use in other projects with another TFT hardware.
ATTENTION: DISCONTINUED
Sorry, this library is discontinued, due now few chinesse TFT is SPFD5402, so few TFT is works with it. I now use the Nextion Display instead this TFT
Tip: I am now using Nextion display (https://nextion.itead.cc/), with many advantages like: 4 wires only for connection with the microcontroller, graphic editor on PC, etc.
DISCLAIMER:
This Library is NOT provided by AdaFruit and they have not endorsed it. This library is just a lot of modifications in the Adafruit Library, to works in TFT with SPFD5408 controller (cheap shields)
ATTENTION:
Due to variations in Chinese shields with some controller, there is no guarantee that will work for everyone.
I test with success in my www.mcufriend.com TFTs, plugged in Uno, Leonardo and Mega Arduino boards.
THIS LIBRARY IS ONLY FOR SPFD5408 controller.
If the white screen persists, can indicate than your TFT is not SPFD5408. Please access this site, to help you identify the controller and library for this TFT:
http://misc.ws/2015/01/24/lcd-touch-screen-information/
INSTALATION:
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder to SPFD5408.
Place the SPFD5408 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library.
Or more simple, you access the Arduinosβs IDE menu : sketch/add library
Restart the IDE
If you download any code that uses Adafruit Libraries, please verify it:
β- Pinout XM XP, must be:
#define YP A1 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 7 // can be a digital pin
#define XP 6 // can be a digital pin
(please verify it, if only a blank screen or noise is showed or touch doesnt works)
β- readID: comment the original blok:
// uint16_t identifier = tft.readID();
//
// if(identifier == 0x9325) {
// Serial.println(F("Found ILI9325 LCD driver"));
// } else if(identifier == 0x9328) {
// Serial.println(F("Found ILI9328 LCD driver"));
// } else if(identifier == 0x7575) {
// Serial.println(F("Found HX8347G LCD driver"));
// } else if(identifier == 0x9341) {
// Serial.println(F("Found ILI9341 LCD driver"));
// } else if(identifier == 0x8357) {
// Serial.println(F("Found HX8357D LCD driver"));
// } else {
// Serial.print(F("Unknown LCD driver chip: "));
// Serial.println(identifier, HEX);
// Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
// Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
// Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
// Serial.println(F("If using the breakout board, it should NOT be #defined!"));
// Serial.println(F("Also if using the breakout, double-check that all wiring"));
// Serial.println(F("matches the tutorial."));
// return;
// }
//
// tft.begin(identifier);
β- tft.begin: insert after block commented
tft.begin(0x9341); // SDFP5408
<<<<<<< HEAD β- Calibrate before run
β- tft.rotation: Need for Mega (else screen is showed mirrored)
tft.setRotation(0); // Need for the Mega, please changed for your choice of rotation initial
β- Calibrate before run
origin/master
Exists one sketch written for my, to help in calibration of touch
See it in examples folder
Run it and change this parameters:
#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940
(please verify it if the point of touch is not accurate)
ββββββββ
All changes in Adafruit code is marked with:
// ### SPFD5408 change -- Begin
(change)
// ### SPFD5408 change -- End
This is useful if You see the points that be workeds for any touble
ββββββ
Examples:
adafruit_originals
From Adafruit Libraries β Not works with the SPFD5408
spfd5408_calibrate
Help the calibration of touch (resistive)
spfd5408_tftpaint
example of Adafruit changed to work with the SPFD5408
spfd5408_graphictest
example of Adafruit changed to work with the SPFD5408
spfd5408_rotationtest
example of Adafruit changed to work with the SPFD5408
Acknowledgements:
- First to Adafruit for excellent library
- To Andrologiciels blog (https://andrologiciels.wordpress.com/arduino/lcd/tft-display/)
As the first library could to show the graphics (before only blank or noise screen)
and be the basis for any adjustments that I made in this library
- To Berni_ (https://forum.arduino.cc/index.php?topic=223769.15)
By the logic of TFT calibration for be the basis for my program