/***************************************************
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"
SPIClass * hspi = new SPIClass(HSPI);
SPIClass * vspi = new SPIClass(FSPI);
// For the Adafruit shield, these are the default.
#define CS1 14
#define DC1 12
#define RST1 13
#define MOSI1 11
#define SCK1 10
#define LED1 9
#define MISO1 46
#define CS2 35
#define DC2 48
#define RST2 45
#define MOSI2 47
#define SCK2 21
#define LED2 20
#define MISO2 19
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
// Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// 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);
Adafruit_ILI9341 tft(vspi, DC1, CS1, RST1);
Adafruit_ILI9341 tft2(hspi, DC2, CS2, RST2);
void setup() {
Serial.begin(115200);
Serial.println("ILI9341 Test!");
hspi->begin(SCK2, MISO2, MOSI2, CS2);
vspi->begin(SCK1, MISO1, MOSI1, CS1);
pinMode(hspi->pinSS(), OUTPUT); //HSPI SS
pinMode(vspi->pinSS(), OUTPUT); //HSPI SS
pinMode(LED2, OUTPUT); //VSPI SS
pinMode(LED1, OUTPUT); //HSPI SS
digitalWrite(LED2, HIGH);
digitalWrite(LED1, LOW);
tft2.begin();
tft.begin();
Serial.println(F("Done!"));
}
void loop(void) {
for(uint8_t rotation=0; rotation<4; rotation++) {
tft.setRotation(rotation);
testText(tft);
tft2.setRotation(rotation);
testText(tft2);
delay(1000);
}
}
unsigned long testText(Adafruit_ILI9341 t) {
t.fillScreen(ILI9341_BLACK);
unsigned long start = micros();
t.setCursor(0, 0);
t.setTextColor(ILI9341_WHITE); t.setTextSize(1);
t.println("Hello World!");
t.setTextColor(ILI9341_YELLOW); t.setTextSize(2);
t.println(1234.56);
t.setTextColor(ILI9341_RED); t.setTextSize(3);
t.println(0xDEADBEEF, HEX);
t.println();
t.setTextColor(ILI9341_GREEN);
t.setTextSize(5);
t.println("Groop");
t.setTextSize(2);
t.println("I implore thee,");
t.setTextSize(1);
t.println("my foonting turlingdromes.");
t.println("And hooptiously drangle me");
t.println("with crinkly bindlewurdles,");
t.println("Or I will rend thee");
t.println("in the gobberwarts");
t.println("with my blurglecruncheon,");
t.println("see if I don't!");
return micros() - start;
}