/***************************************************
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
----> http://www.adafruit.com/products/1651
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "SD.h"
// For the Adafruit shield, these are the default.
#define TFT_DC 25
#define TFT_RST 27
#define TFT_CS 17
#define SD_CSPIN 16
#define SD_MAXSPEED 50000000
SPIClass spi = SPIClass();
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(&spi, TFT_DC, TFT_CS, TFT_RST);
Adafruit_ILI9341 tft2 = Adafruit_ILI9341(&spi, TFT_DC, 15, TFT_RST);
// If using the breakout, change pins as desired
// Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
unsigned long testFillScreen(Adafruit_ILI9341 &tft)
{
unsigned long start = micros();
tft.fillScreen(ILI9341_BLACK);
yield();
tft.fillScreen(ILI9341_RED);
yield();
tft.fillScreen(ILI9341_GREEN);
yield();
tft.fillScreen(ILI9341_BLUE);
yield();
tft.fillScreen(ILI9341_BLACK);
yield();
return micros() - start;
}
void printDirectory(File dir, int numTabs) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
void setup()
{
Serial.begin(9600);
Serial.println("ILI9341 Test!");
if(!SD.begin(SD_CSPIN, spi)){
Serial.println("Card Failed");
while(1);
}
Serial.println("Files in the card:");
File root = SD.open("/");
printDirectory(root, 0);
Serial.println("");
tft.begin();
tft2.begin();
Serial.print(F("Screen fill 1 "));
Serial.println(testFillScreen(tft));
delay(500);
Serial.print(F("Screen fill 2 "));
Serial.println(testFillScreen(tft2));
delay(500);
Serial.println(F("Done!"));
}
void loop(void)
{
}