fs improvements

pull/1/head
Thomas Ballmann 4 years ago
parent 09be1183cb
commit 7888f6432e

@ -47,6 +47,10 @@ void setupApp()
setupCurrentImage();
setupApiFace();
server.onNotFound([](AsyncWebServerRequest *request) {
request->send(404);
});
// TODO response
server.on("/stats", HTTP_GET, [](AsyncWebServerRequest *request) {
AsyncResponseStream *response = request->beginResponseStream("application/json");
@ -64,11 +68,10 @@ void setupApp()
doc["device"]["bootCycle"] = deviceGetBootCount();
doc["device"]["screen"]["width"] = 640;
doc["device"]["screen"]["height"] = 384;
SPIFFS.begin();
doc["device"]["fs"]["total"] = SPIFFS.totalBytes();
doc["device"]["fs"]["used"] = SPIFFS.usedBytes();
doc["device"]["fs"]["free"] = SPIFFS.totalBytes() - SPIFFS.usedBytes();
SPIFFS.end();
doc["playlist"]["current"] = PlaylistGetCurrentFace();
doc["playlist"]["remaining"] = PlaylistGetRemainingTimeMs() / 1000;
@ -268,7 +271,7 @@ void setupApiFace()
server.on("/api/face", HTTP_POST, [](AsyncWebServerRequest *request) {
Serial.println("post request");
/*
/*
int params = request->params();
for (int i = 0; i < params; i++)
{

@ -38,7 +38,6 @@ bool downloadFile(String url, const char *path)
WiFiClient *stream = http.getStreamPtr();
// persist image
SPIFFS.begin();
File file = SPIFFS.open(tmpFile, FILE_WRITE);
if (!file)
{
@ -78,8 +77,6 @@ bool downloadFile(String url, const char *path)
file.close();
SPIFFS.remove(path);
SPIFFS.rename(tmpFile, path);
SPIFFS.end();
}
Serial.print("download completed in: ");

@ -39,7 +39,7 @@ void showFaceCalendar()
display_picture();
display_calender();
display.nextPage();
displayFlush();
}
void downloadRandomePicture()
@ -133,8 +133,6 @@ void display_calender()
void display_picture()
{
SPIFFS.begin();
File file = SPIFFS.open(faceCalendarPicture, "r");
if (!file)
{
@ -152,8 +150,6 @@ void display_picture()
file.close();
ImageFlushBuffer();
SPIFFS.end();
}
void display_time()

Loading…
Cancel
Save