Hello everyone,
I have got a TFT/touchscreen screen from Elegoo (one of these https://www.elegoo.com/product/elegoo-uno-r3-2-8-inches-tft-touch-screen/ )
I have successfully used both the screen and the touchscreen... however, if I try to use them both at the same time the screen turns white.
I have read a lot of discussions about the "white screen problem", but they essentially all boil down to misconfiguration when initialising the screen, which is not the case here (since the screen works).
Here's some sample code, which is essentially a modified version of the example sketches.
It draws random circles on the screen while retrieving touch coordinates.
If I comment the getPoint() call, the screen works. If I put that line the screen gets completely white, although I can correctly retrieve the touchscreen coordinates. The same happens with the example sketches (I tried both using the Elegoo libraries that were provided with the screen and the Adafruit libraries, with the same result)
#include <Elegoo_GFX.h>
#include <Elegoo_TFTLCD.h>
#include <TouchScreen.h>
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define YP A2
#define XM A3
#define YM 8
#define XP 9
#define LCD_RESET A4
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 380);
void setup(void) {
Serial.begin(9600);
tft.reset();
uint16_t identifier = 0x9341;
tft.begin(identifier);
}
void loop(void)
{
TSPoint p;
tft.fillScreen(0);
// Colour definitions
int cols[6] = {0xFCD4, 0xFDB6, 0xFED8,
0xE799, 0xB75A, 0xC67D};
while(1)
{
int col = random(0, 5);
int x = random(0, tft.width());
int y = random(0, tft.height());
int radius = random(5, 10);
tft.fillCircle(x, y, radius, cols[col]);
// If I comment the line below the screen works
p = ts.getPoint();
if (p.z != 0)
{
Serial.print("X = "); Serial.print(p.x);
Serial.print("\tY = "); Serial.print(p.y);
Serial.print("\tPressure = "); Serial.println(p.z);
}
delay(50);
}
}
Any help with this would be greatly appreciated.
Nico