Chop down tft-related loooong ifdefs chains (#10803)

* Chop down tft-related loooong ifdefs chains

* Fix accidental sweep-up of portduino into screen #ifdef refactor
This commit is contained in:
Jonathan Bennett
2026-06-29 21:23:25 -05:00
committed by GitHub
parent 8345c2b6a9
commit fd8ba4fa4e
34 changed files with 52 additions and 57 deletions

View File

@@ -511,8 +511,20 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
static_cast<SSD1306Spi *>(dispdev)->setHorizontalOffset(32);
LOG_INFO("SSD1306 init success");
}
#elif defined(ST7735_CS) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7789_CS) || \
defined(RAK14014) || defined(HX8357_CS) || defined(ILI9488_CS) || defined(ST7796_CS) || defined(HACKADAY_COMMUNICATOR)
#elif ARCH_PORTDUINO
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
if (portduino_config.displayPanel != no_screen) {
LOG_DEBUG("Make TFTDisplay!");
dispdev = new TFTDisplay(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
} else {
dispdev = new AutoOLEDWire(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
isAUTOOled = true;
}
}
#elif USE_TFTDISPLAY
LOG_DEBUG("Make TFTDisplay!");
dispdev = new TFTDisplay(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
#elif defined(USE_EINK) && !defined(USE_EINK_DYNAMICDISPLAY) && !defined(USE_EINK_PARALLELDISPLAY)
@@ -526,18 +538,6 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
#elif defined(USE_ST7567)
dispdev = new ST7567Wire(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
#elif ARCH_PORTDUINO
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
if (portduino_config.displayPanel != no_screen) {
LOG_DEBUG("Make TFTDisplay!");
dispdev = new TFTDisplay(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
} else {
dispdev = new AutoOLEDWire(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
isAUTOOled = true;
}
}
#else
dispdev = new AutoOLEDWire(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
@@ -847,8 +847,7 @@ void Screen::setup()
dispdev->mirrorScreen();
#else
if (!config.display.flip_screen) {
#if defined(ST7701_CS) || defined(ST7735_CS) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7789_CS) || \
defined(RAK14014) || defined(HX8357_CS) || defined(ILI9488_CS) || defined(ST7796_CS) || defined(HACKADAY_COMMUNICATOR)
#if USE_TFTDISPLAY && !ARCH_PORTDUINO
static_cast<TFTDisplay *>(dispdev)->flipScreenVertically();
#elif defined(USE_ST7789)
static_cast<ST7789Spi *>(dispdev)->flipScreenVertically();

View File

@@ -98,10 +98,7 @@
#define FONT_LARGE_LOCAL FONT_MEDIUM_LOCAL
#endif
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || defined(ILI9488_CS) || defined(ST7796_CS) || \
defined(USE_ST7796) || defined(HACKADAY_COMMUNICATOR)) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
#if (defined(USE_EINK) || defined(HAS_SPI_TFT)) && !defined(DISPLAY_FORCE_SMALL_FONTS)
// The screen is bigger so use bigger fonts
#define FONT_SMALL FONT_MEDIUM_LOCAL // Height: 19
#define FONT_MEDIUM FONT_LARGE_LOCAL // Height: 28

View File

@@ -39,9 +39,7 @@ enum class TFTColorRole : uint8_t {
Count
};
#if HAS_TFT || defined(ST7701_CS) || defined(ST7735_CS) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || \
defined(ST7789_CS) || defined(HX8357_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(ST7796_CS) || \
defined(USE_ST7796) || defined(HACKADAY_COMMUNICATOR)
#if HAS_TFT || defined(HAS_SPI_TFT)
#define GRAPHICS_TFT_COLORING_ENABLED 1
#else
#define GRAPHICS_TFT_COLORING_ENABLED 0

View File

@@ -97,10 +97,7 @@ void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16
#ifdef ARCH_ESP32
if (!Throttle::isWithinTimespanMs(storeForwardModule->lastHeartbeat,
(storeForwardModule->heartbeatInterval * 1200))) { // no heartbeat, overlap a bit
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || defined(ST7796_CS) || \
defined(HACKADAY_COMMUNICATOR) || defined(USE_ST7796) || ARCH_PORTDUINO) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
#if (defined(USE_EINK) || defined(HAS_SPI_TFT) || ARCH_PORTDUINO) && !defined(DISPLAY_FORCE_SMALL_FONTS)
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 3 + FONT_HEIGHT_SMALL, 12,
8, imgQuestionL1);
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 11 + FONT_HEIGHT_SMALL, 12,
@@ -110,10 +107,7 @@ void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16
8, imgQuestion);
#endif
} else {
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || defined(ST7796_CS) || \
defined(HACKADAY_COMMUNICATOR) || defined(USE_ST7796)) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
#if (defined(USE_EINK) || defined(HAS_SPI_TFT)) && !defined(DISPLAY_FORCE_SMALL_FONTS)
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(screen->ourId), y + 3 + FONT_HEIGHT_SMALL, 16,
8, imgSFL1);
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(screen->ourId), y + 11 + FONT_HEIGHT_SMALL, 16,
@@ -126,10 +120,7 @@ void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16
#endif
} else {
// TODO: Raspberry Pi supports more than just the one screen size
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || defined(ST7796_CS) || \
defined(HACKADAY_COMMUNICATOR) || defined(USE_ST7796) || ARCH_PORTDUINO) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
#if (defined(USE_EINK) || defined(HAS_SPI_TFT) || ARCH_PORTDUINO) && !defined(DISPLAY_FORCE_SMALL_FONTS)
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8,
imgInfoL1);
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8,

View File

@@ -717,10 +717,7 @@ void UIRenderer::drawNodes(OLEDDisplay *display, int16_t x, int16_t y, const mes
snprintf(usersString, sizeof(usersString), "%d/%d %s", nodes_online, nodes_total, additional_words);
}
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || defined(ST7796_CS) || \
defined(HACKADAY_COMMUNICATOR) || defined(USE_ST7796)) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
#if (defined(USE_EINK) || defined(HAS_SPI_TFT)) && !defined(DISPLAY_FORCE_SMALL_FONTS)
if (currentResolution == ScreenResolution::High) {
NodeListRenderer::drawScaledXBitmap16x16(x, y - 1, 8, 8, imgUser, display);

View File

@@ -26,10 +26,7 @@ const uint8_t bluetoothConnectedIcon[36] PROGMEM = {0xfe, 0x01, 0xff, 0x03, 0x03
0xf3, 0x3f, 0x33, 0x30, 0x33, 0x33, 0x33, 0x33, 0x03, 0x33, 0xff, 0x33,
0xfe, 0x31, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0x3f, 0xe0, 0x1f};
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || defined(ILI9488_CS) || defined(ST7796_CS) || \
defined(USE_ST7796) || defined(HACKADAY_COMMUNICATOR) || ARCH_PORTDUINO) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
#if (defined(USE_EINK) || defined(HAS_SPI_TFT) || ARCH_PORTDUINO) && !defined(DISPLAY_FORCE_SMALL_FONTS)
const uint8_t imgQuestionL1[] PROGMEM = {0xff, 0x01, 0x01, 0x32, 0x7b, 0x49, 0x49, 0x6f, 0x26, 0x01, 0x01, 0xff};
const uint8_t imgQuestionL2[] PROGMEM = {0x0f, 0x08, 0x08, 0x08, 0x06, 0x0f, 0x0f, 0x06, 0x08, 0x08, 0x08, 0x0f};
const uint8_t imgInfoL1[] PROGMEM = {0xff, 0x01, 0x01, 0x01, 0x1e, 0x7f, 0x1e, 0x01, 0x01, 0x01, 0x01, 0xff};

View File

@@ -924,9 +924,7 @@ void setup()
#if HAS_SCREEN
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
#if defined(ST7701_CS) || defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || \
defined(ST7789_CS) || defined(HX8357_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(ST7796_CS) || \
defined(USE_SPISSD1306) || defined(USE_ST7796) || defined(HACKADAY_COMMUNICATOR)
#if defined(HAS_SPI_TFT) || defined(USE_EINK) || defined(USE_SPISSD1306)
screen = new graphics::Screen(screen_found, screen_model, screen_geometry);
#elif defined(ARCH_PORTDUINO)
if ((screen_found.port != ScanI2C::I2CPort::NO_I2C || portduino_config.displayPanel) &&
@@ -1056,9 +1054,7 @@ void setup()
#if !MESHTASTIC_EXCLUDE_I2C
// Don't call screen setup until after nodedb is setup (because we need
// the current region name)
#if defined(ST7701_CS) || defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || \
defined(ST7789_CS) || defined(HX8357_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(ST7796_CS) || \
defined(USE_ST7796) || defined(USE_SPISSD1306) || defined(HACKADAY_COMMUNICATOR)
#if defined(HAS_SPI_TFT) || defined(USE_EINK) || defined(USE_SPISSD1306)
if (screen)
screen->setup();
#elif defined(ARCH_PORTDUINO)

View File

@@ -1035,9 +1035,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
config.bluetooth.fixed_pin = defaultBLEPin;
#if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7789_CS) || \
defined(HX8357_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(ST7796_CS) || defined(USE_SPISSD1306) || \
defined(USE_ST7796) || defined(HACKADAY_COMMUNICATOR)
#if defined(USE_EINK) || defined(HAS_SPI_TFT) || defined(USE_SPISSD1306)
bool hasScreen = true;
#ifdef HELTEC_MESH_NODE_T114
uint32_t st7789_id = get_st7789_id(ST7789_NSS, ST7789_SCK, ST7789_SDA, ST7789_RS, ST7789_RESET);

View File

@@ -43,6 +43,7 @@
#define HAS_SCREEN 1 // Assume no screen present by default to prevent crash...
// ST7735S TFT LCD
#define HAS_SPI_TFT 1
#define ST7735S 1 // there are different (sub-)versions of ST7735
#define ST7735_CS -1
#define ST7735_RS 33 // DC

View File

@@ -34,6 +34,7 @@
#define GPS_RX_PIN 16
#define GPS_TX_PIN 17
#define HAS_SPI_TFT 1
#define ILI9341_DRIVER
#define TFT_HEIGHT 240
#define TFT_WIDTH 320

View File

@@ -52,6 +52,7 @@
#undef LED_STATE_ON
#undef LED_POWER
#define HAS_SPI_TFT 1
#define HAS_CST226SE 1
#define HAS_TOUCHSCREEN 1
// #define TOUCH_IRQ 35 // broken in this version of the lib 0.3.1

View File

@@ -29,6 +29,7 @@
#define HAS_SCREEN 0
// Default SPI1 will be mapped to the display
#define HAS_SPI_TFT 1
#define ST7789_SDA 23
#define ST7789_SCK 18
#define ST7789_CS 5

View File

@@ -42,12 +42,11 @@ void c6l_init();
#define SX126X_DIO3_TCXO_VOLTAGE 3.0
#define USE_SPISSD1306
#ifdef USE_SPISSD1306
#define DISPLAY_FORCE_SMALL_FONTS
#define SSD1306_NSS 6 // CS
#define SSD1306_RS 18 // DC
#define SSD1306_RESET 15
// #define OLED_DG 1
#endif
// Tiny OLED panel — opts into compile-time layout/font/feature substitutions
// gated on OLED_TINY across the graphics stack.
#define OLED_TINY

View File

@@ -11,6 +11,7 @@
#define TFT_BLACK 0
#define BRIGHTNESS_DEFAULT 130 // Medium Low Brightness
#define USE_TFTDISPLAY 1
#define HAS_SPI_TFT 1
#define USE_POWERSAVE
#define SLEEP_TIME 120

View File

@@ -78,6 +78,7 @@
#define LORA_KCT8103L_PA_CTX 5 // CTX - Switch between Receive LNA Mode and Receive Bypass Mode. (HIGH=RX bypass, LOW=RX LNA)
#if HAS_TFT
#define HAS_SPI_TFT 1
#define USE_TFTDISPLAY 1
#endif
/*

View File

@@ -53,6 +53,7 @@
#define LORA_KCT8103L_PA_CTX 5 // CTX - Switch between Receive LNA Mode and Receive Bypass Mode. (HIGH=RX bypass, LOW=RX LNA)
#if HAS_TFT
#define HAS_SPI_TFT 1
#define USE_TFTDISPLAY 1
#endif
/*

View File

@@ -8,6 +8,7 @@
#define I2C_SCL SCL
// Display (TFT)
#define HAS_SPI_TFT 1
#define USE_ST7789
#define ST7789_NSS 39
#define ST7789_RS 47 // DC

View File

@@ -8,6 +8,7 @@
#define I2C_SCL SCL
// ST7735S TFT LCD
#define HAS_SPI_TFT 1
#define ST7735S 1 // there are different (sub-)versions of ST7735
#define ST7735_CS 38
#define ST7735_RS 40 // DC

View File

@@ -7,6 +7,7 @@
#define I2C_SCL SCL
// ST7735S TFT LCD
#define HAS_SPI_TFT 1
#define ST7735S 1 // there are different (sub-)versions of ST7735
#define ST7735_CS 38
#define ST7735_RS 40 // DC

View File

@@ -7,6 +7,7 @@
#define I2C_SCL SCL
// ST7735S TFT LCD
#define HAS_SPI_TFT 1
#define ST7735S 1 // there are different (sub-)versions of ST7735
#define ST7735_CS 38
#define ST7735_RS 40 // DC

View File

@@ -1,5 +1,5 @@
#define USE_ST7789
#define HAS_SPI_TFT 1
#define ST7789_NSS 37
#define ST7789_RS 34 // DC
#define ST7789_SDA 35 // MOSI

View File

@@ -27,6 +27,7 @@
#define LORA_DIO2 RADIOLIB_NC
// Default SPI1 will be mapped to the display
#define HAS_SPI_TFT 1
#define ST7789_SDA 4
#define ST7789_SCK 3
#define ST7789_CS 6

View File

@@ -18,6 +18,7 @@
// #define ADC_MULTIPLIER 2
// ST7701 TFT LCD
#define HAS_SPI_TFT 1
#define ST7701_CS (4 | IO_EXPANDER)
#define ST7701_RS -1 // DC
#define ST7701_SDA 48 // MOSI

View File

@@ -2,6 +2,7 @@
#define TFT_CS 12
// ST7789 TFT LCD
#define HAS_SPI_TFT 1
#define ST7789_CS TFT_CS
#define ST7789_RS 11 // DC
#define ST7789_SDA 41 // MOSI

View File

@@ -1,4 +1,5 @@
// ST7789 TFT LCD
#define HAS_SPI_TFT 1
#define ST7789_CS 12
#define ST7789_RS 38 // DC
#define ST7789_SDA 13 // MOSI

View File

@@ -1,5 +1,6 @@
// ST7796 TFT LCD
#define TFT_CS 38
#define HAS_SPI_TFT 1
#define ST7796_CS TFT_CS
#define ST7796_RS 37 // DC
#define ST7796_SDA MOSI // MOSI

View File

@@ -9,6 +9,7 @@
#define I2C_SCL SCL
// ST7735S TFT LCD
#define HAS_SPI_TFT 1
#define ST7735S 1 // there are different (sub-)versions of ST7735
#define ST7735_CS 38
#define ST7735_RS 40 // DC

View File

@@ -11,6 +11,7 @@
// #define USE_SSD1306
// Default SPI1 will be mapped to the display
#define HAS_SPI_TFT 1
#define ST7789_SDA 42
#define ST7789_SCK 41
#define ST7789_CS 38

View File

@@ -18,6 +18,7 @@
#define LORA_DIO2 RADIOLIB_NC // Not really used
// HX8357 TFT LCD
#define HAS_SPI_TFT 1
#define HX8357_CS 48
#define HX8357_RS 47 // AKA DC
#define HX8357_RESET 46

View File

@@ -37,6 +37,7 @@ extern "C" {
#define VEXT_ON_VALUE HIGH
// ST7735S TFT LCD
#define HAS_SPI_TFT 1
#define ST7735_CS (0 + 22)
#define ST7735_RS (0 + 15) // DC
#define ST7735_SDA (0 + 17) // MOSI

View File

@@ -31,7 +31,7 @@ extern "C" {
#define HELTEC_MESH_NODE_T1
// Display (ST7735, 80x160 TFT via SPI1)
#define HAS_SPI_TFT 1
#define ST7735_CS (0 + 12)
#define ST7735_RS (0 + 22) // DC
#define ST7735_SDA (0 + 24)

View File

@@ -36,7 +36,7 @@ extern "C" {
#define HELTEC_MESH_NODE_T114
#define USE_ST7789
#define HAS_SPI_TFT 1
#define ST7789_NSS 11
#define ST7789_RS 12 // DC
#define ST7789_SDA 41 // MOSI

View File

@@ -107,6 +107,7 @@ extends = heltec_mesh_solar_base
build_flags = ${heltec_mesh_solar_base.build_flags}
-DHELTEC_MESH_SOLAR_TFT
-DSPI_INTERFACES_COUNT=2
-DHAS_SPI_TFT=1
-DUSE_ST7789
-DST7789_NSS=41
-DST7789_RS=13

View File

@@ -276,6 +276,8 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
#define RAK14014 // Tell it we have a RAK14014
#define USER_SETUP_LOADED 1
#define HAS_SPI_TFT 1
#define ST7789_DRIVER 1
#define TFT_WIDTH 240
#define TFT_HEIGHT 320