#include <Adafruit_FT6206.h>
#include <Wire.h>
#include <Adafruit_ILI9341.h>
#define GRAY 0x4A69
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_ILI9341 tft = Adafruit_ILI9341(10,9);
Adafruit_FT6206 ts = Adafruit_FT6206();
//240x320
void setup(void) {
Serial.begin(9600);
tft.begin();
ts.begin();
}
void loop(void) {
home();
}
TS_Point waitForTouch(){
while (!ts.touched()){}
TS_Point p = ts.getPoint();
p.x = map(p.x,0,240,240,0);
p.y = map(p.y,0,320,320,0);
return p;
}
void home() {
tft.fillRect(0,10,240,320,GRAY);
tft.fillRect(20,250,80,40,GREEN);
tft.fillRect(140,250,80,40,BLUE);
tft.setCursor(30,20);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print("Assalamualaikum");
tft.setTextSize(3);
tft.setCursor(24,258);
tft.print("Psan");
tft.setCursor(144,258);
tft.print("Telp");
c:TS_Point p = waitForTouch();
if (checkButton(p,20,250,80,40)){
//sms();
numpad();
}else if(checkButton(p,140,250,80,40)){
//telp();
}else{
goto c;
}
}
void numpad(){
tft.fillRect(0,10,240,320,GRAY);
int num[3][3]={{1,2,3},{4,5,6},{7,8,9}};
String alphabet[3][3]={{"abc","def","ghi"},{"jkl","mno","pqr"},{"stuv","wxyz","\" \""}};
tft.setTextColor(BLACK);
for (int x=1;x<5;x++){
for (int y=1;y<4;y++){
tft.fillRoundRect(-25+(50*x),120+(50*y),40,40,10,WHITE);
}
}
for (int x=1;x<4;x++){
for (int y=1;y<4;y++){
tft.setCursor(-10+(50*x),130+(50*y));
tft.setTextSize(2);
tft.print(num[y-1][x-1]);
tft.setCursor(-14+(50*x),148+(50*y));
tft.setTextSize(1);
tft.print(alphabet[y-1][x-1]);
}
}
tft.setCursor(181,186);
tft.print("Hapus");
tft.setTextSize(2);
tft.setCursor(190,230);
tft.print(0);
tft.setCursor(185,280);
tft.print("ok");
int x,y,expi=1;
c:TS_Point p =
for (x=1;x<5;x++){
for (y=1;y<4;y++){
if (checkButton(p,-25+(50*x),120+(50*y),40,40)){
stroke(x,y);
}
}
}
goto c;
}
void stroke(int x,int y){
int oldTime = micros()/100000,timeexp = 1;
}
void debug(){
TS_Point pos = ts.getPoint();
pos.x = map(pos.x,0,240,240,0);
pos.y = map(pos.y,0,320,320,0);
Serial.print("( ");
Serial.print(pos.x);
Serial.print(" , ");
Serial.print(pos.y);
Serial.println(" )");
}
int checkButton(TS_Point p,int x,int y,int dx,int dy) {
if ((p.x > x-1 && p.x < (x+dx)-1)&&(p.y > y-1 && p.y < (y+dy)-1)){
return true;
}
return false;
}