image service created
parent
26e12e5d56
commit
153b5d9811
@ -0,0 +1,39 @@
|
||||
#include <SPIFFS.h>
|
||||
#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;
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue