You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
765 B
C++
39 lines
765 B
C++
4 years ago
|
#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;
|
||
|
}
|