@@ -324,7 +324,7 @@ static int8_t prevFrame = -1;
324324// Combined dynamic node list frame cycling through LastHeard, HopSignal, and Distance modes
325325// Uses a single frame and changes data every few seconds (E-Ink variant is separate)
326326
327- #if defined(ESP_PLATFORM) && defined(USE_ST7789)
327+ #if defined(ESP_PLATFORM) && ( defined(USE_ST7789) || defined(USE_ST7796) )
328328SPIClass SPI1 (HSPI);
329329#endif
330330
@@ -356,7 +356,18 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
356356#else
357357 dispdev = new ST7789Spi (&SPI1, ST7789_RESET, ST7789_RS, ST7789_NSS, GEOMETRY_RAWMODE, TFT_WIDTH, TFT_HEIGHT);
358358#endif
359+ #elif defined(USE_ST7796)
360+ #ifdef ESP_PLATFORM
361+ dispdev = new ST7796Spi (&SPI1, ST7796_RESET, ST7796_RS, ST7796_NSS, GEOMETRY_RAWMODE, TFT_WIDTH, TFT_HEIGHT, ST7796_SDA,
362+ ST7796_MISO, ST7796_SCK, TFT_SPI_FREQUENCY);
363+ #else
364+ dispdev = new ST7796Spi (&SPI1, ST7796_RESET, ST7796_RS, ST7796_NSS, GEOMETRY_RAWMODE, TFT_WIDTH, TFT_HEIGHT);
365+ #endif
366+ #if defined(USE_ST7789)
359367 static_cast <ST7789Spi *>(dispdev)->setRGB (TFT_MESH);
368+ #elif defined(USE_ST7796)
369+ static_cast <ST7796Spi *>(dispdev)->setRGB (TFT_MESH);
370+ #endif
360371#elif defined(USE_SSD1306)
361372 dispdev = new SSD1306Wire (address.address , -1 , -1 , geometry,
362373 (address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
@@ -474,6 +485,15 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
474485 pinMode (VTFT_LEDA, OUTPUT);
475486 digitalWrite (VTFT_LEDA, TFT_BACKLIGHT_ON);
476487#endif
488+ #endif
489+ #ifdef USE_ST7796
490+ ui->init ();
491+ #ifdef ESP_PLATFORM
492+ analogWrite (VTFT_LEDA, BRIGHTNESS_DEFAULT);
493+ #else
494+ pinMode (VTFT_LEDA, OUTPUT);
495+ digitalWrite (VTFT_LEDA, TFT_BACKLIGHT_ON);
496+ #endif
477497#endif
478498 enabled = true ;
479499 setInterval (0 ); // Draw ASAP
@@ -512,6 +532,21 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
512532 nrf_gpio_cfg_default (ST7789_NSS);
513533#endif
514534#endif
535+ #ifdef USE_ST7796
536+ SPI1.end ();
537+ #if defined(ARCH_ESP32)
538+ pinMode (VTFT_LEDA, OUTPUT);
539+ digitalWrite (VTFT_LEDA, LOW);
540+ pinMode (ST7796_RESET, ANALOG);
541+ pinMode (ST7796_RS, ANALOG);
542+ pinMode (ST7796_NSS, ANALOG);
543+ #else
544+ nrf_gpio_cfg_default (VTFT_LEDA);
545+ nrf_gpio_cfg_default (ST7796_RESET);
546+ nrf_gpio_cfg_default (ST7796_RS);
547+ nrf_gpio_cfg_default (ST7796_NSS);
548+ #endif
549+ #endif
515550
516551#ifdef T_WATCH_S3
517552 PMU->disablePowerOutput (XPOWERS_ALDO2);
@@ -557,6 +592,10 @@ void Screen::setup()
557592#if defined(MUZI_BASE)
558593 dispdev->delayPoweron = true ;
559594#endif
595+ #if defined(USE_ST7796) && defined(TFT_MESH)
596+ // Custom text color, if defined in variant.h
597+ static_cast <ST7796Spi *>(dispdev)->setRGB (TFT_MESH);
598+ #endif
560599
561600 // === Initialize display and UI system ===
562601 ui->init ();
@@ -620,6 +659,8 @@ void Screen::setup()
620659 static_cast <TFTDisplay *>(dispdev)->flipScreenVertically ();
621660#elif defined(USE_ST7789)
622661 static_cast <ST7789Spi *>(dispdev)->flipScreenVertically ();
662+ #elif defined(USE_ST7796)
663+ static_cast <ST7796Spi *>(dispdev)->mirrorScreen ();
623664#elif !defined(M5STACK_UNITC6L)
624665 dispdev->flipScreenVertically ();
625666#endif
@@ -652,7 +693,7 @@ void Screen::setup()
652693 touchScreenImpl1->init ();
653694 }
654695 }
655- #elif HAS_TOUCHSCREEN && !defined(USE_EINK)
696+ #elif HAS_TOUCHSCREEN && !defined(USE_EINK) && !HAS_CST226SE
656697 touchScreenImpl1 =
657698 new TouchScreenImpl1 (dispdev->getWidth (), dispdev->getHeight (), static_cast <TFTDisplay *>(dispdev)->getTouch );
658699 touchScreenImpl1->init ();
0 commit comments