Skip to content

Add support for displays with blacktab colors and greentab offsets #193

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions Adafruit_ST7735.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void Adafruit_ST7735::initB(void) {
/**************************************************************************/
void Adafruit_ST7735::initR(uint8_t options) {
commonInit(Rcmd1);
if (options == INITR_GREENTAB) {
if ((options == INITR_GREENTAB) || (options == INITR_BLACKTAB_OFFSETS)) {
displayInit(Rcmd2green);
_colstart = 2;
_rowstart = 1;
Expand Down Expand Up @@ -258,8 +258,8 @@ void Adafruit_ST7735::initR(uint8_t options) {
}
displayInit(Rcmd3);

// Black tab, change MADCTL color filter
if ((options == INITR_BLACKTAB) || (options == INITR_MINI160x80)) {
// Black tab or similar, change MADCTL color filter
if ((options == INITR_BLACKTAB) || (options == INITR_MINI160x80) || (options == INITR_BLACKTAB_OFFSETS)) {
uint8_t data = 0xC0;
sendCommand(ST77XX_MADCTL, &data, 1);
}
Expand Down Expand Up @@ -295,11 +295,7 @@ void Adafruit_ST7735::setRotation(uint8_t m) {

switch (rotation) {
case 0:
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
} else {
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST7735_MADCTL_BGR;
}
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY;

if (tabcolor == INITR_144GREENTAB) {
_height = ST7735_TFTHEIGHT_128;
Expand All @@ -316,11 +312,7 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
_ystart = _rowstart;
break;
case 1:
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
} else {
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST7735_MADCTL_BGR;
}
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV;

if (tabcolor == INITR_144GREENTAB) {
_width = ST7735_TFTHEIGHT_128;
Expand All @@ -337,12 +329,6 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
_xstart = _rowstart;
break;
case 2:
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
madctl = ST77XX_MADCTL_RGB;
} else {
madctl = ST7735_MADCTL_BGR;
}

if (tabcolor == INITR_144GREENTAB) {
_height = ST7735_TFTHEIGHT_128;
_width = ST7735_TFTWIDTH_128;
Expand All @@ -358,11 +344,7 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
_ystart = _rowstart;
break;
case 3:
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
} else {
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST7735_MADCTL_BGR;
}
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV;

if (tabcolor == INITR_144GREENTAB) {
_width = ST7735_TFTHEIGHT_128;
Expand All @@ -380,5 +362,12 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
break;
}

// Black tab or similar, change MADCTL color filter
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80) || (tabcolor == INITR_BLACKTAB_OFFSETS)) {
madctl = madctl | ST77XX_MADCTL_RGB;
} else {
madctl = madctl | ST7735_MADCTL_BGR;
}

sendCommand(ST77XX_MADCTL, &madctl, 1);
}
1 change: 1 addition & 0 deletions Adafruit_ST7735.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define INITR_MINI160x80 0x04
#define INITR_HALLOWING 0x05
#define INITR_MINI160x80_PLUGIN 0x06
#define INITR_BLACKTAB_OFFSETS 0x07 // like black tab, but with offsets of green tab

// Some register settings
#define ST7735_MADCTL_BGR 0x08
Expand Down