[P116] Add ST77xx resolutions 240x320 and 240x280

This commit is contained in:
Ton Huisman
2025-12-20 23:17:04 +01:00
parent 8693e9d20b
commit b25839f945
6 changed files with 110 additions and 6 deletions
+74 -4
View File
@@ -206,6 +206,22 @@ 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
Rcmd2black240x320[] = { // 7735R init, part 2 (mini 240x320)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 240, // XEND = 240
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
320 >> 8, 320 & 0xFF }, // XEND = 320
Rcmd2black240x280[] = { // 7735R init, part 2 (mini 240x280)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 240, // XEND = 240
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
280 >> 8, 280 & 0xFF }, // XEND = 240
#endif // if ST7735_EXTRA_INIT
Rcmd3[] = { // 7735R init, part 3 (red or green tab)
@@ -292,6 +308,20 @@ 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_BLACKTAB240x320) {
_height = ST7735_TFTHEIGHT_320;
_width = ST7735_TFTWIDTH_240;
displayInit(Rcmd2black240x320);
const uint8_t data = 0x00;
sendCommand(ST77XX_INVON, &data, 0);
sendCommand(ST77XX_INVON, &data, 0); // Write twice...
} else if (options == INITR_BLACKTAB240x280) {
_height = ST7735_TFTHEIGHT_280;
_width = ST7735_TFTWIDTH_240;
displayInit(Rcmd2black240x280);
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
@@ -339,7 +369,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) || (tabcolor == INITR_BLACKTAB170x320)) {
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320) || (tabcolor == INITR_BLACKTAB240x320) || (tabcolor == INITR_BLACKTAB240x280)) {
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
#endif // if ST7735_EXTRA_INIT
} else {
@@ -368,6 +398,16 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
_width = ST7735_TFTWIDTH_170;
_colstart = 35;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x320) {
_height = ST7735_TFTHEIGHT_320;
_width = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x280) {
_height = ST7735_TFTHEIGHT_280;
_width = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 20;
#endif // if ST7735_EXTRA_INIT
} else {
_height = ST7735_TFTHEIGHT_160;
@@ -380,7 +420,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) || (tabcolor == INITR_BLACKTAB170x320)) {
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320) || (tabcolor == INITR_BLACKTAB240x320) || (tabcolor == INITR_BLACKTAB240x280)) {
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST77XX_MADCTL_RGB;
#endif // if ST7735_EXTRA_INIT
} else {
@@ -409,6 +449,16 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
_height = ST7735_TFTWIDTH_170;
_colstart = 35;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x320) {
_width = ST7735_TFTHEIGHT_320;
_height = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x280) {
_width = ST7735_TFTHEIGHT_280;
_height = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 20;
#endif // if ST7735_EXTRA_INIT
} else {
_width = ST7735_TFTHEIGHT_160;
@@ -421,7 +471,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) || (tabcolor == INITR_BLACKTAB170x320)) {
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320) || (tabcolor == INITR_BLACKTAB240x320) || (tabcolor == INITR_BLACKTAB240x280)) {
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST77XX_MADCTL_RGB;
#endif // if ST7735_EXTRA_INIT
} else {
@@ -450,6 +500,16 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
_width = ST7735_TFTWIDTH_170;
_colstart = 35;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x320) {
_height = ST7735_TFTHEIGHT_320;
_width = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x280) {
_height = ST7735_TFTHEIGHT_280;
_width = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 20;
#endif // if ST7735_EXTRA_INIT
} else {
_height = ST7735_TFTHEIGHT_160;
@@ -462,7 +522,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) || (tabcolor == INITR_BLACKTAB170x320)) {
} else if ((tabcolor == INITR_BLACKTAB135x240) || (tabcolor == INITR_BLACKTAB172x320) || (tabcolor == INITR_BLACKTAB170x320) || (tabcolor == INITR_BLACKTAB240x320) || (tabcolor == INITR_BLACKTAB240x280)) {
madctl = ST77XX_MADCTL_RGB;
#endif // if ST7735_EXTRA_INIT
} else {
@@ -491,6 +551,16 @@ void Adafruit_ST7735::setRotation(uint8_t m) {
_height = ST7735_TFTWIDTH_170;
_colstart = 35;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x320) {
_width = ST7735_TFTHEIGHT_320;
_height = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 0;
} else if (tabcolor == INITR_BLACKTAB240x280) {
_width = ST7735_TFTHEIGHT_280;
_height = ST7735_TFTWIDTH_240;
_colstart = 0;
_rowstart = 20;
#endif // if ST7735_EXTRA_INIT
} else {
_width = ST7735_TFTHEIGHT_160;
+2
View File
@@ -33,6 +33,8 @@
#define INITR_BLACKTAB135x240 0x07
#define INITR_BLACKTAB172x320 0x08
#define INITR_BLACKTAB170x320 0x09
#define INITR_BLACKTAB240x320 0x0A
#define INITR_BLACKTAB240x280 0x0B
// Some register settings
#define ST7735_MADCTL_BGR 0x08
+2
View File
@@ -36,9 +36,11 @@
#define ST7735_TFTWIDTH_135 135
#define ST7735_TFTWIDTH_172 172
#define ST7735_TFTWIDTH_170 170
#define ST7735_TFTWIDTH_240 240
#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
#define ST7735_TFTHEIGHT_280 280
#define ST7735_TFTHEIGHT_320 320
#define ST_CMD_DELAY 0x80 // special signifier for command lists
+6 -2
View File
@@ -152,6 +152,8 @@ boolean Plugin_116(uint8_t function, struct EventStruct *event, String& string)
ST77xx_type_toString(ST77xx_type_e::ST7735s_135x240),
ST77xx_type_toString(ST77xx_type_e::ST7735s_172x320),
ST77xx_type_toString(ST77xx_type_e::ST77xxs_170x320),
ST77xx_type_toString(ST77xx_type_e::ST77xxs_240x320),
ST77xx_type_toString(ST77xx_type_e::ST77xxs_240x280),
# endif // if P116_EXTRA_ST7735
ST77xx_type_toString(ST77xx_type_e::ST7789vw_240x320),
ST77xx_type_toString(ST77xx_type_e::ST7789vw_240x240),
@@ -173,6 +175,8 @@ boolean Plugin_116(uint8_t function, struct EventStruct *event, String& string)
static_cast<int>(ST77xx_type_e::ST7735s_135x240),
static_cast<int>(ST77xx_type_e::ST7735s_172x320),
static_cast<int>(ST77xx_type_e::ST77xxs_170x320),
static_cast<int>(ST77xx_type_e::ST77xxs_240x320),
static_cast<int>(ST77xx_type_e::ST77xxs_240x280),
# endif // if P116_EXTRA_ST7735
static_cast<int>(ST77xx_type_e::ST7789vw_240x320),
static_cast<int>(ST77xx_type_e::ST7789vw_240x240),
@@ -188,8 +192,8 @@ boolean Plugin_116(uint8_t function, struct EventStruct *event, String& string)
constexpr int optCount4 = NR_ELEMENTS(optionValues4);
const FormSelectorOptions selector(optCount4, options4, optionValues4);
selector.addFormSelector(F("TFT display model"),
F("type"),
P116_CONFIG_FLAG_GET_TYPE);
F("type"),
P116_CONFIG_FLAG_GET_TYPE);
}
addFormSubHeader(F("Layout"));
@@ -15,6 +15,8 @@ const __FlashStringHelper* ST77xx_type_toString(const ST77xx_type_e& device) {
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");
case ST77xx_type_e::ST77xxs_240x320: return F("ST77xx 240 x 320px");
case ST77xx_type_e::ST77xxs_240x280: return F("ST77xx 240 x 280px");
# 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");
@@ -83,6 +85,14 @@ void ST77xx_type_toResolution(const ST77xx_type_e& device,
x = 170;
y = 320;
break;
case ST77xx_type_e::ST77xxs_240x320:
x = 240;
y = 320;
break;
case ST77xx_type_e::ST77xxs_240x280:
x = 240;
y = 280;
break;
# endif // if P116_EXTRA_ST7735
case ST77xx_type_e::ST7796s_320x480:
x = 320;
@@ -201,6 +211,20 @@ bool P116_data_struct::plugin_init(struct EventStruct *event) {
initRoptions = INITR_BLACKTAB170x320; // 170x320px
}
// fall through
case ST77xx_type_e::ST77xxs_240x320:
if (initRoptions == 0xFF) {
initRoptions = INITR_BLACKTAB240x320; // 240x320px
}
// fall through
case ST77xx_type_e::ST77xxs_240x280:
if (initRoptions == 0xFF) {
initRoptions = INITR_BLACKTAB240x280; // 240x280px
}
// fall through
# endif // if P116_EXTRA_ST7735
case ST77xx_type_e::ST7735s_80x160:
+2
View File
@@ -103,6 +103,8 @@ enum class ST77xx_type_e : uint8_t {
ST7735s_135x240 = 12u,
ST7735s_172x320 = 13u,
ST77xxs_170x320 = 14u,
ST77xxs_240x320 = 15u,
ST77xxs_240x280 = 16u,
# endif // if P116_EXTRA_ST7735
};