I am having trouble getting an Adafruit TFT display working on a UNO using SPI. This is the display: Overview | Adafruit 3.5" 320x480 Color TFT Touchscreen Breakout | Adafruit Learning System
The problem is that although the code appears to run okay, the screen is just a blank bright white. This device is 3.3v and 5V tolerant. I am unsing the adafruit HX8357 library.
The wiring image is attached.
And the code is here:
*****NOTE: I had to Remove most of the functions at the end to make it fit in this post. *****
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_HX8357.h"
// These are 'flexible' lines that can be changed
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8 // RST can be set to -1 if you tie it to Arduino's reset
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);
// SoftSPI - note that on some processors this might be *faster* than hardware SPI!
//Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST, MISO);
void setup() {
Serial.begin(115200);
Serial.println("HX8357D Test!");
tft.begin();
// read diagnostics (optional but can help debug problems)
uint8_t x = tft.readcommand8(HX8357_RDPOWMODE);
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDMADCTL);
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDCOLMOD);
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDDIM);
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDDSDR);
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
Serial.println(F("Benchmark Time (microseconds)"));
tft.setRotation(1);
Serial.print(F("Text "));
Serial.println(testText());
delay(500);
Serial.print(F("Lines "));
Serial.println(testLines(HX8357_CYAN));
delay(500);
Serial.print(F("Rectangles (outline) "));
Serial.println(testRects(HX8357_GREEN));
delay(500);
tft.fillScreen(HX8357_BLACK);
Serial.print(F("Circles (outline) "));
Serial.println(testCircles(10, HX8357_RED));
delay(500);
Serial.print(F("Triangles (outline) "));
Serial.println(testTriangles());
delay(500);
Serial.print(F("Triangles (filled) "));
Serial.println(testFilledTriangles());
delay(500);
Serial.print(F("Rounded rects (outline) "));
Serial.println(testRoundRects());
delay(500);
Serial.print(F("Rounded rects (filled) "));
Serial.println(testFilledRoundRects());
delay(500);
Serial.println(F("Done!"));
}
void loop(void) {
for(uint8_t rotation=0; rotation<4; rotation++) {
tft.setRotation(rotation);
testText();
delay(1000);
}
}
unsigned long testFillScreen() {
unsigned long start = micros();
tft.fillScreen(HX8357_RED);
tft.fillScreen(HX8357_GREEN);
tft.fillScreen(HX8357_BLUE);
tft.fillScreen(HX8357_WHITE);
return micros() - start;
}