106 lines
3.1 KiB
C++
Executable File
106 lines
3.1 KiB
C++
Executable File
|
|
//#include "TFTLCD.h"
|
|
#include "TouchScreen.h"
|
|
|
|
#include <Adafruit_GFX.h> // Core graphics library
|
|
#include <SWTFT.h>
|
|
|
|
|
|
//Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:
|
|
|
|
|
|
|
|
#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
|
|
|
|
// For better pressure precision, we need to know the resistance
|
|
// between X+ and X- Use any multimeter to read it
|
|
// For the one we're using, its 300 ohms across the X plate
|
|
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
|
|
|
|
#define LCD_CS A3
|
|
#define LCD_CD A2
|
|
#define LCD_WR A1
|
|
#define LCD_RD A0
|
|
// optional
|
|
#define LCD_RESET A4
|
|
|
|
// Color definitions
|
|
#define BLACK 0x0000
|
|
#define BLUE 0x001F
|
|
#define RED 0xF800
|
|
#define GREEN 0x07E0
|
|
#define CYAN 0x07FF
|
|
#define MAGENTA 0xF81F
|
|
#define YELLOW 0xFFE0
|
|
#define WHITE 0xFFFF
|
|
|
|
|
|
|
|
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
|
|
//-- Assign human-readable names to some common 16-bit color values:
|
|
|
|
// Replaced standard code here with 16bit color codes from http://stackoverflow.com/questions/13720937/c-defined-16bit-high-color
|
|
// These color codes seemed to be a little more accurate
|
|
|
|
#define Black 0x0000 /* 0, 0, 0 */
|
|
#define Navy 0x000F /* 0, 0, 128 */
|
|
#define DarkGreen 0x03E0 /* 0, 128, 0 */
|
|
#define DarkCyan 0x03EF /* 0, 128, 128 */
|
|
#define Maroon 0x7800 /* 128, 0, 0 */
|
|
#define Purple 0x780F /* 128, 0, 128 */
|
|
#define Olive 0x7BE0 /* 128, 128, 0 */
|
|
#define LightGrey 0xC618 /* 192, 192, 192 */
|
|
#define DarkGrey 0x7BEF /* 128, 128, 128 */
|
|
#define Blue 0x001F /* 0, 0, 255 */
|
|
#define Green 0x07E0 /* 0, 255, 0 */
|
|
#define Cyan 0x07FF /* 0, 255, 255 */
|
|
#define Red 0xF800 /* 255, 0, 0 */
|
|
#define Magenta 0xF81F /* 255, 0, 255 */
|
|
#define Yellow 0xFFE0 /* 255, 255, 0 */
|
|
#define White 0xFFFF /* 255, 255, 255 */
|
|
#define Orange 0xFD20 /* 255, 165, 0 */
|
|
#define GreenYellow 0xAFE5 /* 173, 255, 47 */
|
|
//--SetUp
|
|
|
|
void setup(void) {
|
|
tft.reset();
|
|
// tft.begin(0x9341); // Correct colors mirrored text
|
|
tft.begin(0x8357); // Inverted colors correct text
|
|
}
|
|
|
|
void loop(void) {
|
|
for(uint8_t rotation=0; rotation<4; rotation++) {
|
|
tft.setRotation(rotation);
|
|
testText();
|
|
delay(2000);
|
|
}
|
|
}
|
|
|
|
unsigned long testText() {
|
|
tft.fillScreen(Black);
|
|
unsigned long start = micros();
|
|
tft.setCursor(0, 0);
|
|
tft.setTextColor(White);
|
|
tft.setTextSize(1);
|
|
tft.println("Dedmore");
|
|
tft.setTextColor(Yellow);
|
|
tft.setTextSize(2);
|
|
tft.println("Dedmore");
|
|
tft.setTextColor(Red);
|
|
tft.setTextSize(3);
|
|
tft.println("Dedmore");
|
|
tft.println();
|
|
tft.setTextColor(Navy);
|
|
tft.setTextSize(5);
|
|
tft.println("Dedmore");
|
|
return micros() - start;
|
|
}
|