diff --git a/Adafruit_TFTLCD.cpp b/Adafruit_TFTLCD.cpp index ee7693f..bd24a71 100644 --- a/Adafruit_TFTLCD.cpp +++ b/Adafruit_TFTLCD.cpp @@ -171,6 +171,97 @@ static const uint8_t HX8347G_regValues[] PROGMEM = { 0x08 , 0x01, 0x09 , 0x3F }; +//new for SWIFT Display +static const uint16_t ST7781_regValues[] PROGMEM = { + 0x0001,0x0100, + 0x0002,0x0700, +0x0003,0x1030, +0x0008,0x0302, +0x0009,0x0000, +0x000A,0x0008, +//*******POWER CONTROL REGISTER INITIAL*******// +0x0010,0x0790, +0x0011,0x0005, +0x0012,0x0000, +0x0013,0x0000, + //delayms(50, +//********POWER SUPPPLY STARTUP 1 SETTING*******// +0x0010,0x12B0, +// delayms(50, +0x0011,0x0007, + //delayms(50, +//********POWER SUPPLY STARTUP 2 SETTING******// +0x0012,0x008C, +0x0013,0x1700, +0x0029,0x0022, +// delayms(50, +//******GAMMA CLUSTER SETTING******// +0x0030,0x0000, +0x0031,0x0505, +0x0032,0x0205, +0x0035,0x0206, +0x0036,0x0408, +0x0037,0x0000, +0x0038,0x0504, +0x0039,0x0206, +0x003C,0x0206, +0x003D,0x0408, +// -----------DISPLAY WINDOWS 240*320-------------// +0x0050,0x0000, +0x0051,0x00EF, +0x0052,0x0000, +0x0053,0x013F, +//-----FRAME RATE SETTING-------// +0x0060,0xA700, +0x0061,0x0001, +0x0090,0x0033, //RTNI setting +//-------DISPLAY ON------// +0x0007,0x0133, 0x0001,0x0100, + 0x0002,0x0700, +0x0003,0x1030, +0x0008,0x0302, +0x0009,0x0000, +0x000A,0x0008, +//*******POWER CONTROL REGISTER INITIAL*******// +0x0010,0x0790, +0x0011,0x0005, +0x0012,0x0000, +0x0013,0x0000, + //delayms(50, +//********POWER SUPPPLY STARTUP 1 SETTING*******// +0x0010,0x12B0, +// delayms(50, +0x0011,0x0007, +// delayms(50, +//********POWER SUPPLY STARTUP 2 SETTING******// +0x0012,0x008C, +0x0013,0x1700, +0x0029,0x0022, +// delayms(50, +//******GAMMA CLUSTER SETTING******// +0x0030,0x0000, +0x0031,0x0505, +0x0032,0x0205, +0x0035,0x0206, +0x0036,0x0408, +0x0037,0x0000, +0x0038,0x0504, +0x0039,0x0206, +0x003C,0x0206, +0x003D,0x0408, +// -----------DISPLAY WINDOWS 240*320-------------// +0x0050,0x0000, +0x0051,0x00EF, +0x0052,0x0000, +0x0053,0x013F, +//-----FRAME RATE SETTING-------// +0x0060,0xA700, +0x0061,0x0001, +0x0090,0x0033, //RTNI setting +//-------DISPLAY ON------// +0x0007,0x0133, +}; + static const uint8_t HX8357D_regValues[] PROGMEM = { HX8357_SWRESET, 0, @@ -268,6 +359,18 @@ void Adafruit_TFTLCD::begin(uint16_t id) { } setRotation(rotation); setAddrWindow(0, 0, TFTWIDTH-1, TFTHEIGHT-1); + } else if (id == 0x7783 ){ //new for SWITCH Display + uint16_t a, d; + driver = ID_932X; + CS_ACTIVE; + while(i < sizeof(ST7781_regValues) / sizeof(uint16_t)) { + a = pgm_read_word(&ST7781_regValues[i++]); + d = pgm_read_word(&ST7781_regValues[i++]); + if(a == TFTLCD_DELAY) delay(d); + else writeRegister16(a, d); + } + setRotation(rotation); + setAddrWindow(0, 0, TFTWIDTH-1, TFTHEIGHT-1); } else if (id == 0x9341) { diff --git a/README.txt b/README.md similarity index 82% rename from README.txt rename to README.md index 85e3032..a705b37 100644 --- a/README.txt +++ b/README.md @@ -1,3 +1,13 @@ +# Fork working with 0x7783 LCD devices + +Added the hardware specific values from the SWIFT driver by Smoke And Wires +This works also for some Iduino 2.8'' displays + +Now you can work with the Adafruit examples. + +This library is only for the Arduino Uno + + This is a library for the Adafruit 2.8" TFT display. This library works with the Adafruit 2.8" TFT Breakout w/SD card ----> http://www.adafruit.com/products/335 diff --git a/examples/graphicstest/graphicstest.pde b/examples/graphicstest/graphicstest.ino similarity index 99% rename from examples/graphicstest/graphicstest.pde rename to examples/graphicstest/graphicstest.ino index 14701c7..6b15f85 100755 --- a/examples/graphicstest/graphicstest.pde +++ b/examples/graphicstest/graphicstest.ino @@ -69,6 +69,8 @@ void setup(void) { Serial.println(F("Found ILI9341 LCD driver")); } else if(identifier == 0x8357) { Serial.println(F("Found HX8357D LCD driver")); + } else if(identifier == 0x7783){ + Serial.println(F("Found 7783 LCD driver")); } else { Serial.print(F("Unknown LCD driver chip: ")); Serial.println(identifier, HEX); diff --git a/examples/rotationtest/rotationtest.pde b/examples/rotationtest/rotationtest.ino similarity index 98% rename from examples/rotationtest/rotationtest.pde rename to examples/rotationtest/rotationtest.ino index 7b83622..3d96992 100644 --- a/examples/rotationtest/rotationtest.pde +++ b/examples/rotationtest/rotationtest.ino @@ -67,6 +67,8 @@ void setup(void) { Serial.println(F("Found ILI9341 LCD driver")); } else if(identifier == 0x8357) { Serial.println(F("Found HX8357D LCD driver")); + } else if(identifier == 0x7783){ + Serial.println(F("Found 7783 LCD driver")); } else { Serial.print(F("Unknown LCD driver chip: ")); Serial.println(identifier, HEX); diff --git a/examples/tftbmp/tftbmp.pde b/examples/tftbmp/tftbmp.ino similarity index 99% rename from examples/tftbmp/tftbmp.pde rename to examples/tftbmp/tftbmp.ino index 8979ed1..b5418ce 100755 --- a/examples/tftbmp/tftbmp.pde +++ b/examples/tftbmp/tftbmp.ino @@ -58,6 +58,8 @@ void setup() Serial.println(F("Found ILI9341 LCD driver")); } else if(identifier == 0x8357) { Serial.println(F("Found HX8357D LCD driver")); + } else if(identifier == 0x7783){ + Serial.println(F("Found 7783 LCD driver")); } else { Serial.print(F("Unknown LCD driver chip: ")); Serial.println(identifier, HEX); diff --git a/examples/tftpaint/tftpaint.ino b/examples/tftpaint/tftpaint.ino index 0380b2c..db0e198 100644 --- a/examples/tftpaint/tftpaint.ino +++ b/examples/tftpaint/tftpaint.ino @@ -49,10 +49,27 @@ #define YM 9 // can be a digital pin #define XP 8 // can be a digital pin +//Measured ADC values for (0,0) and (210-1,320-1) +//TS_MINX corresponds to ADC value when X = 0 +//TS_MINY corresponds to ADC value when Y = 0 +//TS_MAXX corresponds to ADC value when X = 240 -1 +//TS_MAXY corresponds to ADC value when Y = 320 -1 +/* + * use touch_calibrate to check out + */ +/* #define TS_MINX 150 #define TS_MINY 120 #define TS_MAXX 920 #define TS_MAXY 940 +*/ +/* + * values for 0x7783 device + */ +#define TS_MINX 900 +#define TS_MINY 160 +#define TS_MAXX 120 +#define TS_MAXY 710 // For better pressure precision, we need to know the resistance // between X+ and X- Use any multimeter to read it @@ -101,6 +118,8 @@ void setup(void) { Serial.println(F("Found ILI9341 LCD driver")); } else if(identifier == 0x8357) { Serial.println(F("Found HX8357D LCD driver")); + } else if(identifier == 0x7783){ + Serial.println(F("Found 7783 LCD driver")); } else { Serial.print(F("Unknown LCD driver chip: ")); Serial.println(identifier, HEX); diff --git a/examples/touch_calibrate/touch_calibrate.ino b/examples/touch_calibrate/touch_calibrate.ino new file mode 100644 index 0000000..26e67c4 --- /dev/null +++ b/examples/touch_calibrate/touch_calibrate.ino @@ -0,0 +1,67 @@ +// Touch screen library with X Y and Z (pressure) readings as well +// as oversampling to avoid 'bouncing' +// This demo code returns raw readings, public domain + +/* + * This library is for calibrating your touch screen + */ + +#include +#include +#include +#include "TouchScreen.h" + +#define YP A2 // must be an analog pin, use "An" notation! +#define XM A3 // must be an analog pin, use "An" notation! +#define YM 8 // can be a digital pin +#define XP 9 // can be a digital pin + +#define LCD_CS A3 +#define LCD_CD A2 +#define LCD_WR A1 +#define LCD_RD A0 +// optional +#define LCD_RESET A4 + +#define BLACK 0x0000 +#define BLUE 0x001F +#define RED 0xF800 +#define GREEN 0x07E0 +#define CYAN 0x07FF +#define MAGENTA 0xF81F +#define YELLOW 0xFFE0 +#define WHITE 0xFFFF +#define BOXSIZE 40 +#define PENRADIUS 3 + + +Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); +// 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); + +void setup(void) { + Serial.begin(9600); + tft.reset(); + uint16_t identifier = tft.readID(); + tft.begin(identifier); + tft.fillScreen(BLACK); + tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED); + tft.fillRect(tft.width()-BOXSIZE-1,tft.height()-BOXSIZE-1,BOXSIZE, BOXSIZE,GREEN); +} + +void loop(void) { + // a point object holds x y and z coordinates + TSPoint p = ts.getPoint(); + + // 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); + } + + delay(100); +}