diff --git a/lib/imageService/imageService.cpp b/lib/imageService/imageService.cpp new file mode 100644 index 0000000..ff4a328 --- /dev/null +++ b/lib/imageService/imageService.cpp @@ -0,0 +1,39 @@ +#include +#include "imageService.h" +#include "settings.h" +#include "download.h" +#include "image.h" + +void imageServiceRenderFile(const char imageFile[], int x, int y, int w, int h, bool dithering) +{ + File file = SPIFFS.open(imageFile, "r"); + if (!file) + { + Serial.println(" file not found"); + } + + ImageNew(x, y, w, h, dithering); + + // TODO check why a small buffer is not working correct + uint8_t buff[1280] = {0}; + while (int c = file.read(buff, sizeof(buff))) + { + ImageWriteBuffer(buff, c); + } + file.close(); + + ImageFlushBuffer(); +} + +bool imageServiceUpdateFile(const char format[], const char target[]) +{ + String url = NVS.getString("playlist.images"); + + if (!url.isEmpty()) + { + url += format; + return downloadFile(url, target); + } + + return false; +} \ No newline at end of file diff --git a/lib/imageService/imageService.h b/lib/imageService/imageService.h new file mode 100644 index 0000000..d552d51 --- /dev/null +++ b/lib/imageService/imageService.h @@ -0,0 +1,7 @@ +#ifndef IMAGE_SERVICE_H +#define IMAGE_SERVICE_H + +void imageServiceRenderFile(const char imageFile[], int x, int y, int w, int h, bool dithering); +bool imageServiceUpdateFile(const char format[], const char target[]); + +#endif \ No newline at end of file