I am trying to use an ELEGOO TouchShield with and Arduino Uno to have multiple screens. Screens will load based on the area of the screen, which I'm referring to as a button, pressed and which screen is currently active. I've been modifying the MCUFRIEND_kbv showBMP_kbv_uno code, and I can get the first image to load.
However, when I attempt to load a second image, it remains on the same one despite the serial console telling me it has loaded the other image file. Upon then trying to load the first file again, the screen goes white and remains that way. Here is the modified version of my Loop code.
void loop()
{
//loaded = false;
if(!loaded){
char *nm = namebuf + pathlen;
File f = SD.open(filepath);
uint8_t ret;
uint32_t start;
if (f != NULL) {
#ifdef USE_SDFAT
f.getName(nm, 32 - pathlen);
#else
strcpy(nm, (char *)f.name());
#endif
f.close();
strlwr(nm);
if (strstr(nm, ".bmp") != NULL && strstr(nm, NAMEMATCH) != NULL) {
Serial.print(namebuf);
Serial.print(F(" - "));
tft.fillScreen(0);
start = millis();
ret = showBMP(namebuf, 5, 5);
switch (ret) {
case 0:
Serial.print(millis() - start);
Serial.println(F("ms"));
delay(1000);
break;
case 1:
Serial.println(F("bad position"));
break;
case 2:
Serial.println(F("bad BMP ID"));
break;
case 3:
Serial.println(F("wrong number of planes"));
break;
case 4:
Serial.println(F("unsupported BMP format"));
break;
case 5:
Serial.println(F("unsupported palette"));
break;
default:
Serial.println(F("unknown"));
break;
}
}
}
else root.rewindDirectory();
loaded = true;
}
else{
if(currScreen == 0){
TSPoint p = ts.getPoint();
// we have some minimum pressure we consider 'valid'
// pressure of 0 means no pressing!
if (p.z > ts.pressureThreshhold) {
GetButtonScreen1(p.x, p.y);
if (button == 1){
loaded = false;
filepath = "/screen2.bmp";
currScreen = 1;
}
}
delay(100);
}
if(currScreen == 1){
TSPoint p = ts.getPoint();
// we have some minimum pressure we consider 'valid'
// pressure of 0 means no pressing!
if (p.z > ts.pressureThreshhold) {
GetButtonScreen2(p.x, p.y);
if(button == 1){
Serial.println("This is Screen 2");
}
else if(button == 2)
{
loaded = false;
filepath = "/button2.bmp";
currScreen = 0;
}
}
delay(100);
}
}
//loaded = true;
}
Here is a picture of the device I have. This is for a work project and somebody else ordered the parts so I do not have a link to the exact order, but I know it's an ELEGOO 2.8" LCD Shield.
Thank you for any help!