Hey so i'm using this display with Adafruit GFX and TouchScreen libraries + MCUFRIEND library.
Heres my project code:
`#include <stdint.h>
#include "TouchScreen.h"
#include <Adafruit_GFX.h> // Core graphics library
#include <MCUFRIEND_kbv.h>
#include <Fonts\FreeSans18pt7b.h>
#include <Fonts\FreeSansBold24pt7b.h>
MCUFRIEND_kbv tft;
// TFT Breakout -- Arduino UNO / Mega2560 / OPEN-SMART UNO Black
// GND -- GND
// 3V3 -- 3.3V
// CS -- A3
// RS -- A2
// WR -- A1
// RD -- A0
// RST -- RESET
// LED -- GND
// DB0 -- 8
// DB1 -- 9
// DB2 -- 10
// DB3 -- 11
// DB4 -- 4
// DB5 -- 13
// DB6 -- 6
// DB7 -- 7
// Assign human-readable names to some common 16-bit color values:
#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 MINPRESSURE 10
#define MAXPRESSURE 1000
uint16_t g_identifier;
uint8_t YP = A1; // must be an analog pin, use "An" notation!
uint8_t XM = A2; // must be an analog pin, use "An" notation!
uint8_t YM = 7; // can be a digital pin
uint8_t XP = 6; // can be a digital pin
uint16_t pLEFT = 880;
uint16_t pRIGHT = 170;
uint16_t pTOP = 950;
uint16_t pBOTTOM = 180;
int v1;
uint16_t xpos, ypos;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
void setup() {
tft.reset();
Serial.begin(9600);
uint16_t g_identifier = tft.readID();
tft.begin(g_identifier);
tft.setRotation(1);
randomSeed(analogRead(0));
homeScreen();
}
void homeScreen(){
v1 = random(0, 2);
tft.fillScreen(WHITE);
tft.setFont(&FreeSansBold24pt7b);
tft.setTextColor(BLACK);
if (v1 ==0){
tft.setCursor(90,65);
tft.print("Welcome!");
}
else if (v1 == 1){
tft.setCursor(135,65);
tft.print("Hello!");
}
tft.drawLine(20, 85, 380, 85, BLACK);
tft.fillRoundRect(150, 100, 100, 100, 20, BLACK);
tft.fillRoundRect(157, 107, 86, 86, 15, WHITE);
tft.fillTriangle(175, 180, 175, 120, 225, 150, BLACK);
playTouch();
}
int returnX(int x){
}
int waitUntil=1;
void playTouch(){
do {
TSPoint p = ts.getPoint();
xpos = map(p.x, pLEFT, pRIGHT, 0, tft.width());
ypos = map(p.y, pTOP, pBOTTOM, 0, tft.height());
if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<250 && xpos>150 && ypos>100 && ypos<200 ){
Serial.print("X = "); Serial.print(p.x);
Serial.print("\tY = "); Serial.print(p.y);
Serial.print("\tPressure = "); Serial.println(p.z);
//tft.fillRoundRect(150, 100, 100, 100, 20, GREEN);
lockScreen();
}
}
while (waitUntil<2);
}
void lockScreen(){
waitUntil=3;
tft.setCursor(0,0);
tft.print("very weird bug");
tft.fillScreen(RED);
Serial.print("Got to lockScreen()");
tft.setCursor(90,65);
tft.setTextColor(BLACK);
tft.setFont(&FreeSans18pt7b);
tft.print("Please Enter Fingerprint");
tft.drawLine(20, 80, 280, 80, BLACK);
}
void loop() {
}`
Everything is pretty much working, but after i detect the play button touch and jump to the lock screen (lockScreen()) nothing renders, not the text, background or lines. it just show a blank white display. (Added a video)
Any help would be much appreciated.