Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork working with 0x7783 LCD devices #32

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
103 changes: 103 additions & 0 deletions Adafruit_TFTLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Copy link

@AndreyArduino AndreyArduino Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line 362 - else if (id == 0x7783 ) you must specify two equal signs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuh, of course.
Done.

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) {

Expand Down
10 changes: 10 additions & 0 deletions README.txt → README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions examples/tftbmp/tftbmp.pde → examples/tftbmp/tftbmp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions examples/tftpaint/tftpaint.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
67 changes: 67 additions & 0 deletions examples/touch_calibrate/touch_calibrate.ino
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>
#include <Adafruit_GFX.h>
#include <Adafruit_TFTLCD.h>
#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);
}