diff --git a/platformio.ini b/platformio.ini index d5c936f1..ea088c44 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 ca2f4243..160dc763 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); + } } }