// IMPORTANT: Adafruit_ILI9341_8bit_AS LIBRARY MUST BE SPECIFICALLY // CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD. // DEFAULT IS THE UNO SHIELD // SEE RELEVANT COMMENTS IN Adafruit_ILI9341_8bit_AS.h FOR SETUP. //#define DEBUG // Gives stats on serial display. #include // Core graphics library #include // Hardware-specific library // The control pins for the LCD can be assigned to any digital or // analog pins...but we'll use the analog pins as this allows us to // double up the pins with the touch screen (see the TFT paint example). #define LCD_CS A3 // Chip Select goes to Analog 3 #define LCD_CD A2 // Command/Data goes to Analog 2, Labled LCD_RS #define LCD_WR A1 // LCD Write goes to Analog 1 #define LCD_RD A0 // LCD Read goes to Analog 0 #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin // Assign human-readable names to some common 16-bit color values: // Set for inverted color display. #define BLACK 0xFFFF #define BLUE 0xFFE0 #define GREEN 0xF81F #define CYAN 0xF800 #define GRAY1 0x8410 #define RED 0x07FF //define BRIGHT_RED 0x???? #define GRAY2 0x4208 #define MAGENTA 0x07E0 #define YELLOW 0x001F #define WHITE 0x0000 Adafruit_ILI9341_8bit_AS tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); // If using the shield, all control and data lines are fixed, and // a simpler declaration can optionally be used: // Adafruit_ILI9341_8bit_AS tft; void setup(void) { tft.reset(); delay(10); tft.begin(0x9341); //tft.setRotation(0); } void loop(void) { //for(uint8_t rotation=0; rotation<4; rotation++) { //tft.setRotation(rotation); //Text(); //delay(1000); } //Calls for subroutines FilledRoundRects(); RoundRects(); FilledTriangles(); Triangles(); Circles(10, WHITE); FillScreen(); Text(); Lines(CYAN); FastLines(RED, BLUE); Rects(GREEN); FilledRects(YELLOW, MAGENTA); FilledCircles(10, MAGENTA); } unsigned long FillScreen() { tft.fillScreen(BLACK); tft.fillScreen(RED); tft.fillScreen(GREEN); tft.fillScreen(BLUE); tft.fillScreen(WHITE); tft.fillScreen(BLACK); } unsigned long Text() { tft.fillScreen(BLACK); tft.setCursor(0, 0); tft.setTextColor(BLUE); tft.setTextSize(3); tft.println("Hello"); tft.println("What's UP ?"); delay(1000); } //unsigned long Text() //{ // tft.fillScreen(BLACK); // tft.setCursor(0, 0); // tft.setTextColor(WHITE); // tft.setTextSize(3); // tft.println("Hello World!"); // tft.setTextColor(YELLOW); // tft.setTextSize(2); // tft.println(1234.56); // tft.setTextColor(RED); // tft.setTextSize(3); // tft.println(0xDEAFBEEF, HEX); // //tft.println(); // tft.setTextColor(GREEN); // //tft.setTextSize(5); // //tft.println("Hello World"); // //tft.setTextSize(4); // //tft.println("Hello World"); // tft.setTextSize(3); // tft.println("Hello World"); // tft.setTextSize(2); // tft.println("Hello World"); // tft.setTextSize(1); // tft.println("Hello World"); //} unsigned long Lines(uint16_t color) // Define Routine Name and type. { // Start of Routine. int x1, y1, x2, y2, // define x1,y1,x2,y2,w,h as int w = tft.width(), // w = 240 h = tft.height(); // h = 320 tft.fillScreen(BLACK); // Clear Screen to BLACK. x1 = y1 = 0; // set x1, y1 to 0 y2 = h - 1; // set y2 to (tft.height(320)- 1) = (319). for(x2=0; x20; i-=6) { i2 = i / 2; tft.fillRect(cx-i2, cy-i2, i, i, color1); tft.drawRect(cx-i2, cy-i2, i, i, color2); } } unsigned long FilledCircles(uint8_t radius, uint16_t color) { unsigned long start; int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; tft.fillScreen(BLACK); for(x=radius; x10; i-=5) { tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,tft.color565(0, i, i)); tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,tft.color565(i, i, 0)); } } unsigned long RoundRects() { unsigned long start; int w, i, i2,cx = tft.width() / 2 - 1,cy = tft.height() / 2 - 1; tft.fillScreen(BLACK); w = min(tft.width(), tft.height()); for(i=0; i20; i-=6) { i2 = i / 2; tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); } }