I'm having trouble getting the Color 320x240 TFT Touchscreen I purchased from here, to recognize touch.
I had this working on a 3.2 and now I trying to use a 3.6 I recently purchased. I'm thinking it has something to do with the 3.6 board, but I don't know for sure.
I've stripped down my code to just the touch function to keep it simple.
I'm hoping someone can see what I'm doing wrong.
Thank you...
I had this working on a 3.2 and now I trying to use a 3.6 I recently purchased. I'm thinking it has something to do with the 3.6 board, but I don't know for sure.
I've stripped down my code to just the touch function to keep it simple.
I'm hoping someone can see what I'm doing wrong.
Thank you...
Code:
#include <XPT2046_Touchscreen.h>
#include "SPI.h"
#include "ILI9341_t3.h"
#include "font_Georgia.h"
#include "font_CourierNew.h"
#define CS_PIN 8
#define TFT_DC 9
#define TFT_CS 10
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
XPT2046_Touchscreen ts(CS_PIN);
TS_Point p;
int intPaintSplashScreen = 0;
void setup()
{
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
Serial.begin(9600);
while (!Serial & millis() <4000)
{
}
Serial.println("ILI9341 Test");
}
void loop(void)
{
if (intPaintSplashScreen == 0)
{
paint_Splash_Screen();
intPaintSplashScreen++;
delay(250);
}
TS_Point p = ts.getPoint();
// value, fromLow, fromHigh, toLow, toHigh
p.x = map(p.x, 204, 948, 0, 320);
p.y = map(p.y, 195, 910, 0, 240);
if (p.x > 0 && p.x < 100 && p.y > 0 && p.y < 100)
{
Serial.print("touched!");
delay(250);
}
} // end Loop()
void paint_Splash_Screen()
{
tft.setRotation(1);
tft.setTextColor(ILI9341_GREEN);
tft.setFont(CourierNew_14);
tft.setCursor(106, 110);
tft.print("Touch Screen");
}