Hello,
I am new to Arduino touch programming and I'm confused by a certain logical error. I'm just testing out various commands in the program. The program is as follows:
#include "TFTLCD.h"
#include "TouchScreen.h"
#define XP 6
#define XM A2
#define YP A1
#define YM 7
#define TS_MINX 150
#define TS_MAXX 920
#define TS_MINY 120
#define TS_MAXY 940
TouchScreen ts = TouchScreen(XP,YP,XM,YM,300);
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#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 PENRADIUS 40
#define MINPRESSURE 10
#define MAXPRESSURE 1000
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
void setup()
{
Serial.begin(9600);
Serial.println("Start");
tft.reset();
tft.initDisplay();
tft.fillScreen(BLACK);
tft.drawVerticalLine(0,0,240,GREEN);
tft.fillRect(0, 0, 40, 40, RED);
tft.fillRect(40, 40, 40, 40, YELLOW);
tft.fillRect(80, 80, 40, 40, BLUE);
tft.fillCircle(50,50,20,GREEN);
}
//Successful execution up to this point
void loop()
{
Point p = ts.getPoint();
tft.drawRect(0, 0, 40, 40, WHITE); //Does not execute
if(p.z > MINPRESSURE && p.z < MAXPRESSURE)
{
p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());
tft.fillCircle(p.x,p.y,5,GREEN); //Does not execute on touch
}
}
What could possibly be the error for this? The program compiles successfully but the output is not logically correct. I'm attaching 2 photos of the LCD screen : one is the first output and the other is the output on touch