Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
Added support for IPS display types using the 'begin' function gfx.begin(IPS_DISPLAY);
  • Loading branch information
4D Systems committed Jan 28, 2021
1 parent 43b48e8 commit d0990b5
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 59 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ For detailed information on the gen4-IoD's and procedures for installation, plea
## Questions/Issues?

Please sign up for our Forum and ask a question there, or submit a Tech Support Ticket from our website.
Please do NOT post issues on Github, as this is not actively monitored. Please use one of the following:
http://forum.4dsystems.com.au or http://www.4dsystems.com.au/support
You can also submit issues via Github if desired.

1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ PORTRAIT_R LITERAL1
LANDSCAPE LITERAL1
LANDSCAPE_R LITERAL1

IPS_DISPLAY LITERAL1
FONT1 LITERAL1
FONT2 LITERAL1
Pressed LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=GFX4d
version=1.0.1
version=1.0.2
author=4D Systems Pty Ltd
maintainer=4D Systems Pty Ltd <[email protected]>
sentence=Graphics Library for the gen4-IoD by 4D Systems
Expand Down
31 changes: 31 additions & 0 deletions src/Examples/IoDTemplateIPS/IoDTemplateIPS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/******************************************
* IoD Template *
* A blank template for any IoD sketch *
* with common commands to quickly start *
* a sketch that initializes the screen *
* *
******************************************/


#include "ESP8266WiFi.h"
#include "GFX4d.h"

GFX4d gfx = GFX4d();

void setup() {

gfx.begin(IPS_DISPLAY);
gfx.Cls();
gfx.ScrollEnable(true);
gfx.BacklightOn(true);
gfx.Orientation(PORTRAIT);
gfx.SmoothScrollSpeed(5);
gfx.TextColor(WHITE); gfx.Font(2); gfx.TextSize(1);

}

void loop() {

yield();

}
91 changes: 54 additions & 37 deletions src/GFX4d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ GFX4d::GFX4d(){
_tcs = 2;
_sd = 5;
#else
_dc = 27; //m5stack
_cs = 14; //m5stack
_sRes = 33; //m5stack
_dc = 27;
_cs = 14;
_sRes = 33;
//_dc = 33;
//_cs = 27;
_disp = 32;
_tcs = 9;
_sd = 4; //m5stack
_sd = 4;
//_sd = 10;
#endif
scrollOffset = 0;
Expand All @@ -243,19 +243,23 @@ GFX4d::GFX4d(){
twcurson = true;

}
#ifdef M5STACK
SPISettings spiSettings = SPISettings(79000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsD = SPISettings(79000000, MSBFIRST, SPI_MODE0);
#else

SPISettings spiSettings = SPISettings(79000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsD = SPISettings(79000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsR = SPISettings(39000000, MSBFIRST, SPI_MODE0);
#endif
SPISettings spiSettingsT = SPISettings(6900000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsT32 = SPISettings(4900000, MSBFIRST, SPI_MODE0);

void GFX4d::begin(void) {



void GFX4d::begin(byte dtds) {
if(dtds & 0x01) IPSDisplay = true;
begin();
}

void GFX4d::begin(void) {

pinMode(_sclk, OUTPUT);
pinMode(_mosi, OUTPUT);
pinMode(_miso, INPUT);
Expand All @@ -280,49 +284,54 @@ void GFX4d::begin(void) {
SPI.begin();
SPI.beginTransaction(spiSettingsD);

SetCommand(0xEF); SetData(0x03); SetData(0x80); SetData(0x02);
SetCommand(0xCF); SetData(0x00); SetData(0XC1); SetData(0X30);
SetCommand(0xED); SetData(0x64); SetData(0x03); SetData(0X12); SetData(0X81);
SetCommand(0xE8); SetData(0x85); SetData(0x00); SetData(0x78);
SetCommand(0xEF); SetData(0x01); SetData(0x01); SetData(0x00);
SetCommand(0xCF); SetData(0x00); SetData(0xC1); SetData(0x30);
SetCommand(0xED); SetData(0x64); SetData(0x03); SetData(0x12); SetData(0x81);
SetCommand(0xE8); SetData(0x85); SetData(0x00); SetData(0x7a);
SetCommand(0xCB); SetData(0x39); SetData(0x2C); SetData(0x00); SetData(0x34); SetData(0x02);
SetCommand(0xF7); SetData(0x20);
SetCommand(0xEA); SetData(0x00); SetData(0x00);
SetCommand(GFX4d_PWCTR1); SetData(0x23);
SetCommand(GFX4d_PWCTR2); SetData(0x10);
SetCommand(GFX4d_VMCTR1); SetData(0x3e); SetData(0x28);
SetCommand(GFX4d_VMCTR2); SetData(0x86);
#ifdef M5STACK
SetCommand(GFX4d_MADCTL); SetData(0xA8);
#else
if(!(IPSDisplay)){
SetCommand(GFX4d_PWCTR1); SetData(0x26);
}else{
SetCommand(GFX4d_PWCTR1); SetData(0x12); SetData(0x12);
}
SetCommand(GFX4d_PWCTR2); SetData(0x11);
SetCommand(GFX4d_VMCTR1); SetData(0x39); SetData(0x27);
SetCommand(GFX4d_VMCTR2); SetData(0xa6);
SetCommand(GFX4d_MADCTL); SetData(0x48);
#endif
SetCommand(GFX4d_PIXFMT); SetData(0x55);
#ifdef M5STACK
SetCommand(GFX4d_FRMCTR1); SetData(0x00); SetData(0x13);
#else
SetCommand(GFX4d_FRMCTR1); SetData(0x00); SetData(0x18);
#endif
SetCommand(GFX4d_FRMCTR1); SetData(0x00); SetData(0x1b);
SetCommand(GFX4d_DFUNCTR); SetData(0x08); SetData(0x82); SetData(0x27);
SetCommand(0xF2); SetData(0x00);
SetCommand(GFX4d_GAMMASET); SetData(0x01);
SetCommand(GFX4d_GMCTRP1); SetData(0x0F); SetData(0x31); SetData(0x2B); SetData(0x0C);
SetData(0x0E); SetData(0x08); SetData(0x4E); SetData(0xF1);
if(!(IPSDisplay)){
SetCommand(GFX4d_GMCTRP1); SetData(0x0F); SetData(0x2d); SetData(0x0e); SetData(0x08);
SetData(0x12); SetData(0x0a); SetData(0x3d); SetData(0x95);
SetData(0x31); SetData(0x04); SetData(0x10); SetData(0x09);
SetData(0x09); SetData(0x0d); SetData(0x00);
SetCommand(GFX4d_GMCTRN1); SetData(0x00); SetData(0x12); SetData(0x17); SetData(0x03);
SetData(0x0d); SetData(0x05); SetData(0x2c); SetData(0x44);
SetData(0x41); SetData(0x05); SetData(0x0F); SetData(0x0a);
SetData(0x30); SetData(0x32); SetData(0x0F);
}else{
SetCommand(GFX4d_GMCTRP1); SetData(0x0F); SetData(0x31); SetData(0x2b); SetData(0x0c);
SetData(0x0e); SetData(0x08); SetData(0x4e); SetData(0xf1);
SetData(0x37); SetData(0x07); SetData(0x10); SetData(0x03);
SetData(0x0E); SetData(0x09); SetData(0x00);
SetCommand(GFX4d_GMCTRN1); SetData(0x00); SetData(0x0E); SetData(0x14); SetData(0x03);
SetData(0x11); SetData(0x07); SetData(0x31); SetData(0xC1);
SetData(0x48); SetData(0x08); SetData(0x0F); SetData(0x0C);
SetData(0x31); SetData(0x36); SetData(0x0F);
SetData(0x0e); SetData(0x09); SetData(0x00);
SetCommand(GFX4d_GMCTRN1); SetData(0x00); SetData(0x0e); SetData(0x14); SetData(0x03);
SetData(0x11); SetData(0x07); SetData(0x31); SetData(0xc1);
SetData(0x48); SetData(0x08); SetData(0x0f); SetData(0x0c);
SetData(0x31); SetData(0x36); SetData(0x0F);
}
SetCommand(GFX4d_SLPOUT);
SPI.endTransaction();
delay(120);
SPI.beginTransaction(spiSettingsD);
SetCommand(GFX4d_DISPON);
SPI.endTransaction();
setScrollArea(0, 0);
#ifdef M5STACK
Invert(true);
#endif
if(IPSDisplay) Invert(false);
Cls(0);
#ifndef USE_FS
//#ifndef ESP32
Expand Down Expand Up @@ -2997,9 +3006,17 @@ void GFX4d::Orientation(uint8_t m) {
void GFX4d::Invert(boolean i) {
SPI.beginTransaction(spiSettingsD);
if(i){
if(IPSDisplay){
SetCommand(GFX4d_INVOFF);
} else {
SetCommand(GFX4d_INVON);
}
} else {
if(IPSDisplay){
SetCommand(GFX4d_INVON);
} else {
SetCommand(GFX4d_INVOFF);
}
}
SPI.endTransaction();
}
Expand Down
27 changes: 7 additions & 20 deletions src/GFX4d.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@

#ifndef _GFX4d_H
#define _GFX4d_H
//#define USE_FS
// #define USE_FS
#define IPS_DISPLAY 1
#define TN_DISPLAY 0
#define SD_FILESYSTEM 0
#define LFS_FILESYSTEM 2
#include "Arduino.h"
#include "Print.h"
#ifndef USE_FS
Expand All @@ -187,25 +191,6 @@
//#define FS_NO_GLOBALS //allow spiffs to coexist with SD card, define BEFORE including FS.h
#include <LittleFS.h> //spiff file system
#endif
#ifdef ESP32
#define M5STACK
#endif
#ifdef M5STACK
// Buttons
#define BTN_A 0
#define BTN_B 1
#define BTN_C 2
#define BUTTON_A 0
#define BUTTON_B 1
#define BUTTON_C 2
#define BUTTON_A_PIN 39
#define BUTTON_B_PIN 38
#define BUTTON_C_PIN 37

// BEEP PIN
#define SPEAKER_PIN 25
#define TONE_PIN_CHANNEL 0
#endif

#define MAX_WIDGETS 400

Expand Down Expand Up @@ -761,6 +746,7 @@ fs::File userDat;
GFX4d();

void begin(void),
begin(byte a),
setGRAM(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1),
WrGRAM(uint32_t color),
WrGRAMs(uint32_t *data, uint16_t l),
Expand Down Expand Up @@ -986,6 +972,7 @@ boolean draw, uint32_t bgindex),
int8_t lastfsh;
int8_t lastfsw;
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk, _disp, _tcs, _sd, _sRes;
boolean IPSDisplay = false;

public:
int16_t //lastArcOld[max_ARCSIZE],
Expand Down
1 change: 1 addition & 0 deletions src/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ PORTRAIT_R LITERAL1
LANDSCAPE LITERAL1
LANDSCAPE_R LITERAL1

IPS_DISPLAY LITERAL1
FONT1 LITERAL1
FONT2 LITERAL1
Pressed LITERAL1
Expand Down

0 comments on commit d0990b5

Please sign in to comment.