//***SPFD5408 change Begin
#include <SPFD5408_Adafruit_GFX.h> // Core graphics library
#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library
#include <SPFD5408_TouchScreen.h>
// *** SP D5408 change -- End
#if defined( SAM3X8E__)
#undef FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
#define LCD_CS 15
#define LCD_RESET 4
#define LCD_DC 2
#define LCD_MOSI 23
#define LCD_SCK 18
#define LCD_MISO 19
#define LED_PIN 13
#define BLACK 0х0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define YP A3
#define XM A2
#define YM 9
#define XP 8
#define TS MINX 125
#define TS MINY 85
#define TS MAXX 965
#define TS MAXY 905
TouchScreen ts = TouchScreen (XP, YP, XM, YM, 300);
Adafruit_TFTLCD tft (LCD_CS, LCD RESET, LCD_DC, LCD_MOSI, LCD_SCK, LCD_MISO );
#define BOXSIZE 40 I
#define PENRADIUS 3
#define MINPRESSURE 10
#define MAXPRESSURE 1000
int touch = 0;
void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
Serial.begin(9600);
tft.reset();
tft.begin(0x9341);//change it to 09341
tft.setTextColor(BLACK);
tft.setTextSize(2.5);
tft.fillScreen (BLACK);
tft.fillRect(0, 0, 120, 120, BLUE);
tft.fillRect(120, 0, 120, 120, YELLOW);
tft.setCursor(15, 45);
tft.println("LED ON");
tft.setCursor(128, 45);
tft.println("LED OFF");
tft.setTextSize(2);
tft.setCursor(8,150);
tft.println("Use the touchscreen to operate the LED");
tft.setCursor(24,200);
tft.println("Congratulations...");
tft.setTextSize(2);
tft.setCursor(90,220);
tft.println("/it works");
tft.setCursor(80,300);
tft.println("Hurrah!");
}
void loop() {
TSPoint p =ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
p.x > =map(p.x, TS MINX, TS_MAXX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
Serial.print("("); Serial.print(p.x);
Serial.print(", "); Serial.print(p.y);
Serial.println(")");
if (p.x > 0 && p.x < 120) {
if (p.y && p.y < 120) {
touch = 1;
}
}
}
if (p.x 120 && p.x <240) {
if (p.y && p.y < 120) {
touch = 2;
}
}
if (touch 1) {
digitalWrite(LED_PIN, HIGH);
touch = 0;
delay(200);
}
if (touch 2) {
digitalWrite(LED_PIN, LOW);
touch = 0;
delay(200);
}
}