Hello everyone, im currently working on a project.
I found a code that worked well for me , but the only problem is that this code only gives 1 page, when i tried using the same things the code user did ( to get another page ), it didnt work , here is the code that i have currently
#include <Adafruit_TFTLCD.h>
#include <Adafruit_GFX.h>
#include <TouchScreen.h>
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define TS_MINX 240
#define TS_MINY 192
#define TS_MAXX 1014
#define TS_MAXY 1006
#define XM A1
#define YP A2
#define XP 7
#define YM 6
#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_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 364);
boolean buttonEnabled = true;
void setup() {
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(0x7575);
tft.setRotation(1);
tft.fillScreen(WHITE);
tft.drawRect(0,0,319,240,YELLOW);
tft.setCursor(30,40);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.print("By : Akram Berjaoui");
tft.setCursor(30,80);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.print("Commencer\n\n Veuillez cliquer sur:");
tft.setCursor(10,150);
tft.setTextColor(BLUE);
tft.setTextSize(2);
tft.print("Bonjour cher utilisateur");
tft.fillRect(50,180, 210, 40, RED);
tft.drawRect(50,180,210,40,BLACK);
tft.setCursor(60,190);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print(" Commencer");
}
void loop() {
TSPoint p = ts.getPoint();
if (p.z > ts.pressureThreshhold) {
p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
p.y = map(p.y, TS_MAXY, TS_MINY, 0, 480);
if(p.x>50 && p.x<260 && p.y>180 && p.y<270 && buttonEnabled){
buttonEnabled = false;
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
tft.fillScreen(WHITE);
tft.drawRect(0,0,319,240,YELLOW);
tft.setCursor(30,150);
tft.setTextColor(BLACK);
tft.setTextSize(3);
tft.print(" vous faire?\n Que voulez");
tft.fillRect(50,60, 210, 40, RED);
tft.drawRect(50,60,210,40,BLACK);
tft.setCursor(40,70);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print(" Preparer du cafe");
tft.fillRect(50,100, 210, 40, RED);
tft.drawRect(50,100,210,40,BLACK);
tft.setCursor(40,110);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print(" Voir Etat du Cafe");
tft.fillRect(50,20, 210, 40, RED);
tft.drawRect(50,20,210,40,BLACK);
tft.setCursor(40,30);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print(" Sortir");
p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
p.y = map(p.y, TS_MAXY, TS_MINY, 0, 480);
}
}
}
this is what it shows me at the start
and this is what it shows after i click on "commencer"
now when i try to do the samething again while changing the value of which p.x should be > < , nothing still shows up after i click on either of the 3 options..
hope u can help me , ty