Center smaller images

This commit is contained in:
cschwinne 2021-05-21 15:19:18 +02:00
parent 2d586406da
commit adf5c8c278
14 changed files with 10 additions and 8 deletions

View File

@ -39,10 +39,7 @@ private:
//// BEGIN STOLEN CODE //// BEGIN STOLEN CODE
bool drawBmp(const char *filename, int16_t x, int16_t y) { bool drawBmp(const char *filename) {
// Nothing to do.
if ((x >= width()) || (y >= height())) return(true);
fs::File bmpFS; fs::File bmpFS;
// Open requested file on SD card // Open requested file on SD card
@ -85,6 +82,9 @@ private:
return(false); return(false);
} }
//draw img that is shorter than 240pix into the center
int16_t y = (height() - h) /2;
bool oldSwapBytes = getSwapBytes(); bool oldSwapBytes = getSwapBytes();
setSwapBytes(true); setSwapBytes(true);
bmpFS.seek(seekOffset); bmpFS.seek(seekOffset);
@ -108,7 +108,7 @@ private:
} }
} }
pushImage(x, y, w, h, (uint16_t *)output_buffer); pushImage(0, y, w, h, (uint16_t *)output_buffer);
setSwapBytes(oldSwapBytes); setSwapBytes(oldSwapBytes);
bmpFS.close(); bmpFS.close();
@ -146,7 +146,7 @@ public:
// Filenames are no bigger than "255.bmp\0" // Filenames are no bigger than "255.bmp\0"
char file_name[10]; char file_name[10];
sprintf(file_name, "/%d.bmp", digits[digit]); sprintf(file_name, "/%d.bmp", digits[digit]);
drawBmp(file_name, 0, 0); drawBmp(file_name);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

@ -2,7 +2,7 @@
This usermod allows WLED to run on the EleksTube IPS clock. This usermod allows WLED to run on the EleksTube IPS clock.
It enables running all WLED effects on the background SK6812 lighting, while displaying digit bitmaps on the 6 IPS screens. It enables running all WLED effects on the background SK6812 lighting, while displaying digit bitmaps on the 6 IPS screens.
Code is largely based on https://github.com/SmittyHalibut/EleksTubeHAX by Mark Smith Code is largely based on https://github.com/SmittyHalibut/EleksTubeHAX by Mark Smith!
Supported: Supported:
- Display with custom bitmaps from filesystem - Display with custom bitmaps from filesystem

View File

@ -2,6 +2,8 @@
#include "TFTs.h" #include "TFTs.h"
#include "wled.h" #include "wled.h"
//Large parts of the code are from https://github.com/SmittyHalibut/EleksTubeHAX
class ElekstubeIPSUsermod : public Usermod { class ElekstubeIPSUsermod : public Usermod {
private: private:
TFTs tfts; TFTs tfts;

View File

@ -49,7 +49,7 @@
//#define DEFAULT_LED_TYPE TYPE_WS2812_RGB //#define DEFAULT_LED_TYPE TYPE_WS2812_RGB
#ifndef PIXEL_COUNTS #ifndef PIXEL_COUNTS
#define PIXEL_COUNTS 30 #define PIXEL_COUNTS DEFAULT_LED_COUNT
#endif #endif
#ifndef DATA_PINS #ifndef DATA_PINS