#include "font_Georgia.h"
tft.setRotation(3);
tft.setFont(Georgia_12);
tft.setTextColor(ILI9341_YELLOW);
tft.println("FS1000 FTD");
tft.println("182 Aircraft Ver 1.0");
void loop(void)
{
if (!ts.bufferEmpty())
{
// Retrieve a point
err--> TS_Point p = ts.getPoint();
p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height());
p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width());
int y = tft.height() - p.x;
int x = p.y;
}
//Serial.print(p.x);
//Serial.println(p.y);
}
#include "SPI.h"
#include "ILI9341_t3.h"
#include "font_Georgia.h"
#include <Wire.h> // this is needed for FT6206
#include <Adafruit_FT6206.h>
// The FT6206 uses hardware I2C (SCL/SDA)
Adafruit_FT6206 ts = Adafruit_FT6206();
// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000
// For the Adafruit shield, these are the default.
#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);
void setup()
{
tft.begin();
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor
Serial.println("ILI9341 Test!");
if (!ts.begin())
{
Serial.println("Unable to start touchscreen.");
}
else
{
Serial.println("Touchscreen started.");
}
}
void loop(void)
{
if (ts.touched())
{
TS_Point p = ts.getPoint();
//p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height());
//p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width());
//int y = tft.height() - p.x;
//int x = p.y;
Serial.print(p.x);
Serial.println(p.y);
}
}
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 8
// MOSI=11, MISO=12, SCK=13
XPT2046_Touchscreen ts(CS_PIN);
void setup()
{
ts.begin();
}
void loop()
{
TS_Point p = ts.getPoint();
if (ts.touched())
{
Serial.print(p.x);
Serial.print(" ");
Serial.println(p.y);
}
delay(250);
}
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include "ILI9341_t3.h"
#define CS_PIN 8
// MOSI=11, MISO=12, SCK=13
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
XPT2046_Touchscreen ts(CS_PIN);
TS_Point p;
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
void setup()
{
ts.begin();
}
void loop()
{
tft.setRotation(1);
p = ts.getPoint();
if (ts.touched())
{
Serial.println(p.x);
Serial.print(" ");
Serial.println(p.y);
}
delay(250);
}
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include <elapsedMillis.h> // Not needed on Teensy
#define CS_PIN 8
// MOSI=11, MISO=12, SCK=13
XPT2046_Touchscreen ts(CS_PIN);
void setup() {
ts.begin();
while ( !Serial && (millis() < 2000)) ;
Serial.println("Touchscreen started.");
}
elapsedMillis waitTouch;
elapsedMillis noTouch;
TS_Point p;
void loop() {
if (waitTouch > 100) {
if ( ts.touched()) {
p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
Serial.println();
noTouch = 0;
}
waitTouch = 0;
}
if (noTouch > 10000) {
noTouch = 0;
Serial.println("Touchscreen Not touched for 10 seconds.");
}
}
//#define TS_MINX 150
//#define TS_MINY 130
//#define TS_MAXX 3800
//#define TS_MAXY 4000
// value, fromLow, fromHigh, toLow, toHigh
p.x = map(p.x, 0, 4000, 0, 320);
p.y = map(p.y, 0, 3800, 0, 240);
Serial.print(p.x);
Serial.print(" ");
Serial.println(p.y);
// Zero is calibration for mapping to pixal, 1-4 follow screen rotation for mapping math
TS_MAP tsMap[5] = { {[B][U]200, 3700, 325, 3670[/U] [/B]}, { 0, 319, 0, 239 }, { 319, 0, 0, 239 }, { 319, 0, 239, 0 }, { 0, 319, 239, 0 } };
xx = map(pp.x, tsMap[0].xt, tsMap[0].xb, tsMap[TS_Rotate].xt, tsMap[TS_Rotate].xb);
yy = map(pp.y, tsMap[0].yl, tsMap[0].yr, tsMap[TS_Rotate].yl, tsMap[TS_Rotate].yr);
int16_t TS_Rotate = 4;
void ButtonRotate( int setrotate )
{
TS_Rotate = setrotate;
if ( TS_Rotate > 4 ) TS_Rotate = 1;
if ( TS_Rotate < 1 ) TS_Rotate = 4;
tft.setRotation(TS_Rotate);
tft.fillScreen(ILI9341_BLACK);
PaintInit( currentcolor );
}
TS_MAP tsMap[5] = { {200, 3700, 325, 3670 },
that works very good for me. Esp. the slider is great.
Some bytes more or less is not a problem. We're not on Arduino That string pointer is a good idea!