Here is the whole page of code, with the example and three included libraries attached. This is just a basic hello world program:
/#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4/
//This is from the paint program example
#define YP A1;
#define XM A2;
#define YM 7;
#define XP 6;
#define TS_LEFT 150;
#define TS_RT 930;
#define TS_TOP 130;
#define TS_BOT 920;
#include <SPI.h>
#include "Adafruit_GFX.h"
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
uint16_t identifier;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
TSPoint tp;
void setup() {
identifier = 0x6809;
tft.begin(identifier);
text();
smilie(YELLOW, BLACK, RED);
}
void loop() {
uint16_t xpos, ypos; //screen coordinates
tp = ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
pinMode(XP, OUTPUT);
pinMode(YM, OUTPUT);
xpos = map(tp.x, TS_LEFT, TS_RT, 0, tft.width());
ypos = map(tp.y, TS_TOP, TS_BOT, 0, tft.height());
}
unsigned long text() {
tft.fillScreen(BLACK);
tft.setCursor(45, 10);
tft.setTextColor(WHITE);
tft.setTextSize(5.5);
if (xpos == 0 && ypos == 0) {
tft.println("Hello, World!");
} else {
tft.println("Owch!");
}
}
unsigned long smilie(int color1, int color2, int color3) {
tft.fillCircle(120, 200, 100, color1);
tft.fillCircle(80, 175, 25, color2);
tft.fillCircle(160, 175, 25, color2);
tft.fillRoundRect(70, 220, 100, 50, 25, color3);
}
MCUFRIEND_kbv.h (2.15 KB)
Adafruit_GFX.h (4.83 KB)
TouchScreen.h (800 Bytes)
Touch_shield_kbv.ino (10.7 KB)