Hola:
Estoy usando una pantalla tactil con arduino Mega. La pantalla en cuestion es esta
https://www.amazon.es/Kuman-Pantalla-Conector-Tarjeta-Funci%C3%B3n/dp/B075CXXL1M
He cogido un ejemplo que encontré y lo fui modificando a mi gusto.
Hago una pantalla de inicio con unos botones táctiles. En esa pantalla de inicio y con esos botones tactiles ajustas unos valores. Luego pulsas “ok” y pasas a la siguiente pantalla.
La siguiente pantalla es simplemente visual, es decir, no tiene ningún botón táctil. Solo muestra algo.
El problema que se ve que los botones táctiles de la anterior pantalla se ejecutan en segundo plano. Y si pulsas donde estaban, VOILA, aparecen por arte de magia.
He probado a hacer un reset en el inicio de la segunda pantalla (como veis en el código), pero se siguen ejecutado.
Probando en poner los botones en “false”, pero me hace cosas raras…
en fin ¿como puedo desahbilitar unos botones tactiles?
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.
//Technical support:goodtft@163.com
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>
// les meves variables
int temp = 40;
int tiemposecado = 30;
int tiempoenfriado = 40;
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
// Color definitions
#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
#define ILI9341_NAVY 0x000F /* 0, 0, 128 */
#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */
#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */
#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */
#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */
#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */
#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */
#define ILI9341_BLUE 0x001F /* 0, 0, 255 */
#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */
#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */
#define ILI9341_RED 0xF800 /* 255, 0, 0 */
#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */
#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */
#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */
#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */
#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ILI9341_PINK 0xF81F
/******************* UI details */
#define BUTTON_X 52
#define BUTTON_Y 150
#define BUTTON_W 80
#define BUTTON_H 45
#define BUTTON_SPACING_X 26
#define BUTTON_SPACING_Y 30
#define BUTTON_TEXTSIZE 3
#define MINPRESSURE 5
#define MAXPRESSURE 1000
// text box where numbers go
#define TEXT_X 10
#define TEXT_Y 10
#define TEXT_W 300
#define TEXT_H 50
#define TEXT_TSIZE 2
#define TEXT_TCOLOR ILI9341_MAGENTA
// the data (phone #) we store in the textfield
#define TEXT_LEN 16
char textfield[TEXT_LEN+1] = "";
uint8_t textfield_i=0;
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 8 // can be a digital pin
#define XP 9 // can be a digital pin
#define TS_MINX 130
#define TS_MAXX 905
#define TS_MINY 75
#define TS_MAXY 930
// We have a status line for like, is FONA working
#define STATUS_X 10
#define STATUS_Y 65
Adafruit_GFX_Button buttons[15];
/* create 15 buttons, in classic candybar phone style */
char buttonl[15][5] = {"Run", "Mate", "Stop", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#" };
uint16_t buttoncolors[15] = {ILI9341_DARKGREEN, ILI9341_DARKGREY, ILI9341_RED, ILI9341_BLUE, ILI9341_BLUE, ILI9341_BLUE, ILI9341_BLUE, ILI9341_BLUE, ILI9341_BLUE, ILI9341_BLUE, ILI9341_BLUE, ILI9341_BLUE,ILI9341_ORANGE, ILI9341_BLUE, ILI9341_ORANGE};
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Adafruit_TFTLCD tft;
int entrada; int aaa; int bbb;
int Barra1En;
String MissatgeVellP2;
void setup(void) {
Serial.begin(9600);
Serial.println(F("TFT LCD test"));
tft.reset();
uint16_t identifier = tft.readID();
if(identifier == 0x9325) {Serial.println(F("Found ILI9325 LCD driver"));}
else if(identifier == 0x9328) {Serial.println(F("Found ILI9328 LCD driver"));}
else if(identifier == 0x4535) {Serial.println(F("Found LGDP4535 LCD driver"));}
else if(identifier == 0x7575) {Serial.println(F("Found HX8347G LCD driver"));}
else if(identifier == 0x9341) {Serial.println(F("Found ILI9341 LCD driver"));}
else if(identifier == 0x7783) {Serial.println(F("Found ST7781 LCD driver"));}
else if(identifier == 0x8230) {Serial.println(F("Found UC8230 LCD driver"));}
else if(identifier == 0x8357) {Serial.println(F("Found HX8357D LCD driver"));}
else if(identifier==0x0101) {identifier=0x9341;Serial.println(F("Found 0x9341 LCD driver"));}
else if(identifier==0x9481){Serial.println(F("Found 0x9481 LCD driver"));}
else if(identifier==0x9486){Serial.println(F("Found 0x9486 LCD driver"));}
else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial.")); identifier=0x9486;
}
tft.begin(identifier);
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
}
void loop(void) {
Pprincipal();
}