Ciao ragazzi..ho un problemino con lo sketch..in pratica vorrei usare le stesse funzioni della matrice keypad ma con imput touch. Ho impostato correttamente i quadrati numerati come la matrice con la funzione printNumI della libreria UTFT ma come potete vedere,nel update key quando premo la casella con il numero 1 riporta il valore a update key..il problema è che invece di stamparmi 1(una sola volta) me lo stampa ben 4 volte..in effetti visto il ciclo for non è neanche sbagliato..ma questo pezzo di codice è ripreso dal precedente con matrice fisica e non fà questo risultato.
Mi interesserebbe capire come "uppare" i tasti premuti in un array/stringa per poi confrontrarlo con la stringa preimpostata con il codice di accesso per poi ovviamente confrontarle con il consueto if.
Grazie per l'aiuto
void drawButtons() {
myGLCD.print("PIN:", 70, 10);
// Draw the upper row of buttons
for (x=0; x<5; x++)
{
myGLCD.setColor(VGA_WHITE);
myGLCD.fillRoundRect (10+(x*60), 70, 60+(x*60), 120);
myGLCD.setColor(VGA_BLACK);
myGLCD.drawRoundRect (10+(x*60), 70, 60+(x*60), 120);
myGLCD.printNumI(x+1, 27+(x*60), 87);
}
// Draw the center row of buttons
for (x=0; x<5; x++)
{
myGLCD.setColor(VGA_WHITE);
myGLCD.fillRoundRect (10+(x*60), 130, 60+(x*60), 180);
myGLCD.setColor(VGA_BLACK);
myGLCD.drawRoundRect (10+(x*60), 130, 60+(x*60), 180);
if (x<4)
myGLCD.printNumI(x+6, 27+(x*60), 147);
}
myGLCD.print("0", 267, 147);
// Draw the lower row of buttons
myGLCD.setColor(VGA_RED);
myGLCD.fillRoundRect (10, 190, 150, 240);
myGLCD.setColor(VGA_BLACK);
myGLCD.drawRoundRect (10, 190, 150, 240);
myGLCD.print("Clear", 40, 207);
myGLCD.setColor(VGA_GREEN);
myGLCD.fillRoundRect (160, 190, 300, 240);
myGLCD.setColor(VGA_BLACK);
myGLCD.drawRoundRect (160, 190, 300, 240);
myGLCD.print("Enter", 190, 207);
myGLCD.setBackColor (0, 0, 0);
}
void updateKey(int val)
{
int i = 0;
int s = 0;
int x = 0;
if(j<4) {
//stCurrent[stCurrentLen]=val;
// stCurrent[stCurrentLen+1]='\0';
//stCurrentLen++;
myGLCD.setFont(BigFont);
myGLCD.setBackColor(VGA_WHITE);
myGLCD.setColor(VGA_BLACK);
myGLCD.print(pswlenght, 140, 10);
pswlenght[j]=val;
j++;
}
}
void touchGetKey() {
if(myTouch.Pressed()) {
x=myTouch.X();
y=myTouch.Y();
if((y>=70) && (y<=120))
{
if((x>=10) && (x<=60))
{
updateKey('1');
}
}
}
}