/***************************************************
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
----> http://www.adafruit.com/products/1651
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "Vector.h"
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
// 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);
class line {
int x0,x1,y0,y1;
uint16_t col;
public:
line(int A0, int A1, int C0, int C1, uint16_t color):x0(A0),x1(A1),y0(C0),y1(C1),col(color)
{}
void draw(Adafruit_ILI9341 &tft){
tft.drawLine(x0,x1,y0,y1,col);
}
void display()
{ Serial.print("Line values: ");
Serial.print("x0=");
Serial.print(x0);
Serial.print(",");
Serial.print("x1=");
Serial.print(x1);
Serial.print(",");
Serial.print("y0=");
Serial.print(y0);
Serial.print(",");
Serial.print("y1=");
Serial.print(y1);
Serial.print("\n"); }
};
void setup() {
Serial.begin(9600);
Serial.println("Welcome to C++ Learning");
tft.begin();
}
void loop(void) {
//diagonal
Vector<line> v1;
for(int i=0;i<10;++i){
line l1(10 + i * 10, 10 + i * 10, 20 + i * 10, 20 + i * 10,ILI9341_YELLOW);
v1.push_back(l1);
l1.draw(tft);
Serial.print(i+1);Serial.print(")");
l1.display();
delay(1000);
}
//Vertical line
Vector<line> v2;
for(int i=0;i<10;++i){
line l2(10 , 10 + i * 10, 10 , 20 + i * 10,ILI9341_YELLOW);
v2.push_back(l2);
l2.draw(tft);
Serial.print(i+1);Serial.print(")");
l2.display();
delay(1000);
}
//Horizontal line
Vector<line> v3;
for(int i=0;i<10;++i){
line l3(10 + i * 10, 10 , 20 + i * 10, 10, ILI9341_YELLOW);
v3.push_back(l3);
l3.draw(tft);
Serial.print(i+1);Serial.print(")");
l3.display();
delay(1000);
}
}