LenShustek
Member
I have a 3.2" PJRC color 320x240 display connected to a Teensy LC, with the TFT display and touchscreen both connected to the default SPI port (pins 11, 12, 13) and separate pins for CS (10 and 8, respectively). The display DC is connected to 20.
If I just display on the screen, it works.
If I display nothing and read from the touchscreen, it works.
But if I read the touchscreen and then display something once on the screen, the touchscreen starts generating random touches forever!
I'm powering the Teensy from USB, and the screen from the 5V pin on the Teensy. I have decoupling caps on the power to the screen.
Here's the test program.
I've tried it with two different displays and get the same behavior. Any idea what's going on, or what I should look for?
If I just display on the screen, it works.
If I display nothing and read from the touchscreen, it works.
But if I read the touchscreen and then display something once on the screen, the touchscreen starts generating random touches forever!
I'm powering the Teensy from USB, and the screen from the 5V pin on the Teensy. I have decoupling caps on the power to the screen.
Here's the test program.
Code:
#include <Adafruit_GFX.h>
#include <SPI.h>
#include <Adafruit_ILI9341.h>
//#include <ILI9341_t3.h> // not for Teensy LC
#include <XPT2046_Touchscreen.h>
#define TS_CS 8
XPT2046_Touchscreen ts(TS_CS);
#define TFT_CS 10
#define TFT_DC 20
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
//ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC); // not for Teensy LC
void setup(void) {
Serial.begin(9600);
tft.begin();
if (ts.begin()) Serial.println("Touchscreen started.");
tft.fillScreen(ILI9341_BLUE);
ts.getPoint(); delay(300); ts.getPoint(); // discard bogus touches
delay(300);}
void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint(); // get raw point
Serial.print(p.x); Serial.print(", ");
Serial.print(p.y); Serial.print(", ");
Serial.println(p.z);
tft.drawCircle(100, 100, 10, ILI9341_WHITE); // causes touchscreen to go crazy!
delay(300); } }