From 52b60fd6a68f42ea07ccfb876cec86b09f20a61c Mon Sep 17 00:00:00 2001 From: Xander X Date: Fri, 4 Jun 2021 10:39:31 +0200 Subject: [PATCH] Added elekstube env to examples in platformio.ini Added support for raw 16bpp RGB565 images. Upload /0.bin etc. See https://github.com/neptune2/EleksTube-IPS-Retro-Nixie-Digits for how to get the original digits. --- platformio.ini | 1 + usermods/EleksTube_IPS/TFTs.h | 39 +++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index d5c936f18..ea088c444 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,6 +15,7 @@ default_envs = nodemcuv2, esp01_1m_full, esp32dev, esp32_eth # Single binaries (uncomment your board) +; default_envs = elekstube_ips ; default_envs = nodemcuv2 ; default_envs = esp01_1m_full ; default_envs = esp07 diff --git a/usermods/EleksTube_IPS/TFTs.h b/usermods/EleksTube_IPS/TFTs.h index ca2f4243f..160dc763c 100644 --- a/usermods/EleksTube_IPS/TFTs.h +++ b/usermods/EleksTube_IPS/TFTs.h @@ -33,6 +33,7 @@ private: } uint16_t output_buffer[TFT_HEIGHT][TFT_WIDTH]; + // These BMP functions are stolen directly from the TFT_SPIFFS_BMP example in the TFT_eSPI library. // Unfortunately, they aren't part of the library itself, so I had to copy them. @@ -40,6 +41,34 @@ private: //// BEGIN STOLEN CODE + bool drawBin(const char *filename) { + fs::File bmpFS; + + + // Open requested file on SD card + bmpFS = WLED_FS.open(filename, "r"); + + if (!bmpFS) + { + Serial.print(F("File not found: ")); + Serial.println(filename); + return(false); + } + + bool oldSwapBytes = getSwapBytes(); + setSwapBytes(true); + + bmpFS.read((uint8_t *) output_buffer,64800); + + pushImage(0, 0, 135, 240, (uint16_t *)output_buffer); + + setSwapBytes(oldSwapBytes); + + bmpFS.close(); + + return(true); + } + bool drawBmp(const char *filename) { fs::File bmpFS; @@ -48,7 +77,8 @@ private: if (!bmpFS) { - Serial.println(F("File not found")); + Serial.print(F("File not found: ")); + Serial.println(filename); return(false); } @@ -148,7 +178,12 @@ public: // Filenames are no bigger than "255.bmp\0" char file_name[10]; sprintf(file_name, "/%d.bmp", digits[digit]); - drawBmp(file_name); + if (WLED_FS.exists(file_name)) { + drawBmp(file_name); + } else { + sprintf(file_name, "/%d.bin", digits[digit]); + drawBin(file_name); + } } }