Problème code écran tactile elegoo

Bonjour, voici mon problème
J'utilise un écran tactile elegoo (https://www.amazon.fr/ELEGOO-Tactile-320x240-Technical-Arduino/dp/B01JD4TJZU)

J'ai une page d’accueil et un bouton aide (?). Lorsque je clique dessus il m'affiche une seconde page. J'ai fait un bouton retour pour revenir en arrière, mais celui ci ne fonctionne pas
Sauriez vous pourquoi ?
Pourquoi mon code n'est pas correct ?
Merci d’avance
Bonne journée

#include <Elegoo_GFX.h>
#include <Elegoo_TFTLCD.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  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
#define NAVY        0x000F      /*   0,   0, 128 */
#define DARKGREEN   0x03E0      /*   0, 128,   0 */
#define DARKCYAN    0x03EF      /*   0, 128, 128 */
#define MAROON      0x7800      /* 128,   0,   0 */
#define PURPLE      0x780F      /* 128,   0, 128 */
#define OLIVE       0x7BE0      /* 128, 128,   0 */
#define LIGHTGREY   0xC618      /* 192, 192, 192 */
#define DARKGREY    0x7BEF      /* 128, 128, 128 */
#define MAGENTA     0xF81F      /* 255,   0, 255 */
#define ORANGE      0xFD20      /* 255, 165,   0 */
#define GREENYELLOW 0xAFE5      /* 173, 255,  47 */
#define PINK        0xF81F


#define YP A3  
#define XM A2  
#define YM 9   
#define XP 8   

//Touch For New ILI9341 TP
#define TS_MINX 120
#define TS_MAXX 900

#define TS_MINY 70
#define TS_MAXY 920

#define STATUS_X 10
#define STATUS_Y 65



Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

int boutton;




void setup() {
  Serial.begin(9600);
  Serial.print("Starting...");

  tft.reset();
  tft.begin(0x9341);
  tft.setRotation(1);

  tft.fillScreen(BLACK); //ecran noir debut

  //Draw white frame
  tft.drawRect(0, 0, 319, 240, RED);

  //Je conserve mon box ?
  tft.setCursor(56, 30); //largeur, hauteur
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print("Je conserve");
  tft.setCursor(70, 60); //largeur, hauteur
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print(" mon box ?");

  //OUI
  tft.fillRect(40, 170, 100, 40, RED); //x:x coordonnée du point de départ // y:y coordonnée du point de départ /*/ w:la longueur du carré /*/   h:la largeur du carré couleur: la couleur du carré
  tft.drawRect(40, 170, 100, 40, WHITE);
  tft.setCursor(65, 178);
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print("oui");

  //NON
  tft.fillRect(176, 170, 100, 40, RED);
  tft.drawRect(176, 170, 100, 40, WHITE);
  tft.setCursor(183, 178);
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print(" non");

  //Aide ?
  tft.drawCircle(152, 129, 20, BLUE);
  tft.fillCircle(152, 129, 20, BLUE);
  tft.setCursor(145, 120);
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print("?");


  boutton = 0;


}


void ecranacceuil ()
{
  tft.fillScreen(BLACK); //ecran noir debut

  //Draw white frame
  tft.drawRect(0, 0, 319, 240, RED);

  //Je conserve mon box ?
  tft.setCursor(56, 30); //largeur, hauteur
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print("Je conserve");
  tft.setCursor(70, 60); //largeur, hauteur
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print(" mon box ?");

  //OUI
  tft.fillRect(40, 170, 100, 40, RED); //x:x coordonnée du point de départ // y:y coordonnée du point de départ /*/ w:la longueur du carré /*/   h:la largeur du carré couleur: la couleur du carré
  tft.drawRect(40, 170, 100, 40, WHITE);
  tft.setCursor(65, 178);
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print("oui");

  //NON
  tft.fillRect(176, 170, 100, 40, RED);
  tft.drawRect(176, 170, 100, 40, WHITE);
  tft.setCursor(183, 178);
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print(" non");

  //Aide ?
  tft.drawCircle(152, 129, 20, BLUE);
  tft.fillCircle(152, 129, 20, BLUE);
  tft.setCursor(145, 120);
  tft.setTextColor(WHITE);
  tft.setTextSize(3);
  tft.print("?");


}


void loop()
{
  TSPoint p = ts.getPoint();  //position doigts

  if (p.z > ts.pressureThreshhold) {
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\n"); //retour ligne



    //Bouton OUI
    if (p.x > 223 && p.x < 348 && p.y > 537 && p.y < 800 && boutton == 0) 
    {

      pinMode(XM, OUTPUT);
      pinMode(YP, OUTPUT);
      boutton = 1; //desactive  bouton


      //Bouton OUI
      tft.fillScreen(BLACK);
      tft.drawRect(0, 0, 319, 240, RED);
      tft.setCursor(50, 50);
      tft.setTextColor(WHITE);
      tft.setTextSize(3);
      tft.print("OUI");
    }


    //Bouton NON
    if (p.x > 253 && p.x < 322 && p.y > 169 && p.y < 475 && boutton == 0)
    {


      pinMode(XM, OUTPUT);
      pinMode(YP, OUTPUT);
      boutton = 1; //desactive  bouton


      //Bouton NON
      tft.fillScreen(BLACK);
      //Draw frame
      tft.drawRect(0, 0, 319, 240, WHITE);
      tft.setCursor(50, 50);
      tft.setTextColor(WHITE);
      tft.setTextSize(3);
      tft.print("NON");
    }


    //Bouton AIDE
    if (p.x > 400 && p.x < 560 && p.y > 456 && p.y < 556 && boutton == 0)
    {


      pinMode(XM, OUTPUT);
      pinMode(YP, OUTPUT);
      boutton = 1; //desactive  bouton


      //Bouton AIDE
      tft.fillScreen(BLACK);
      //Draw frame
      tft.drawRect(0, 0, 319, 240, RED);
      tft.setCursor(50, 50);
      tft.setTextColor(WHITE);
      tft.setTextSize(3);
      tft.print("AIDE texte ");

      //fleche retour

      tft.fillRect(20, 178, 130, 40, LIGHTGREY);
      tft.drawRect(20, 178, 130, 40, WHITE);
      tft.setCursor(20, 185);//y et x
      tft.setTextColor(WHITE);
      tft.setTextSize(3);
      tft.print(" retour");
      Serial.print(boutton);

    
      if (p.x > 185 && p.x < 329 && p.y > 500 && p.y < 850 && boutton == 1)
      {

        pinMode(XM, OUTPUT);
        pinMode(YP, OUTPUT);
        boutton = 0; //bouton acceuil remarche
        Serial.print("ok");
        ecranacceuil();

      }
    }

    delay(5);
  }
}

regardez l'imbrication de vos if

  if (p.z > ts.pressureThreshhold) {
    //Bouton OUI
    if (p.x > 223 && p.x < 348 && p.y > 537 && p.y < 800 && boutton == 0) {
    }

    //Bouton NON
    if (p.x > 253 && p.x < 322 && p.y > 169 && p.y < 475 && boutton == 0) {
    }

    //Bouton AIDE
    if (p.x > 400 && p.x < 560 && p.y > 456 && p.y < 556 && boutton == 0) {
[color=red]      if (p.x > 185 && p.x < 329 && p.y > 500 && p.y < 850 && boutton == 1) {
      }[/color]
    }
  }

merci beaucoup!

vous devriez écrire des fonctions pour chaque "if" et chaque dessin, ça rendrait la loop beaucoup plus lisible

vous pourriez aussi écrire une fonction qui teste si un point est dans un rectangle donné (éventuellement avec ces points dans une structure 'rectangle', ça rendrait vos if plus simple à lire)