#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#ifdef SEEEDUINO
#define YP A2 // must be an analog pin, use “An” notation!
#define XM A1 // must be an analog pin, use “An” notation!
#define YM A0 // can be a digital pin, this is A0
#define XP A3 // can be a digital pin, this is A3
#endif
#define TS_MINX 140
#define TS_MAXX 900
#define TS_MINY 120
#define TS_MAXY 940
int GREENled = 30;
int REDled = 31;
int YELLOWled = 32;
int BLUEled = 33;
void setup()
{
Tft.init(); //init TFT library
pinMode(0,OUTPUT);
pinMode(GREENled, OUTPUT);
pinMode(REDled, OUTPUT);
pinMode(YELLOWled, OUTPUT);
pinMode(BLUEled, OUTPUT);
// X-Y-Length-Height //
Tft.fillRectangle(0, 0, 240, 320, WHITE); //Background
Tft.fillRectangle(0, 0, 240, 12, BLUE); //blue bar
Tft.fillRectangle(212, 1, 21, 10, BLACK); // battery body
Tft.fillRectangle(210, 3, 2, 6, BLACK); // battery tip
Tft.fillRectangle(219, 2, 13, 8, GREEN); // battery level at FULL —> (201, 2, 19, 8, GREEN);
//statusbar
Tft.drawString(“Romny 12/31/12”,5, 4, 1, YELLOW);
//4 squares
Tft.fillRectangle(30, 50, 80, 80, RED);//1
Tft.fillRectangle(130, 50, 80, 80, GREEN);//2
Tft.fillRectangle(30, 160, 80, 80, BLUE);//3
Tft.fillRectangle(130, 160, 80, 80, YELLOW);//4
//square Label
Tft.drawString(“LED1”,40, 80, 2, BLACK);
Tft.drawString(“LED2”,40, 190, 2, BLACK);
Tft.drawString(“LED3”,135, 80, 2, BLACK);
Tft.drawString(“LED4”,135, 190, 2, BLACK);
}
void loop () {
int MapX1 = 239;
int MapX2 = 0;
int MapY1 = 319;
int MapY2 = 0;
// a point object holds x y and z coordinates
Point p = ts.getPoint();
p.x = map(p.x, TS_MINX, TS_MAXX, MapX1, MapX2);
p.y = map(p.y, TS_MINY, TS_MAXY, MapY1, MapY2);
// we have some minimum pressure we consider ‘valid’
// pressure of 0 means no pressing!
if (p.z > ts.pressureThreshhold) {
//If you get here, someone is touching the screen at (p.x, p.y) coordinates.
//p.z has how hard they are pressing.
Tft.fillCircle(p.x,p.y,2,GREEN);
// The corners of button 1 are (30,50) and (80,80)
if (p.x > 30 && p.x < 80 && p.y > 50 && p.y < 80) {
//Put your code that turns on the LED Here.
digitalWrite(REDled, HIGH);
delay(1000);
}
}
}