I am trying to make a menu function on my tft screen, but every time I attempt to press a button to go to the next screen, it just flashes white and stays that way.
#include <Elegoo_GFX.h> // Core graphics library
#include <Elegoo_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h> // Touch Support
#define TS_MINX 920
#define TS_MINY 120
#define TS_MAXX 150
#define TS_MAXY 940
#define YP A3 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
// macros for color (16 bit)
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
boolean screen = false;
void setup() {
Serial.begin(9600);
drawOffScreen();
}
void drawOnScreen(){
tft.reset(); // Reset LCD
tft.begin(0x9341); // Initialise LCD
tft.fillScreen(BLACK); // Black Background
tft.fillRect(0,0,240,160,GREEN); // Upper GREEN Rectange
tft.drawRect(0,0,240,160,WHITE); // White borders to the rectangles
tft.setTextColor(WHITE); // Set Text Proporties
tft.setTextSize(2);
tft.setCursor(80, 80);
tft.println("Turn Off");
screen = true;
}
void drawOffScreen(){
tft.reset(); // Reset LCD
tft.begin(0x9341); // Initialise LCD
tft.fillScreen(BLACK); // Black Background
tft.fillRect(0,160,240,160,RED); // Lower RED Rectange
tft.drawRect(0,160,240,160,WHITE);
tft.setTextColor(WHITE); // Set Text Proporties
tft.setTextSize(2);
tft.setCursor(80, 240);
tft.println("Turn On");
screen = false;
}
void loop() {
TSPoint p = ts.getPoint();
screen = false;
if (p.z > 10 && p.z < 1000) // Check touch validity
{
if (p.y > 160 && screen == false){
drawOnScreen();
}
if (p.y < 160 && screen == true){
drawOffScreen();
}
}
delay (100);
}```
Whats above isn't my actual code I'm working on, but rather a test I ran to see if it was some other part of my code or just what I was trying to do. Same result when I try to use drawOnScreen by touching the button on the 'OffScreen'.
You have a number of variables called screen. They are different variables; the one in setup() is not the same as the one in drawonScreen() which is not the same as the one in drawOffScreen() which is also not the one in loop().
Use one variable boolean screen in the global space (that is, before setup()); replace in the rest of your code boolean screen by screen.
create a variable of type boolean which is only accessible from withing the curly opening brace "{" above this code-line
assign value false
A line of code
screen = false;
is completely different.
It uses the already declared variable with name screen which is accessible in this scope .
If you move the declaration outside all functions at the top of your source-code
the variable will be global and be accessible from everywhere else in your code
To read more about scope look up the link given by user @sterretje
best regards Stefan
Basic troubleshooting: attempt to replicate the problem. I was able to replicate the problem with much less code, therefore making it easier for myself and presumably anyone else to track down the real problem.
Current code. When I touch any square, I get X/Y and the name of the square on serial monitor. When I touch 'ULAR' it's supposed to redraw the screen and then after 10 seconds, redraw again to the main.
So this means it is suposed to do so but it doesn't. If it does not what does it then.
You should always describe in detail what your code should do
and what your code does instead
Man. Trying to be fast by too short postings is just slowing everything down
it could help if you would add the details
which code?
if you explain what means
WHAT
does happen?
Here you are adding the information that you did some tests with an arduino Uno.
With this now I'm unsure how many microcontrollers and how many different types of microcontrollers do you have?
You know it. But I can't read your mind. I have only the information that you have posted.
Switching from what type of microcontroller back to Arduino Uno?
here is a code-version that does a lot of derial debug-output
You can test this version.
You didn't provided links to the libraries that you use.
There are always multiple libraries for each kind of device.
So downloading by assuming does not work.
Again: you can go on playing a ping-pong-game of snap-chat-short postings delaying everything
or you can accelerate finding the solution by investing time into good and detailed information.
// MACRO-START * MACRO-START * MACRO-START * MACRO-START * MACRO-START * MACRO-START *
// Take it for granted at the moment scroll down to void setup
// start of macros dbg and dbgi
#define dbg(myFixedText, variableName) \
Serial.print( F(#myFixedText " " #variableName"=") ); \
Serial.println(variableName);
// usage: dbg("1:my fixed text",myVariable);
// myVariable can be any variable or expression that is defined in scope
#define dbgi(myFixedText, variableName,timeInterval) \
do { \
static unsigned long intervalStartTime; \
if ( millis() - intervalStartTime >= timeInterval ){ \
intervalStartTime = millis(); \
Serial.print( F(#myFixedText " " #variableName"=") ); \
Serial.println(variableName); \
} \
} while (false);
// usage: dbgi("2:my fixed text",myVariable,1000);
// myVariable can be any variable or expression that is defined in scope
// third parameter is the time in milliseconds that must pass by until the next time a
// Serial.print is executed
// end of macros dbg and dbgi
// print only once when value has changed
#define dbgc(myFixedText, variableName) \
do { \
static long lastState; \
if ( lastState != variableName ){ \
Serial.print( F(#myFixedText " " #variableName" changed from ") ); \
Serial.print(lastState); \
Serial.print( F(" to ") ); \
Serial.println(variableName); \
lastState = variableName; \
} \
} while (false);
// MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END *
#include <Elegoo_TFTLCD.h>
#include <pin_magic.h>
#include <registers.h>
#include <Elegoo_GFX.h>
#include <TouchScreen.h>
#define TS_MINX 920
#define TS_MINY 120
#define TS_MAXX 150
#define TS_MAXY 940
#define YP A3
#define XM A2
#define YM 9
#define XP 8
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
//macros for color (16 bit)
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define YELLOW 0xFFE0
#define MAGENTA 0xF81F
#define WHITE 0xFFFF
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
unsigned long WaitTime = 5000;
void setup() {
Serial.begin(115200);
Serial.println("Setup-Start wait 5000");
delay(5000);
Serial.println("Setup-Start delay(5000) done");
drawMainScreen();
}
void drawInfoScreen() {
dbg("entering drawInfoScreen",zone);
tft.fillScreen(BLACK);
tft.setTextColor(WHITE);
tft.drawRect(5, 5, 230, 310, WHITE);
tft.setTextSize(3);
tft.setCursor(100, 10);
tft.println("Ular");
delay(10000);
dbg("delay(10000);done just before drawInfoScreen",zone);
drawMainScreen();
dbg("leaving drawInfoScreen",zone);
}
void drawMainScreen() {
dbg("entering drawMainScreen", WaitTime);
delay(WaitTime);
tft.reset();
dbg("tft.reset done delay(5000)", WaitTime);
delay(WaitTime);
tft.begin(0x9341);
dbg("tft.begin(0x9341) done", WaitTime);
delay(WaitTime);
tft.fillScreen(BLACK);
dbg("tft.fillScreen(BLACK) done", WaitTime);
delay(WaitTime);
tft.fillScreen(WHITE);
dbg("tft.fillScreen(WHITE) done", WaitTime);
delay(WaitTime);
tft.fillScreen(BLACK);
dbg("2 tft.fillScreen(BLACK) done", WaitTime);
delay(WaitTime);
tft.setTextColor(WHITE);
dbg("tft.setTextColor(WHITE) done", WaitTime);
delay(WaitTime);
tft.setTextSize(2);
dbg("tft.setTextSize(2) done", WaitTime);
delay(WaitTime);
//Unit 1
tft.drawRect(5, 5, 110, 100, WHITE);
tft.setCursor(30, 10);
tft.println("ULAR");
tft.setCursor(20, 30);
tft.println("T:80F");
tft.setCursor(20, 50);
tft.println("RH:50%");
tft.setCursor(20, 70);
tft.println("LM:1:10");
dbg("Unit 1 done", WaitTime);
delay(WaitTime);
//Unit 2
tft.drawRect(5, 110, 110, 100, WHITE);
tft.setCursor(30, 115);
tft.println("MONTY");
tft.setCursor(20, 135);
tft.println("T:80F");
tft.setCursor(20, 155);
tft.println("RH:50%");
tft.setCursor(20, 175);
tft.println("LM:1:10");
dbg("Unit 2 done", WaitTime);
delay(WaitTime);
//Unit 3
tft.drawRect(5, 215, 110, 100, WHITE);
tft.setCursor(30, 220);
tft.println("JEFF");
tft.setCursor(20, 240);
tft.println("T:80F");
tft.setCursor(20, 260);
tft.println("RH:50%");
tft.setCursor(20, 280);
tft.println("LM:1:10");
dbg("Unit 3 done", WaitTime);
delay(WaitTime);
//Unit 4
tft.drawRect(125, 5, 110, 100, WHITE);
tft.setCursor(140, 10);
tft.println("GARTERS");
tft.setCursor(140, 30);
tft.println("T:80F");
tft.setCursor(140, 50);
tft.println("RH:50%");
tft.setCursor(140, 70);
tft.println("LM:1:10");
dbg("Unit 4 done", WaitTime);
delay(WaitTime);
//Unit 5
tft.drawRect(125, 110, 110, 100, WHITE);
tft.setCursor(150, 115);
tft.println("NORRO");
tft.setCursor(140, 135);
tft.println("T:80F");
tft.setCursor(140, 155);
tft.println("RH:50%");
tft.setCursor(140, 175);
tft.println("LM:1:10");
dbg("Unit 5 done", WaitTime);
delay(WaitTime);
//Unit 6
tft.drawRect(125, 215, 110, 100, WHITE);
tft.setCursor(150, 220);
tft.println("EMPTY");
tft.setCursor(140, 240);
tft.println("T:80F");
tft.setCursor(140, 260);
tft.println("RH:50%");
tft.setCursor(140, 280);
tft.println("LM:1:10");
dbg("Unit 6 done", WaitTime);
delay(WaitTime);
}
void loop() {
dbgi("top of loop", p.z, 1000);
TSPoint p = ts.getPoint();
dbgi("p = ts.getPoint() done", p.z, 1000);
String zone = "Main";
if (p.z > 10 && p.z < 1000)
{
dbgi("(p.z > 10 && p.z < 1000) is true", p.z, 500);
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
if (p.x > 4 && p.x < 116 && p.y > 4 && p.y < 106)
{
dbgi("((p.x > 4 && p.x < 116 && p.y > 4 && p.y < 106) is true", p.x, 500);
zone = "ULAR";
drawInfoScreen();
}
if (p.x > 4 && p.x < 116 && p.y > 109 && p.y < 211)
{
zone = "MONTY";
}
if (p.x > 4 && p.x < 116 && p.y > 214 && p.y < 316)
{
zone = "JEFF";
}
if (p.x > 124 && p.x < 236 && p.y > 4 && p.y < 106)
{
zone = "GARTERS";
}
if (p.x > 124 && p.x < 236 && p.y > 109 && p.y < 211)
{
zone = "NORRO";
}
if (p.x > 124 && p.x < 236 && p.y > 214 && p.y < 316)
{
zone = "EMPTY";
}
dbg("bottom of loop", p.x, 200);
dbg("bottom of loop", p.y, 200);
dbg("bottom of loop", zone, 200);
/*
Serial.print("X = ");
Serial.println(p.x);
Serial.print("Y = ");
Serial.println(p.y);
Serial.println(zone);
*/
}
delay (100);
}
I am using an Arduino Mega 2560 R3 and this TFT screen.
I also own an Arduino UNO R3 that I have used to see if the issue described below persists between the two. The issue persisted between the two microcontrollers.
I am using Arduino IDE V 2.0.1
I am using the following libraries. Elegoo_GFX.zip (10.7 KB) Elegoo_TFTLCD.zip (160.0 KB) TouchScreen.zip (4.4 KB) pin_magic.zip (5.0 KB) registers.zip (1.3 KB)
What I want the code to do:
-Black background. (Works)
-Draw a series of 6 rectangles. (Works)
-Put text in each rectangle. (Works)
-Define each rectangle as an individual zone/button. (Works - passes zone name to serial output)
-When pressed, each zone will draw an advanced information screen. (Does not work, screen flashes briefly and turns white, only zone 'ULAR' has the coding so far.)
You will find the required libraries and description of the issue above the code block.
I at one point removed the lines below from the block above in the drawInfoScreen() section, to no improvement. My reasoning for this was that the code would have already ran the reset and begin, and mayhap it did not need to be done again. The screen still turned white after the appropriate zone was registered as pressed.
tft.reset();
tft.begin(0x9341);
I appreciate the posting of the debugging code, however upon attempting to verify it, this error message was printed in the output section of my Arduino IDE V. 2.0.1:
C:\Users\###\Temp\.arduinoIDE-unsaved20221011-16208-197zd77.77l9\sketch_nov11a\sketch_nov11a.ino:254:35: error: macro "dbg" passed 3 arguments, but takes just 2
dbg("bottom of loop", p.x, 200);
^
C:\Users\###\Temp\.arduinoIDE-unsaved20221011-16208-197zd77.77l9\sketch_nov11a\sketch_nov11a.ino:255:35: error: macro "dbg" passed 3 arguments, but takes just 2
dbg("bottom of loop", p.y, 200);
^
C:\Users\###\Temp\.arduinoIDE-unsaved20221011-16208-197zd77.77l9\sketch_nov11a\sketch_nov11a.ino:256:36: error: macro "dbg" passed 3 arguments, but takes just 2
dbg("bottom of loop", zone, 200);
^
Multiple libraries were found for "TouchScreen.h"
Used: C:\Users\###\Arduino\libraries\TouchScreen
Not used: C:\Users\###\Arduino\libraries\Adafruit_TouchScreen
exit status 1
Compilation error: macro "dbg" passed 3 arguments, but takes just 2
I do apologize, as the above error message has been edited to remove PII. The characters ### replace my file directories up to my temp folder for the first three, up to my Arduino file on the last two. The TouchScreen.h library I am using (and have included above) is the one that came with the installation media included in the package the TFT screen was shipped in.
I sincerely hope this is all the information you are needing to assist me with this issue. If you have any other requirements please let them be know.
You added ZIP-files to your posting.
ZIP-files can include malicious software. Almost no user will download a ZIP-file.
This is the reason why you should only post the download-link to the libraries and not ZIP-files.
Where inside your code is this function-call that does draw an advanced information screen
What does this exactly mean that only zone 'ULAR' has the coding so far ?
is each zone defined or not?
did you only code the ULAR-advanced information screen or did you code all advanced information screens?
After installing your libraries this code-version compiles
// MACRO-START * MACRO-START * MACRO-START * MACRO-START * MACRO-START * MACRO-START *
// Take it for granted at the moment scroll down to void setup
// start of macros dbg and dbgi
#define dbg(myFixedText, variableName) \
Serial.print( F(#myFixedText " " #variableName"=") ); \
Serial.println(variableName);
// usage: dbg("1:my fixed text",myVariable);
// myVariable can be any variable or expression that is defined in scope
#define dbgi(myFixedText, variableName,timeInterval) \
do { \
static unsigned long intervalStartTime; \
if ( millis() - intervalStartTime >= timeInterval ){ \
intervalStartTime = millis(); \
Serial.print( F(#myFixedText " " #variableName"=") ); \
Serial.println(variableName); \
} \
} while (false);
// usage: dbgi("2:my fixed text",myVariable,1000);
// myVariable can be any variable or expression that is defined in scope
// third parameter is the time in milliseconds that must pass by until the next time a
// Serial.print is executed
// end of macros dbg and dbgi
// print only once when value has changed
#define dbgc(myFixedText, variableName) \
do { \
static long lastState; \
if ( lastState != variableName ){ \
Serial.print( F(#myFixedText " " #variableName" changed from ") ); \
Serial.print(lastState); \
Serial.print( F(" to ") ); \
Serial.println(variableName); \
lastState = variableName; \
} \
} while (false);
// MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END *
#include <Elegoo_TFTLCD.h>
#include <pin_magic.h>
#include <registers.h>
#include <Elegoo_GFX.h>
#include <TouchScreen.h>
#define TS_MINX 920
#define TS_MINY 120
#define TS_MAXX 150
#define TS_MAXY 940
#define YP A3
#define XM A2
#define YM 9
#define XP 8
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
//macros for color (16 bit)
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define YELLOW 0xFFE0
#define MAGENTA 0xF81F
#define WHITE 0xFFFF
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
unsigned long WaitTime = 5000;
String zone = "Main";
TSPoint p = ts.getPoint();
void setup() {
Serial.begin(115200);
Serial.println("Setup-Start wait 5000");
delay(5000);
Serial.println("Setup-Start delay(5000) done");
drawMainScreen();
}
void drawInfoScreen() {
dbg("entering drawInfoScreen", zone);
tft.fillScreen(BLACK);
tft.setTextColor(WHITE);
tft.drawRect(5, 5, 230, 310, WHITE);
tft.setTextSize(3);
tft.setCursor(100, 10);
tft.println("Ular");
delay(10000);
dbg("delay(10000);done just before drawInfoScreen", zone);
drawMainScreen();
dbg("leaving drawInfoScreen", zone);
}
void drawMainScreen() {
dbg("entering drawMainScreen", WaitTime);
delay(WaitTime);
tft.reset();
dbg("tft.reset done delay(5000)", WaitTime);
delay(WaitTime);
tft.begin(0x9341);
dbg("tft.begin(0x9341) done", WaitTime);
delay(WaitTime);
tft.fillScreen(BLACK);
dbg("tft.fillScreen(BLACK) done", WaitTime);
delay(WaitTime);
tft.fillScreen(WHITE);
dbg("tft.fillScreen(WHITE) done", WaitTime);
delay(WaitTime);
tft.fillScreen(BLACK);
dbg("2 tft.fillScreen(BLACK) done", WaitTime);
delay(WaitTime);
tft.setTextColor(WHITE);
dbg("tft.setTextColor(WHITE) done", WaitTime);
delay(WaitTime);
tft.setTextSize(2);
dbg("tft.setTextSize(2) done", WaitTime);
delay(WaitTime);
//Unit 1
tft.drawRect(5, 5, 110, 100, WHITE);
tft.setCursor(30, 10);
tft.println("ULAR");
tft.setCursor(20, 30);
tft.println("T:80F");
tft.setCursor(20, 50);
tft.println("RH:50%");
tft.setCursor(20, 70);
tft.println("LM:1:10");
dbg("Unit 1 done", WaitTime);
delay(WaitTime);
//Unit 2
tft.drawRect(5, 110, 110, 100, WHITE);
tft.setCursor(30, 115);
tft.println("MONTY");
tft.setCursor(20, 135);
tft.println("T:80F");
tft.setCursor(20, 155);
tft.println("RH:50%");
tft.setCursor(20, 175);
tft.println("LM:1:10");
dbg("Unit 2 done", WaitTime);
delay(WaitTime);
//Unit 3
tft.drawRect(5, 215, 110, 100, WHITE);
tft.setCursor(30, 220);
tft.println("JEFF");
tft.setCursor(20, 240);
tft.println("T:80F");
tft.setCursor(20, 260);
tft.println("RH:50%");
tft.setCursor(20, 280);
tft.println("LM:1:10");
dbg("Unit 3 done", WaitTime);
delay(WaitTime);
//Unit 4
tft.drawRect(125, 5, 110, 100, WHITE);
tft.setCursor(140, 10);
tft.println("GARTERS");
tft.setCursor(140, 30);
tft.println("T:80F");
tft.setCursor(140, 50);
tft.println("RH:50%");
tft.setCursor(140, 70);
tft.println("LM:1:10");
dbg("Unit 4 done", WaitTime);
delay(WaitTime);
//Unit 5
tft.drawRect(125, 110, 110, 100, WHITE);
tft.setCursor(150, 115);
tft.println("NORRO");
tft.setCursor(140, 135);
tft.println("T:80F");
tft.setCursor(140, 155);
tft.println("RH:50%");
tft.setCursor(140, 175);
tft.println("LM:1:10");
dbg("Unit 5 done", WaitTime);
delay(WaitTime);
//Unit 6
tft.drawRect(125, 215, 110, 100, WHITE);
tft.setCursor(150, 220);
tft.println("EMPTY");
tft.setCursor(140, 240);
tft.println("T:80F");
tft.setCursor(140, 260);
tft.println("RH:50%");
tft.setCursor(140, 280);
tft.println("LM:1:10");
dbg("Unit 6 done", WaitTime);
delay(WaitTime);
}
void loop() {
dbgi("top of loop", p.z, 1000);
dbgi("p = ts.getPoint() done", p.z, 1000);
if (p.z > 10 && p.z < 1000)
{
dbgi("(p.z > 10 && p.z < 1000) is true", p.z, 500);
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
if (p.x > 4 && p.x < 116 && p.y > 4 && p.y < 106)
{
dbgi("((p.x > 4 && p.x < 116 && p.y > 4 && p.y < 106) is true", p.x, 500);
zone = "ULAR";
drawInfoScreen();
}
if (p.x > 4 && p.x < 116 && p.y > 109 && p.y < 211)
{
zone = "MONTY";
}
if (p.x > 4 && p.x < 116 && p.y > 214 && p.y < 316)
{
zone = "JEFF";
}
if (p.x > 124 && p.x < 236 && p.y > 4 && p.y < 106)
{
zone = "GARTERS";
}
if (p.x > 124 && p.x < 236 && p.y > 109 && p.y < 211)
{
zone = "NORRO";
}
if (p.x > 124 && p.x < 236 && p.y > 214 && p.y < 316)
{
zone = "EMPTY";
}
dbgi("bottom of loop", p.x, 200);
dbgi("bottom of loop", p.y, 200);
dbgi("bottom of loop", zone, 200);
/*
Serial.print("X = ");
Serial.println(p.x);
Serial.print("Y = ");
Serial.println(p.y);
Serial.println(zone);
*/
}
delay (100);
}
This code-version has a lot of delays of 5 seconds to make it possible to execute the code
with pauses that you can see at which point inside your code the
does happen.
After analysing this;
post the serial output as a code-section.
describe at which line of serial output did happen the screen-flashing and
at which line of serial output did happen the screen turning white
Understood, but there is not a download link I am aware of for these specific libraries, they all came from the installation media included in the package the TFT screen came in. Without being certain that ones I found online were the exact same, I opted to take them straight from the disk. Would the .h files have been acceptable to upload, or is that only a part of the library?
All zones are defined, ULAR is the only one I had coded to pull up an advanced screen. I am heading to work now, but will run the diagnostic when I return home this evening.
While running the code I see the reports from the serial monitor, however now the main screen doesn't draw, and when the p.x/p.y output start it doesn't report pressure. I'm starting to think maybe the screen is faulty, as I tested on both the UNO and MEGA with the same results.
It could well be some difference in the code that - with one version your frams are drawn on the screen and are not drawn with another codeversion.
I such cases you should do crosstesting by testing different code-versions.
This leads to another thing that is important in software-developping.
Keeping versions. Me personal I use version-numbers.
First version ending on "-001".
when a project has any kind of "this part is working"-status I add a comment what was added as last thing // drawing frames works
and then use save as ... -002,
next round -003, -004 etc.
So I can easily roll back to an earlier version and do cross-testing.
Another thing is to use some example-code. There is a subfolder
....Arduino\libraries\Elegoo_TFTLCD\examples\graphicstest
graphicstest.pde is a valid source-code just pretty old
Did you run one of these tests? What was the result?
The first three lines say // IMPORTANT: Elegoo_TFTLCD LIBRARY MUST BE SPECIFICALLY // CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD. // SEE RELEVANT COMMENTS IN Elegoo_TFTLCD.h FOR SETUP.
inside file Elegoo_TFTLCD.h
// **** IF USING THE LCD BREAKOUT BOARD, COMMENT OUT THIS NEXT LINE. ****
// **** IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED: ****
//#define USE_Elegoo_SHIELD_PINOUT 1
Which hardware do you have?
From this example you can see the microcontroller-word is not super-standardised like USB-devices. You have to take care of more details than just "does the plug fit into the socket?"
The comment says IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED:
I simply extracted thhe zip-file and changed nothing.
The line is commented out
The comments says
// **** IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED: ****
//#define USE_Elegoo_SHIELD_PINOUT 1
the line is DIS-abled by commenting out
So one possible reason for not functioning could be this
I have putted a lot of 5 seconds long delays into the code
so not drawing might be just long times inbetween before drawing the next detail.
This might be as well because of the long delays. I haven't analysed how reading in touches are done
Thank you for your help. I had looked through the included samples as well as the ones on the CD that come with the LCD, and as far as I could tell, none of them did anything with switching screens like I was (as in waiting for a touch response to do so). I had found a tutorial with another screen on youtube but unfortunately it used different libraries and didn't compile for me out of the box. Looking through it, I saw that 99% of the definitions were the same, so I swapped the libraries and it was able to compile. More than that, when I hit the subscribe button it worked! I found two lines of code with a note that I didn't have:
//This is important, because the libraries are sharing pins
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
Adding them to my project caused everything to work!
As far as your question, I'm using the breakout board.