Merge pull request #2015 from RedNax67/master

Added support for raw 16bpp RGB565 images, and added elekstube env to examples in platformio.ini
This commit is contained in:
Christian Schwinne 2021-06-04 13:11:23 +02:00 committed by GitHub
commit 29c9e5cb17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 2 deletions

View File

@ -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

View File

@ -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);
}
}
}