Skip to content

Buttons from the previous page, on the new menu page. #3127

@Daevid8

Description

@Daevid8

Hello Bodmer.
I have a problem with the TFT_eSPI library, more specifically with the menu display. Based on the example from the library, I wanted to create a menu. Everything went very well thanks to your library, for which I thank you very much, but I have a problem with reading the touch buttons on individual pages. More precisely, the point is that after switching to the next page in the menu, all buttons from previous pages can still be pressed as if in the background. They are not visible, but they can be pressed, which unfortunately causes a big problem because the menu buttons are in the same places. I hope you can help me, thank you in advance.
My touch display is 2.8" TFT ST7789.
Sorry for any language errors. I have to use a translator because English is not my language. Below is a fragment of the code.

void loop() {


  //uruchomienie akcja.attach
  akcja.process();

  // Pobierz dane z DS1302
  t = rtc.getTime();

 
  uint16_t t_x = 0, t_y = 0;              // współrzędne pulsacji
  bool pressed = tft.getTouch(&t_x, &t_y);  // prawda po naciśnięciu


  // Sprawdź, czy kliknąłeś obszar przycisku
  for (uint8_t b = 0; b < totalButtonNumber; b++) {
    if (pressed && key[b].contains(t_x, t_y)) {
      key[b].press(true);
      Serial.print(t_x);
      Serial.print(",");
      Serial.println(t_y);
    } else {
      key[b].press(false);
    }
  }


  // Akcja po naciśnięciu przycisku
  for (uint8_t b = 0; b < totalButtonNumber; b++) {

    if (key[b].justReleased()) {
      key[b].drawButton();  // przerysuj po wydaniu

      switch (b) {
        case 0:
          //ekran1
          break;
        case 1:
          //ekran2
          break;
        case 2:
          //ekran3
          break;
        case 3:
          //ekran4
          break;
        case 4:
          //
          break;
        case 5:
          //
          break;
        case 6:
          //
          break;
        case 7:
          //
          break;
        case 8:
          //
          break;
        default:
          delay(1);
          // sprawozdania
          return;
      }
    }
    if (key[b].justPressed()) {
      key[b].drawButton(true);  // zmienia kolor przycisku po naciśnięciu
      delay(10);                
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions