Help with coding of TFT LCD Touch!!!
hi guys!!!
i have problem touch. have set code when touch point of screen in page 1 takes page 2. @ page 2 @ same point of screen there other statement takes page 1. problem when @ page 1 , touch point of screen takes me page 2 , takes me page 1. how possible make taking me page 2 , stays there until touch again screen? have tried putting delay didn't help. took me again page 1 again delay programmed it.
here code:
i have problem touch. have set code when touch point of screen in page 1 takes page 2. @ page 2 @ same point of screen there other statement takes page 1. problem when @ page 1 , touch point of screen takes me page 2 , takes me page 1. how possible make taking me page 2 , stays there until touch again screen? have tried putting delay didn't help. took me again page 1 again delay programmed it.
here code:
code: [select]
#include <utouch.h>
#include <utouchcd.h>
#include <memorysaver.h>
#include <utft.h>
utft myglcd(itdb32s,38,39,40,41);
utouch mytouch(6,5,4,3,2);
extern uint8_t bigfont[];
extern uint8_t smallfont[];
extern uint8_t sevensegnumfont[];
int led = 0;
int page = 0;
int x, y;
void setup(){
myglcd.initlcd(landscape);
myglcd.clrscr();
mytouch.inittouch(landscape);
mytouch.setprecision(prec_medium);
mainscr();
}
void loop(){
if (true)
{
if (mytouch.dataavailable())
{
mytouch.read();
x=mytouch.getx();
y=mytouch.gety();
if (page == 1)
{
if ((x>=20) && (x<=170))
{
if ((y>=49) && (y<=65))
{
testpage2();
}
}
}
if (page == 2)
{
if ((x>=20) && (x<=170))
{
if ((y>=49) && (y<=65))
{
mainscr();
}
}
}
}
}
}
void testpage2() {
page = 2;
myglcd.clrscr();
myglcd.fillscr(0, 0, 0);
myglcd.setbackcolor (0, 0, 0);
myglcd.setfont(smallfont);
myglcd.setcolor(255, 255, 255);
myglcd.print("testbutton", 25, 53);
}
void mainscr() {
page = 1;
myglcd.fillscr(0, 0, 0);
myglcd.setbackcolor (0, 0, 0);
myglcd.setfont(smallfont);
myglcd.setcolor(255, 255, 255);
myglcd.setbackcolor (0, 0, 0);
myglcd.print("enable led", 25, 53);
}
Arduino Forum > Using Arduino > Displays > Help with coding of TFT LCD Touch!!!
arduino
Comments
Post a Comment