Everything is peachy. I have it running for a few days as I play with the other Mega/TFT and the touch screen examples. Now I have my two touch buttons mapped and Printing to the serial monitor "Button 1" and "Button 2" on the second platform. Upon moving this piece of code into the unit I get the touch screen working but the display whites out. Ahhh the shared pins! Using The paint example as a guide I get the pin sharing working.
Now....the program is so slow you have to hold the soft button and wait for the update. Not good.
The Paint Program did not seem to have this problem
do I need to get rid of the shared pins?
Is there some clever code that I am missing?
Do I need a dedicated Arduino for the display? I have an Uno I could use.Maybe a SPI connection.
HELP!
HELP!
The gist of it is here
Code: Select all
#include <stdint.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>
#ifndef USE_ADAFRUIT_SHIELD_PINOUT
#error "This sketch is intended for use with the TFT LCD Shield. Make sure that USE_ADAFRUIT_SHIELD_PINOUT is #defined in the Adafruit_TFTLCD.h library file."
#endif
// These are the pins for the shield!
#define YP A1 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 7 // can be a digital pin
#define XP 6 // can be a digital pin
#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#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
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_TFTLCD tft;
#define BOXSIZE 40
#define BANNED 4
int oldcolor, currentcolor;
void setup(void) {
Serial.begin(9600);
//progmemPrintln(PSTR("Paint!"));
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
tft.fillScreen(BLACK);
pinMode(13, OUTPUT);
}
#define MINPRESSURE 10
#define MAXPRESSURE 1000
void loop()
{
tft.setCursor(0, 0);
tft.fillScreen(BLACK);
tft.setTextColor(GREEN);
tft.setTextSize(5);
tft.println("Waiting");
digitalWrite(13, HIGH);
Point p = ts.getPoint();
digitalWrite(13, LOW);
// if sharing pins, you'll need to fix the directions of the touchscreen pins
//pinMode(XP, OUTPUT);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
//pinMode(YM, OUTPUT);
// we have some minimum pressure we consider 'valid'
// pressure of 0 means no pressing!
if (p.z > ts.pressureThreshhold) {
Serial.print("X = "); Serial.print(p.x);
Serial.print("\tY = "); Serial.print(p.y);
Serial.print("\tPressure = "); Serial.println(p.z);
}
}