From f48a366b5a8b06363e15e8ba56384197e4701524 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 22:37:41 +0000 Subject: [PATCH 1/2] feat: Add support for Cheap Yellow Display This change introduces a new build environment for the Cheap Yellow Display, which lacks PSRAM. The display logic has been updated to support boards with and without PSRAM by using conditional compilation. A new 4MB partition table has also been added. --- default_4MB.csv | 7 ++++++ platformio.ini | 32 +++++++++++++++++++++++-- src/Display.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 default_4MB.csv diff --git a/default_4MB.csv b/default_4MB.csv new file mode 100644 index 0000000..960469b --- /dev/null +++ b/default_4MB.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x140000, +app1, app, ota_1, 0x150000,0x140000, +spiffs, data, spiffs, 0x290000,0x160000, +coredump, data, coredump,0x3F0000,0x10000, diff --git a/platformio.ini b/platformio.ini index 5ffd4e0..9022809 100644 --- a/platformio.ini +++ b/platformio.ini @@ -46,7 +46,7 @@ board_upload.flash_size = 16MB board_build.partitions = default_16MB.csv build_flags = ${common_build_flags.build_flags} - -DBOARD_HAS_PSRAM + -DBOARD_HAS_PSRAM ; -DUSE_DMA -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1 @@ -81,4 +81,32 @@ build_flags = -DSYS_EN=GPIO_NUM_41 -DSYS_OUT=GPIO_NUM_40 ; Battery monitor - -DBATTERY_VOLTAGE_PIN=GPIO_NUM_1 \ No newline at end of file + -DBATTERY_VOLTAGE_PIN=GPIO_NUM_1 + +[env:cheap_yellow_display] +extends = common +board = esp32dev +board_build.flash_mode = qio +board_upload.flash_size = 4MB +board_build.partitions = default_4MB.csv +build_flags = + ${common_build_flags.build_flags} + -DCHEAP_YELLOW_DISPLAY + ; TFT_eSPI setup + -DUSER_SETUP_LOADED=1 + -DILI9341_DRIVER=1 + -DTFT_WIDTH=240 + -DTFT_HEIGHT=320 + -DTFT_MOSI=13 + -DTFT_SCLK=14 + -DTFT_CS=15 + -DTFT_DC=2 + -DTFT_RST=-1 + -DTFT_BL=21 + -DSPI_FREQUENCY=40000000 + ; SD card + -DUSE_SDCARD + -DSD_CARD_MISO=19 + -DSD_CARD_MOSI=23 + -DSD_CARD_CLK=18 + -DSD_CARD_CS=5 diff --git a/src/Display.cpp b/src/Display.cpp index 74bdd60..60f013d 100644 --- a/src/Display.cpp +++ b/src/Display.cpp @@ -13,13 +13,19 @@ Display::Display(Prefs *prefs) : tft(new TFT_eSPI()), _prefs(prefs) // First, initialize the TFT itself and set the rotation tft->init(); +#ifdef CHEAP_YELLOW_DISPLAY + tft->setRotation(1); +#else tft->setRotation(3); +#endif +#ifdef BOARD_HAS_PSRAM // Now create the sprite with the correct, rotated dimensions frameSprite = new TFT_eSprite(tft); frameSprite->createSprite(tft->width(), tft->height()); frameSprite->setTextFont(2); frameSprite->setTextSize(2); +#endif // setup the backlight #ifdef TFT_BL @@ -71,22 +77,34 @@ void Display::drawPixels(int x, int y, int width, int height, uint16_t *pixels) // new function to draw to our framebuffer sprite void Display::drawPixelsToSprite(int x, int y, int width, int height, uint16_t *pixels) { +#ifdef BOARD_HAS_PSRAM frameSprite->pushImage(x, y, width, height, pixels); +#else + drawPixels(x, y, width, height, pixels); +#endif } // new function to push the framebuffer to the screen void Display::flushSprite() { +#ifdef BOARD_HAS_PSRAM xSemaphoreTakeRecursive(tft_mutex, portMAX_DELAY); frameSprite->pushSprite(0, 0); xSemaphoreGiveRecursive(tft_mutex); +#endif } void Display::fillSprite(uint16_t color) { +#ifdef BOARD_HAS_PSRAM xSemaphoreTakeRecursive(tft_mutex, portMAX_DELAY); frameSprite->fillSprite(color); xSemaphoreGiveRecursive(tft_mutex); +#else + xSemaphoreTakeRecursive(tft_mutex, portMAX_DELAY); + tft->fillScreen(color); + xSemaphoreGiveRecursive(tft_mutex); +#endif } int Display::width() @@ -107,9 +125,15 @@ int Display::height() void Display::fillScreen(uint16_t color) { +#ifdef BOARD_HAS_PSRAM xSemaphoreTakeRecursive(tft_mutex, portMAX_DELAY); frameSprite->fillScreen(color); xSemaphoreGiveRecursive(tft_mutex); +#else + xSemaphoreTakeRecursive(tft_mutex, portMAX_DELAY); + tft->fillScreen(color); + xSemaphoreGiveRecursive(tft_mutex); +#endif } void Display::drawOSD(const char *text, OSDPosition position, OSDLevel level) @@ -118,6 +142,7 @@ void Display::drawOSD(const char *text, OSDPosition position, OSDLevel level) { return; } +#ifdef BOARD_HAS_PSRAM // draw OSD text into the sprite, with a black background for readability frameSprite->setTextColor(TFT_ORANGE, TFT_BLACK); @@ -151,6 +176,43 @@ void Display::drawOSD(const char *text, OSDPosition position, OSDLevel level) } frameSprite->setCursor(x, y); frameSprite->println(text); +#else + // no sprite, draw directly to the screen + xSemaphoreTakeRecursive(tft_mutex, portMAX_DELAY); + tft->setTextColor(TFT_ORANGE, TFT_BLACK); + + int textWidth = tft->textWidth(text); + int textHeight = tft->fontHeight(); + int x = 0; + int y = 0; + + switch (position) + { + case TOP_LEFT: + x = 20; + y = 20; + break; + case TOP_RIGHT: + x = width() - textWidth - 20; + y = 20; + break; + case BOTTOM_LEFT: + x = 20; + y = height() - textHeight - 20; + break; + case BOTTOM_RIGHT: + x = width() - textWidth - 20; + y = height() - textHeight - 20; + break; + case CENTER: + x = (width() - textWidth) / 2; + y = (height() - textHeight) / 2; + break; + } + tft->setCursor(x, y); + tft->println(text); + xSemaphoreGiveRecursive(tft_mutex); +#endif } From 4765919fb63025bfdd084746d5ba712c27f8ede9 Mon Sep 17 00:00:00 2001 From: t0mg Date: Wed, 19 Nov 2025 00:52:52 +0100 Subject: [PATCH 2/2] update some pins --- platformio.ini | 29 +++++++++++++++++++++++------ src/Display.cpp | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9022809..fd505cb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -28,6 +28,7 @@ board_build.embed_txtfiles = src/www/index.html src/www/app.js src/www/vcr.ttf +extra_scripts = pre:extra_script.py [common_build_flags] build_flags = @@ -39,7 +40,6 @@ build_flags = extends = common board = esp32-s3-devkitc-1 board_build.arduino.memory_type = qio_opi -extra_scripts = pre:extra_script.py board_build.flash_mode = qio board_build.psram_type = opi board_upload.flash_size = 16MB @@ -93,20 +93,37 @@ build_flags = ${common_build_flags.build_flags} -DCHEAP_YELLOW_DISPLAY ; TFT_eSPI setup + ; -DTFT_INVERSION_OFF + ; -DUSE_HSPI_PORT + ; -DTFT_RGB_ORDER=TFT_BGR -DUSER_SETUP_LOADED=1 -DILI9341_DRIVER=1 -DTFT_WIDTH=240 -DTFT_HEIGHT=320 + -DTFT_MISO=12 -DTFT_MOSI=13 -DTFT_SCLK=14 -DTFT_CS=15 -DTFT_DC=2 -DTFT_RST=-1 - -DTFT_BL=21 + -DTFT_BL=27 + -DTFT_BACKLIGHT_ON=HIGH + -DTFT_BACKLIGHT_OFF=LOW + -DTOUCH_CS=-1 + -DLOAD_GLCD=1 + -DLOAD_FONT2=1 + -DLOAD_FONT4=1 -DSPI_FREQUENCY=40000000 + -DSPI_READ_FREQUENCY=20000000 + -DSPI_TOUCH_FREQUENCY=2500000 ; SD card -DUSE_SDCARD - -DSD_CARD_MISO=19 - -DSD_CARD_MOSI=23 - -DSD_CARD_CLK=18 - -DSD_CARD_CS=5 + -DSD_CARD_MISO=GPIO_NUM_19 + -DSD_CARD_MOSI=GPIO_NUM_23 + -DSD_CARD_CLK=GPIO_NUM_18 + -DSD_CARD_CS=GPIO_NUM_5 + ; Button + -DSYS_EN=GPIO_NUM_1 + -DSYS_OUT=GPIO_NUM_4 + ; Battery monitor + -DBATTERY_VOLTAGE_PIN=GPIO_NUM_34 \ No newline at end of file diff --git a/src/Display.cpp b/src/Display.cpp index 60f013d..70dd255 100644 --- a/src/Display.cpp +++ b/src/Display.cpp @@ -14,7 +14,7 @@ Display::Display(Prefs *prefs) : tft(new TFT_eSPI()), _prefs(prefs) // First, initialize the TFT itself and set the rotation tft->init(); #ifdef CHEAP_YELLOW_DISPLAY - tft->setRotation(1); + tft->setRotation(2); #else tft->setRotation(3); #endif