Problema TFT Touch ITDB 2.8


olá todos, este forum tem sido bastante positivo no que diz respeito resolução de problemas e tenho encontrado muitas soluções para dúvidas que tenho encontrado nos outros tópicos, mas ainda não encontrei nada sobre o meu problema!!!

tenho um arduino uno r3 com tft touch itdb 2.8 e libraria que tirei seguinte site:

http://www.henningkarlsen.com/electronics/library.php?id=55
e
http://www.henningkarlsen.com/electronics/library.php?id=51

foi o que me indicaram para poder colocar á prova o tft  :)

tive então de mudar apenas um parametro no código e ele carregou direito e aparece os botões no ecrã para eu tocar mas nada feito!!! já li e re-li mesmo o um ficheiro que vem com o codigo e não tenho por onde lhe pegar!!!

segue abaixo o código:

code: [select]
// utouch_buttontest (c)2010-2012 henning karlsen
// web: http://www.henningkarlsen.com/electronics
//
// program quick demo of how create , use buttons.
//
// program requires utft library.
//
// assumed display module connected an
// appropriate shield or know how change pin
// numbers in setup.
//

#include <utft.h>
#include <utouch.h>

// declare fonts using
extern uint8_t bigfont[];

// uncomment next 2 lines arduino 2009/uno
utft        myglcd(itdb28,19,18,17,16);   // remember change model parameter suit display module!
utouch      mytouch(15,10,14,9,8);

int x, y;
char stcurrent[20]="";
int stcurrentlen=0;
char stlast[20]="";

/*************************
**   custom functions   **
*************************/

void drawbuttons()
{
// draw upper row of buttons
 for (x=0; x<5; x++)
 {
   myglcd.setcolor(0, 0, 255);
   myglcd.fillroundrect (10+(x*60), 10, 60+(x*60), 60);
   myglcd.setcolor(255, 255, 255);
   myglcd.drawroundrect (10+(x*60), 10, 60+(x*60), 60);
   myglcd.printnumi(x+1, 27+(x*60), 27);
 }
// draw center row of buttons
 for (x=0; x<5; x++)
 {
   myglcd.setcolor(0, 0, 255);
   myglcd.fillroundrect (10+(x*60), 70, 60+(x*60), 120);
   myglcd.setcolor(255, 255, 255);
   myglcd.drawroundrect (10+(x*60), 70, 60+(x*60), 120);
   if (x<4)
     myglcd.printnumi(x+6, 27+(x*60), 87);
 }
 myglcd.print("0", 267, 87);
// draw lower row of buttons
 myglcd.setcolor(0, 0, 255);
 myglcd.fillroundrect (10, 130, 150, 180);
 myglcd.setcolor(255, 255, 255);
 myglcd.drawroundrect (10, 130, 150, 180);
 myglcd.print("clear", 40, 147);
 myglcd.setcolor(0, 0, 255);
 myglcd.fillroundrect (160, 130, 300, 180);
 myglcd.setcolor(255, 255, 255);
 myglcd.drawroundrect (160, 130, 300, 180);
 myglcd.print("enter", 190, 147);
 myglcd.setbackcolor (0, 0, 0);
}

void updatestr(int val)
{
 if (stcurrentlen<20)
 {
   stcurrent[stcurrentlen]=val;
   stcurrent[stcurrentlen+1]='\0';
   stcurrentlen++;
   myglcd.setcolor(0, 255, 0);
   myglcd.print(stcurrent, left, 224);
 }
 else
 {
   myglcd.setcolor(255, 0, 0);
   myglcd.print("buffer full!", center, 192);
   delay(500);
   myglcd.print("            ", center, 192);
   delay(500);
   myglcd.print("buffer full!", center, 192);
   delay(500);
   myglcd.print("            ", center, 192);
   myglcd.setcolor(0, 255, 0);
 }
}

// draw red frame while button touched
void waitforit(int x1, int y1, int x2, int y2)
{
 myglcd.setcolor(255, 0, 0);
 myglcd.drawroundrect (x1, y1, x2, y2);
 while (mytouch.dataavailable())
   mytouch.read();
 myglcd.setcolor(255, 255, 255);
 myglcd.drawroundrect (x1, y1, x2, y2);
}

/*************************
**  required functions  **
*************************/

void setup()
{
// initial setup
 myglcd.initlcd();
 myglcd.clrscr();

 mytouch.inittouch();
 mytouch.setprecision(prec_medium);

 myglcd.setfont(bigfont);
 myglcd.setbackcolor(0, 0, 255);
 drawbuttons();  
}

void loop()
{
 while (true)
 {
   if (mytouch.dataavailable())
   {
     mytouch.read();
     x=mytouch.getx();
     y=mytouch.gety();
     
     if ((y>=10) && (y<=60))  // upper row
     {
       if ((x>=10) && (x<=60))  // button: 1
       {
         waitforit(10, 10, 60, 60);
         updatestr('1');
       }
       if ((x>=70) && (x<=120))  // button: 2
       {
         waitforit(70, 10, 120, 60);
         updatestr('2');
       }
       if ((x>=130) && (x<=180))  // button: 3
       {
         waitforit(130, 10, 180, 60);
         updatestr('3');
       }
       if ((x>=190) && (x<=240))  // button: 4
       {
         waitforit(190, 10, 240, 60);
         updatestr('4');
       }
       if ((x>=250) && (x<=300))  // button: 5
       {
         waitforit(250, 10, 300, 60);
         updatestr('5');
       }
     }

     if ((y>=70) && (y<=120))  // center row
     {
       if ((x>=10) && (x<=60))  // button: 6
       {
         waitforit(10, 70, 60, 120);
         updatestr('6');
       }
       if ((x>=70) && (x<=120))  // button: 7
       {
         waitforit(70, 70, 120, 120);
         updatestr('7');
       }
       if ((x>=130) && (x<=180))  // button: 8
       {
         waitforit(130, 70, 180, 120);
         updatestr('8');
       }
       if ((x>=190) && (x<=240))  // button: 9
       {
         waitforit(190, 70, 240, 120);
         updatestr('9');
       }
       if ((x>=250) && (x<=300))  // button: 0
       {
         waitforit(250, 70, 300, 120);
         updatestr('0');
       }
     }

     if ((y>=130) && (y<=180))  // upper row
     {
       if ((x>=10) && (x<=150))  // button: clear
       {
         waitforit(10, 130, 150, 180);
         stcurrent[0]='\0';
         stcurrentlen=0;
         myglcd.setcolor(0, 0, 0);
         myglcd.fillrect(0, 224, 319, 239);
       }
       if ((x>=160) && (x<=300))  // button: enter
       {
         waitforit(160, 130, 300, 180);
         if (stcurrentlen>0)
         {
           for (x=0; x<stcurrentlen+1; x++)
           {
             stlast[x]=stcurrent[x];
           }
           stcurrent[0]='\0';
           stcurrentlen=0;
           myglcd.setcolor(0, 0, 0);
           myglcd.fillrect(0, 208, 319, 239);
           myglcd.setcolor(0, 255, 0);
           myglcd.print(stlast, left, 208);
         }
         else
         {
           myglcd.setcolor(255, 0, 0);
           myglcd.print("buffer empty", center, 192);
           delay(500);
           myglcd.print("            ", center, 192);
           delay(500);
           myglcd.print("buffer empty", center, 192);
           delay(500);
           myglcd.print("            ", center, 192);
           myglcd.setcolor(0, 255, 0);
         }
       }
     }
   }
 }
}


agradeço toda ajuda  ;)

quote
tive então de mudar apenas um parametro no código e ele carregou direito e aparece os botões no ecrã para eu tocar mas nada feito!!! já li e re-li mesmo o um ficheiro que vem com o codigo e não tenho por onde lhe pegar!!!

o que é o nada feito?
vez imagem ou o touch nao funciona apenas?
olhando ao teu codigo chamou me atençao isto:
code: [select]
void loop()
{
  while (true)
  {
   

certamente isto nada tem ver com solução para o teu problema mas porque é que tens um infinite loop dentro de outro?
o void loop() por si só já é um ciclo infinito.
tens o datasheet tft
como é ligado o touch ao arduino?


Arduino Forum > International > Portugues > Problema TFT Touch ITDB 2.8


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support