mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
[P116] Add support for ST7735/ST7789 170x320 displays
This commit is contained in:
@@ -28,7 +28,7 @@ The ST7735, ST7789 and ST7796 chip families drive color TFT displays in various
|
||||
|
||||
This plugin supports these display models:
|
||||
|
||||
* **ST7735** with resolutions 128 x 128, 128 x 160, 80 x 160, 135 x 240 and 172 x 320 pixels
|
||||
* **ST7735** with resolutions 128 x 128, 128 x 160, 80 x 160, 135 x 240, 170 x 320 and 172 x 320 pixels
|
||||
* **ST7789** with resolutions 240 x 320, 240 x 240, 240 x 280 and 135 x 240 pixels
|
||||
* **ST7796** with resolution of 320 x 480 pixels.
|
||||
|
||||
@@ -145,6 +145,7 @@ Available options:
|
||||
* *ST7735 80 x 160px (Color inverted)*: Special color inverted configuration as used in f.e. M5Stack StickC.
|
||||
* *ST7735 135 x 240px*: Added to support a revision of the TTGO T-Display 16MB Flash module, that won't work with the ST7789 driver, the seller is claiming to use, but does work with this specially crafted ST7735 driver.
|
||||
* *ST7735 172 x 320px*: Added to support an ESP32-C6 module having a display with this specific resolution.
|
||||
* *ST77xx 170 x 320px*: Added to support ST7789v3 / ST7735 displays with this specific resolution.
|
||||
* *ST7789 240 x 320px*: Allows 32 lines of text in the smallest font scaling setting. Predefined text only goes to 24, extra lines can be displayed from rules or external commands.
|
||||
* *ST7789 240 x 240px*: Allows 24 lines of text in the smallest font scaling setting.
|
||||
* *ST7789 240 x 280px*: Allows 28 lines of text in the smallest font scaling setting. Predefined text only goes to 24, extra lines can be displayed from rules or external commands.
|
||||
|
||||
@@ -198,6 +198,14 @@ static const uint8_t PROGMEM
|
||||
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
320 >> 8, 320 & 0xFF }, // XEND = 320
|
||||
Rcmd2black170x320[] = { // 7735R init, part 2 (mini 170x320)
|
||||
2, // 2 commands in list:
|
||||
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 170, // XEND = 170
|
||||
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
320 >> 8, 320 & 0xFF }, // XEND = 320
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
|
||||
Rcmd3[] = { // 7735R init, part 3 (red or green tab)
|
||||
@@ -277,6 +285,13 @@ void Adafruit_ST7735::initR(uint8_t options) {
|
||||
const uint8_t data = 0x00;
|
||||
sendCommand(ST77XX_INVON, &data, 0);
|
||||
sendCommand(ST77XX_INVON, &data, 0); // Write twice...
|
||||
} else if (options == INITR_BLACKTAB170x320) {
|
||||
_height = ST7735_TFTHEIGHT_320;
|
||||
_width = ST7735_TFTWIDTH_170;
|
||||
displayInit(Rcmd2black170x320);
|
||||
const uint8_t data = 0x00;
|
||||
sendCommand(ST77XX_INVON, &data, 0);
|
||||
sendCommand(ST77XX_INVON, &data, 0); // Write twice...
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
// colstart, rowstart left at default '0' values
|
||||
@@ -324,7 +339,7 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
|
||||
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
|
||||
#if ST7735_EXTRA_INIT
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320)) {
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320)) {
|
||||
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
@@ -348,6 +363,11 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
_width = ST7735_TFTWIDTH_172;
|
||||
_colstart = 34;
|
||||
_rowstart = 1;
|
||||
} else if (tabcolor == INITR_BLACKTAB170x320) {
|
||||
_height = ST7735_TFTHEIGHT_320;
|
||||
_width = ST7735_TFTWIDTH_170;
|
||||
_colstart = 35;
|
||||
_rowstart = 0;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
_height = ST7735_TFTHEIGHT_160;
|
||||
@@ -360,7 +380,7 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
|
||||
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
|
||||
#if ST7735_EXTRA_INIT
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320)) {
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320)) {
|
||||
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
@@ -384,6 +404,11 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
_height = ST7735_TFTWIDTH_172;
|
||||
_colstart = 34;
|
||||
_rowstart = 1;
|
||||
} else if (tabcolor == INITR_BLACKTAB170x320) {
|
||||
_width = ST7735_TFTHEIGHT_320;
|
||||
_height = ST7735_TFTWIDTH_170;
|
||||
_colstart = 35;
|
||||
_rowstart = 0;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
_width = ST7735_TFTHEIGHT_160;
|
||||
@@ -396,7 +421,7 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
|
||||
madctl = ST77XX_MADCTL_RGB;
|
||||
#if ST7735_EXTRA_INIT
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320)) {
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320)) {
|
||||
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
@@ -420,6 +445,11 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
_width = ST7735_TFTWIDTH_172;
|
||||
_colstart = 34;
|
||||
_rowstart = 1;
|
||||
} else if (tabcolor == INITR_BLACKTAB170x320) {
|
||||
_height = ST7735_TFTHEIGHT_320;
|
||||
_width = ST7735_TFTWIDTH_170;
|
||||
_colstart = 35;
|
||||
_rowstart = 0;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
_height = ST7735_TFTHEIGHT_160;
|
||||
@@ -432,7 +462,7 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
|
||||
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
|
||||
#if ST7735_EXTRA_INIT
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320)) {
|
||||
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320)) {
|
||||
madctl = ST77XX_MADCTL_RGB;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
@@ -456,6 +486,11 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
|
||||
_height = ST7735_TFTWIDTH_172;
|
||||
_colstart = 34;
|
||||
_rowstart = 1;
|
||||
} else if (tabcolor == INITR_BLACKTAB170x320) {
|
||||
_width = ST7735_TFTHEIGHT_320;
|
||||
_height = ST7735_TFTWIDTH_170;
|
||||
_colstart = 35;
|
||||
_rowstart = 0;
|
||||
#endif // if ST7735_EXTRA_INIT
|
||||
} else {
|
||||
_width = ST7735_TFTHEIGHT_160;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define INITR_GREENTAB160x80 0x06
|
||||
#define INITR_BLACKTAB135x240 0x07
|
||||
#define INITR_BLACKTAB172x320 0x08
|
||||
#define INITR_BLACKTAB170x320 0x09
|
||||
|
||||
// Some register settings
|
||||
#define ST7735_MADCTL_BGR 0x08
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#define ST7735_TFTWIDTH_80 80 // for mini
|
||||
#define ST7735_TFTWIDTH_135 135
|
||||
#define ST7735_TFTWIDTH_172 172
|
||||
#define ST7735_TFTWIDTH_170 170
|
||||
#define ST7735_TFTHEIGHT_128 128 // for 1.44" display
|
||||
#define ST7735_TFTHEIGHT_160 160 // for 1.8" and mini display
|
||||
#define ST7735_TFTHEIGHT_240 240
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
|
||||
// History:
|
||||
// 2025-06-11 tonhuisman: Add support for ST7789v3/ST7735 display with 170x320 resolution
|
||||
// 2025-02-20 tonhuisman: Add support for ST7735 display with 172x320 resolution
|
||||
// 2024-05-04 tonhuisman: Add Default font selection setting, if AdafruitGFX_Helper fonts are included
|
||||
// 2024-03-17 tonhuisman: Add support for another alternative initialization for ST7735 displays, as the display controller
|
||||
// used on the LilyGO TTGO T-Display (16 MB) seems to be a ST7735, despite being documented as ST7789
|
||||
@@ -149,6 +151,7 @@ boolean Plugin_116(uint8_t function, struct EventStruct *event, String& string)
|
||||
# if P116_EXTRA_ST7735
|
||||
ST77xx_type_toString(ST77xx_type_e::ST7735s_135x240),
|
||||
ST77xx_type_toString(ST77xx_type_e::ST7735s_172x320),
|
||||
ST77xx_type_toString(ST77xx_type_e::ST77xxs_170x320),
|
||||
# endif // if P116_EXTRA_ST7735
|
||||
ST77xx_type_toString(ST77xx_type_e::ST7789vw_240x320),
|
||||
ST77xx_type_toString(ST77xx_type_e::ST7789vw_240x240),
|
||||
@@ -169,6 +172,7 @@ boolean Plugin_116(uint8_t function, struct EventStruct *event, String& string)
|
||||
# if P116_EXTRA_ST7735
|
||||
static_cast<int>(ST77xx_type_e::ST7735s_135x240),
|
||||
static_cast<int>(ST77xx_type_e::ST7735s_172x320),
|
||||
static_cast<int>(ST77xx_type_e::ST77xxs_170x320),
|
||||
# endif // if P116_EXTRA_ST7735
|
||||
static_cast<int>(ST77xx_type_e::ST7789vw_240x320),
|
||||
static_cast<int>(ST77xx_type_e::ST7789vw_240x240),
|
||||
|
||||
@@ -14,6 +14,7 @@ const __FlashStringHelper* ST77xx_type_toString(const ST77xx_type_e& device) {
|
||||
# if P116_EXTRA_ST7735
|
||||
case ST77xx_type_e::ST7735s_135x240: return F("ST7735 135 x 240px");
|
||||
case ST77xx_type_e::ST7735s_172x320: return F("ST7735 172 x 320px");
|
||||
case ST77xx_type_e::ST77xxs_170x320: return F("ST77xx 170 x 320px");
|
||||
# endif // if P116_EXTRA_ST7735
|
||||
case ST77xx_type_e::ST7789vw_240x320: return F("ST7789 240 x 320px");
|
||||
case ST77xx_type_e::ST7789vw_240x240: return F("ST7789 240 x 240px");
|
||||
@@ -78,6 +79,10 @@ void ST77xx_type_toResolution(const ST77xx_type_e& device,
|
||||
x = 172;
|
||||
y = 320;
|
||||
break;
|
||||
case ST77xx_type_e::ST77xxs_170x320:
|
||||
x = 170;
|
||||
y = 320;
|
||||
break;
|
||||
# endif // if P116_EXTRA_ST7735
|
||||
case ST77xx_type_e::ST7796s_320x480:
|
||||
x = 320;
|
||||
@@ -189,6 +194,13 @@ bool P116_data_struct::plugin_init(struct EventStruct *event) {
|
||||
initRoptions = INITR_BLACKTAB172x320; // 172x320px
|
||||
}
|
||||
|
||||
// fall through
|
||||
case ST77xx_type_e::ST77xxs_170x320:
|
||||
|
||||
if (initRoptions == 0xFF) {
|
||||
initRoptions = INITR_BLACKTAB170x320; // 170x320px
|
||||
}
|
||||
|
||||
// fall through
|
||||
# endif // if P116_EXTRA_ST7735
|
||||
case ST77xx_type_e::ST7735s_80x160:
|
||||
|
||||
@@ -102,6 +102,7 @@ enum class ST77xx_type_e : uint8_t {
|
||||
# if P116_EXTRA_ST7735
|
||||
ST7735s_135x240 = 12u,
|
||||
ST7735s_172x320 = 13u,
|
||||
ST77xxs_170x320 = 14u,
|
||||
# endif // if P116_EXTRA_ST7735
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user