PaulStoffregen / XPT2046_Touchscreen

Touchscreen Arduino Library for XPT2046 Touch Controller Chip
240 stars 84 forks source link

Problem when using with Adafruit ILI9341 (and ILI9341_t3) TFT library #42

Open Hannes0O0 opened 2 years ago

Hannes0O0 commented 2 years ago

Description

When I use this library in combination with the Adafruit_ILI9341.h library or the ILI9341_t3.h library, the display shows either white, or a combination of blue and black (with the Adafruit library). Everything related to touch works fine. If I upload the graphic test from Adafruit first and reupload the Sketch from before again, everything suddenly works just fine. When I power off and on the Teensy after that the TFT stops working.

Steps To Reproduce Problem

  1. Connect the TFT to a Teensy 4.1.
  2. Upload the Sketch.

Hardware & Software

Board: Teensy 4.1 Shields / modules used: 2.8 Inch SPI TFT Arduino IDE version: 1.8.13 Teensyduino version (if using Teensy): 1.53 Operating system & version: Windows 10 home 64bit

Arduino Sketch

include

include "SPI.h"

include "XPT2046_Touchscreen.h"

include "Adafruit_GFX.h"

include "Adafruit_ILI9341.h"

//Pin definitions

define TFT_MOSI 11

define TFT_MISO 12

define TFT_CLK 13

define TFT_DP_CS 10

define TFT_DP_RST 8

define TFT_DP_DC 9

define TFT_TS_CS 7

define TFT_TS_IRQ 6

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_DP_CS, TFT_DP_DC, TFT_MOSI, TFT_CLK, TFT_DP_RST, TFT_MISO); XPT2046_Touchscreen ts(TFT_TS_CS);

void setup() { pinMode(TFT_DP_CS, OUTPUT); pinMode(TFT_TS_CS, OUTPUT); digitalWrite(TFT_DP_CS, HIGH); digitalWrite(TFT_TS_CS, HIGH); Serial.begin(38400); //TFT init tft.begin(); tft.setRotation(2); //Tochscreen init ts.begin(); ts.setRotation(2); tft.fillScreen(0x0A0F); }

void loop() { if (ts.touched()) { TS_Point p = ts.getPoint(); Serial.print("Pressure = "); Serial.print(p.z); Serial.print(", x = "); Serial.print(p.x); Serial.print(", y = "); Serial.print(p.y); delay(30); Serial.println(); } } //This Sketch would normally change the color of the screen and Serial.print the Tochposition

//------------------------------------------------------------------------------------------------------------------------------------

//When I remove the code for the touch functionality it works as expected (=changes the coler of the screen):

include "SPI.h"

include "Adafruit_GFX.h"

include "Adafruit_ILI9341.h"

//Pin definitions

define TFT_MOSI 11

define TFT_MISO 12

define TFT_CLK 13

define TFT_DP_CS 10

define TFT_DP_RST 8

define TFT_DP_DC 9

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_DP_CS, TFT_DP_DC, TFT_MOSI, TFT_CLK, TFT_DP_RST, TFT_MISO);

void setup() { pinMode(TFT_DP_CS, OUTPUT); pinMode(TFT_TS_CS, OUTPUT); digitalWrite(TFT_DP_CS, HIGH); digitalWrite(TFT_TS_CS, HIGH); Serial.begin(38400); //TFT init tft.begin(); tft.setRotation(2); tft.fillScreen(0x0A0F); }

void loop() { }