I am currently trying to build an art stream deck with a 3.5" display.
So far I'm able to load several pages manually (controlled by "PAGE = ..."), everything works manually, but as soon as I uncomment the 3 lines of code for the touch function, the screen just stays black (the BMPs are somehow not loaded anymore) and I just can't figure out what the problem is.
I hope someone can help me
Here is my code (the three lowest lines are for touch):
String PAGE = "main";
String old_PAGE = "";
void loop()
{
if(PAGE != old_PAGE){
if (PAGE=="test"){
showBMP("up.bmp", 0*93+13, 0*100+20);//x,y
showBMP("b/01.bmp", 1*93+13, 0*100+20);//x,y
showBMP("b/02.bmp", 2*93+13, 0*100+20);//x,y
showBMP("b/03.bmp", 3*93+13, 0*100+20);//x,y
showBMP("b/04.bmp", 4*93+13, 0*100+20);//x,y
showBMP("b/05.bmp", 0*93+13, 1*100+20);//x,y
showBMP("b/06.bmp", 1*93+13, 1*100+20);//x,y
showBMP("b/07.bmp", 2*93+13, 1*100+20);//x,y
showBMP("b/08.bmp", 3*93+13, 1*100+20);//x,y
//showBMP("80.bmp", 4*93+13, 1*100+20);//x,y
showBMP("b/10.bmp", 0*93+13, 2*100+20);//x,y
showBMP("b/11.bmp", 1*93+13, 2*100+20);//x,y
showBMP("b/12.bmp", 2*93+13, 2*100+20);//x,y
showBMP("b/13.bmp", 3*93+13, 2*100+20);//x,y
showBMP("b/14.bmp", 4*93+13, 2*100+20);//x,y
}
else if (PAGE="main"){
showBMP("internet.bmp", 0*93+13, 0*100+20);//x,y
showBMP("rahmen.bmp", 1*93+13, 0*100+20);//x,y
showBMP("rahmen.bmp", 2*93+13, 0*100+20);//x,y
showBMP("gimp.bmp", 3*93+13, 0*100+20);//x,y
showBMP("joplin.bmp", 4*93+13, 0*100+20);//x,y
showBMP("rahmen.bmp", 0*93+13, 1*100+20);//x,y
showBMP("previous.bmp", 1*93+13, 1*100+20);//x,y
showBMP("play.bmp", 2*93+13, 1*100+20);//x,y
showBMP("next.bmp", 3*93+13, 1*100+20);//x,y
showBMP("spotify.bmp", 4*93+13, 1*100+20);//x,y
showBMP("blenderf.bmp", 0*93+13, 2*100+20);//x,y
showBMP("rahmen.bmp", 1*93+13, 2*100+20);//x,y
showBMP("blender.bmp", 2*93+13, 2*100+20);//x,y
showBMP("Signal.bmp", 3*93+13, 2*100+20);//x,y
showBMP("Firefox.bmp", 4*93+13, 2*100+20);//x,y
}
old_PAGE = PAGE;
}
//if (touch_button()=="button1"){
// PAGE="test";
//}
And here my function "touch_button()":
String touch_button(){
uint16_t xpos, ypos; //screen coordinates
tp = ts.getPoint(); //tp.x, tp.y are ADC values
// if sharing pins, you'll need to fix the directions of the touchscreen pins
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
if (tp.z > MINPRESSURE && tp.z < MAXPRESSURE){
xpos = map(tp.x, TS_LEFT, TS_RT, 0, tft.width());
ypos = map(tp.y, TS_TOP, TS_BOT, 0, tft.height());
if (((xpos >= 320)and(xpos <= 450))and((ypos >= 10)and(ypos <= 50))){
return String("button1");
}
if (((xpos >= 320)and(xpos <= 450))and((ypos >= 70)and(ypos <= 110))){
return String("button2");
}
if (((xpos >= 320)and(xpos <= 450))and((ypos >= 130)and(ypos <= 170))){
return String("button3");
}
if (((xpos >= 320)and(xpos <= 450))and((ypos >= 190)and(ypos <= 230))){
return String("button4");
}
if (((xpos >= 320)and(xpos <= 450))and((ypos >= 250)and(ypos <= 290))){
return String("button5");
}
if (((xpos >= 210)and(xpos <= 280))and((ypos >= 10)and(ypos <= 50))){
return String("button6");
}
if (((xpos >= 210)and(xpos <= 280))and((ypos >= 70)and(ypos <= 110))){
return String("button7");
}
if (((xpos >= 210)and(xpos <= 280))and((ypos >= 130)and(ypos <= 170))){
return String("button8");
}
if (((xpos >= 210)and(xpos <= 280))and((ypos >= 190)and(ypos <= 230))){
return String("button9");
}
if (((xpos >= 210)and(xpos <= 280))and((ypos >= 250)and(ypos <= 290))){
return String("button10");
}
if (((xpos >= 13)and(xpos <= 93))and((ypos >= 10)and(ypos <= 50))){
return String("button11");
}
if (((xpos >= 13)and(xpos <= 93))and((ypos >= 70)and(ypos <= 110))){
return String("button12");
}
if (((xpos >= 13)and(xpos <= 93))and((ypos >= 130)and(ypos <= 170))){
return String("button13");
}
if (((xpos >= 13)and(xpos <= 93))and((ypos >= 190)and(ypos <= 230))){
return String("button14");
}
if (((xpos >= 13)and(xpos <= 93))and((ypos >= 250)and(ypos <= 290))){
return String("button15");
}
}
return "";
}