Skip to content

Commit 5e5554b

Browse files
committed
use more explicit and less conflicting functions and variable names
1 parent ce44827 commit 5e5554b

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

usermods/pov_display/usermod_pov_display.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
#include "wled.h"
33
#include <PNGdec.h>
44

5-
PNG png;
6-
File f;
5+
PNG png_decoder;
6+
File pov_image;
77
static const char _data_FX_MODE_POV_IMAGE[] PROGMEM = "POV Image@!;;;1";
88

9-
void * openFile(const char *filename, int32_t *size) {
10-
f = WLED_FS.open(filename);
11-
*size = f.size();
12-
return &f;
9+
void * PovOpenFile(const char *filename, int32_t *size) {
10+
pov_image = WLED_FS.open(filename);
11+
*size = pov_image.size();
12+
return &pov_image;
1313
}
1414

15-
void closeFile(void *handle) {
16-
if (f) f.close();
15+
void PovCloseFile(void *handle) {
16+
if (pov_image) pov_image.close();
1717
}
1818

19-
int32_t readFile(PNGFILE *pFile, uint8_t *pBuf, int32_t iLen)
19+
int32_t PovReadFile(PNGFILE *pFile, uint8_t *pBuf, int32_t iLen)
2020
{
2121
int32_t iBytesRead;
2222
iBytesRead = iLen;
@@ -31,7 +31,7 @@ int32_t readFile(PNGFILE *pFile, uint8_t *pBuf, int32_t iLen)
3131
return iBytesRead;
3232
}
3333

34-
int32_t seekFile(PNGFILE *pFile, int32_t iPosition)
34+
int32_t PovSeekFile(PNGFILE *pFile, int32_t iPosition)
3535
{
3636
int i = micros();
3737
File *f = static_cast<File *>(pFile->fHandle);
@@ -41,9 +41,9 @@ int32_t seekFile(PNGFILE *pFile, int32_t iPosition)
4141
return pFile->iPos;
4242
}
4343

44-
void draw(PNGDRAW *pDraw) {
44+
void PovDraw(PNGDRAW *pDraw) {
4545
uint16_t usPixels[SEGLEN];
46-
png.getLineAsRGB565(pDraw, usPixels, PNG_RGB565_LITTLE_ENDIAN, 0xffffffff);
46+
png_decoder.getLineAsRGB565(pDraw, usPixels, PNG_RGB565_LITTLE_ENDIAN, 0xffffffff);
4747
for(int x=0; x < SEGLEN; x++) {
4848
uint16_t color = usPixels[x];
4949
byte r = ((color >> 11) & 0x1F);
@@ -55,11 +55,12 @@ void draw(PNGDRAW *pDraw) {
5555
}
5656

5757
uint16_t mode_pov_image(void) {
58-
const char * filepath = SEGMENT.name;
59-
int rc = png.open(filepath, openFile, closeFile, readFile, seekFile, draw);
58+
char filepath[WLED_MAX_SEGNAME_LEN + 1] = "/";
59+
strncpy(filepath + 1, SEGMENT.name, WLED_MAX_SEGNAME_LEN);
60+
int rc = png_decoder.open(filepath, PovOpenFile, PovCloseFile, PovReadFile, PovSeekFile, PovDraw);
6061
if (rc == PNG_SUCCESS) {
61-
rc = png.decode(NULL, 0);
62-
png.close();
62+
rc = png_decoder.decode(NULL, 0);
63+
png_decoder.close();
6364
return FRAMETIME;
6465
}
6566
return FRAMETIME;

0 commit comments

Comments
 (0)