mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 03:04:25 +01:00
added äöüßÄÖÜ to fonts + small updates
- fonts re-rendered: added äöüßÄÖÜ. - shuffled a bit with fonts to optimize disk usage - ability to delete files during OTA - prettify tagDB.json - error handling in get_DB - small cosmetic changes * Due to new ability to delete files: After firmware update via OTA, please perform an OTA update of the filesystem again to perform the deletion of unneeded fonts. * If updating via platform.io: don't forget to update the filesystem image.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ESP32_AP-Flasher/data/fonts/calibrib100.vlw
Normal file
BIN
ESP32_AP-Flasher/data/fonts/calibrib100.vlw
Normal file
Binary file not shown.
BIN
ESP32_AP-Flasher/data/fonts/calibrib120.vlw
Normal file
BIN
ESP32_AP-Flasher/data/fonts/calibrib120.vlw
Normal file
Binary file not shown.
BIN
ESP32_AP-Flasher/data/fonts/calibrib150.vlw
Normal file
BIN
ESP32_AP-Flasher/data/fonts/calibrib150.vlw
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ESP32_AP-Flasher/data/fonts/calibrib60.vlw
Normal file
BIN
ESP32_AP-Flasher/data/fonts/calibrib60.vlw
Normal file
Binary file not shown.
Binary file not shown.
BIN
ESP32_AP-Flasher/data/fonts/calibrib80.vlw
Normal file
BIN
ESP32_AP-Flasher/data/fonts/calibrib80.vlw
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ESP32_AP-Flasher/data/fonts/twcondensed20.vlw
Normal file
BIN
ESP32_AP-Flasher/data/fonts/twcondensed20.vlw
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15
ESP32_AP-Flasher/data/update_actions.json
Normal file
15
ESP32_AP-Flasher/data/update_actions.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"deletefile": [
|
||||
"/fonts/calibrib62.vlw",
|
||||
"/fonts/GillSC16.vlw",
|
||||
"/fonts/GillSC20.vlw",
|
||||
"/fonts/numbers1-1.vlw",
|
||||
"/fonts/numbers1-2.vlw",
|
||||
"/fonts/numbers2-1.vlw",
|
||||
"/fonts/numbers2-2.vlw",
|
||||
"/fonts/numbers3-1.vlw",
|
||||
"/fonts/numbers3-2.vlw",
|
||||
"/fonts/tw20.vlw",
|
||||
"/fonts/twbold20.vlw"
|
||||
]
|
||||
}
|
||||
@@ -151,7 +151,7 @@ Latency will be around 40 seconds.">
|
||||
<div class="model"></div>
|
||||
|
||||
<div class="received">
|
||||
RSSI <div class="rssi"></div>, LQI <div class="lqi"></div>, <div class="temperature"></div>°C, <div class="batt"></div>V
|
||||
RSSI <div class="rssi"></div>, LQI <div class="lqi"></div><div class="temperature"></div><div class="batt"></div>
|
||||
</div>
|
||||
|
||||
<div class="contentmode"></div>
|
||||
|
||||
@@ -276,10 +276,7 @@ select {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
.received div {
|
||||
padding-left: 3px;
|
||||
padding-right: 1px;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.contentmode {
|
||||
|
||||
@@ -159,8 +159,12 @@ function processTags(tagArray) {
|
||||
$('#tag' + tagmac + ' .model').innerHTML = models[element.hwType];
|
||||
$('#tag' + tagmac + ' .rssi').innerHTML = element.RSSI;
|
||||
$('#tag' + tagmac + ' .lqi').innerHTML = element.LQI;
|
||||
$('#tag' + tagmac + ' .temperature').innerHTML = element.temperature;
|
||||
$('#tag' + tagmac + ' .batt').innerHTML = element.batteryMv / 1000;
|
||||
$('#tag' + tagmac + ' .temperature').innerHTML = (element.temperature > 0 ? ", " + element.temperature + "°C": "");
|
||||
if (element.batteryMv == 0 || element.batteryMv == 1337) {
|
||||
$('#tag' + tagmac + ' .batt').innerHTML = "";
|
||||
} else {
|
||||
$('#tag' + tagmac + ' .batt').innerHTML = ", " + (element.batteryMv >= 2600 ? "≥" : "") + (element.batteryMv / 1000) + "V";
|
||||
}
|
||||
$('#tag' + tagmac + ' .received').style.opacity = "1";
|
||||
} else {
|
||||
$('#tag' + tagmac + ' .model').innerHTML = "waiting for hardware type";
|
||||
|
||||
@@ -151,6 +151,23 @@ export async function updateWebpage(fileUrl, tagname, showReload) {
|
||||
consoleDiv.scrollTop = consoleDiv.scrollHeight;
|
||||
|
||||
print("Updating littleFS partition...");
|
||||
|
||||
try {
|
||||
const response = await fetch("/update_actions", {
|
||||
method: "POST",
|
||||
body: ''
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.text();
|
||||
} else {
|
||||
print(`error performing update actions: ${response.status}`, "red");
|
||||
errors++;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`error calling update actions:` + error, "red");
|
||||
errors++;
|
||||
}
|
||||
|
||||
fetch("/getexturl?url=" + fileUrl)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
|
||||
@@ -10,3 +10,4 @@ void handleUpdateOTA(AsyncWebServerRequest* request);
|
||||
void firmwareUpdateTask(void* parameter);
|
||||
void updateFirmware(const char* url, const char* expectedMd5, size_t size);
|
||||
void handleRollback(AsyncWebServerRequest* request);
|
||||
void handleUpdateActions(AsyncWebServerRequest* request);
|
||||
|
||||
@@ -30,15 +30,9 @@
|
||||
#include "web.h"
|
||||
#include "language.h"
|
||||
|
||||
#ifdef BOARD_HAS_PSRAM
|
||||
#define PAL_BLACK TFT_BLACK
|
||||
#define PAL_WHITE TFT_WHITE
|
||||
#define PAL_RED TFT_RED
|
||||
#else
|
||||
#define PAL_BLACK 0
|
||||
#define PAL_WHITE 9
|
||||
#define PAL_RED 2
|
||||
#endif
|
||||
|
||||
enum contentModes {
|
||||
Image,
|
||||
@@ -306,18 +300,8 @@ void drawString(TFT_eSprite &spr, String content, uint16_t posx, uint16_t posy,
|
||||
}
|
||||
|
||||
void initSprite(TFT_eSprite &spr, int w, int h) {
|
||||
#ifdef BOARD_HAS_PSRAM
|
||||
spr.setColorDepth(8);
|
||||
spr.createSprite(w, h);
|
||||
#else
|
||||
spr.setColorDepth(4); // 4 bits per pixel, uses indexed color
|
||||
spr.createSprite(w, h);
|
||||
uint16_t cmap[16];
|
||||
cmap[PAL_BLACK] = TFT_BLACK;
|
||||
cmap[PAL_RED] = TFT_RED;
|
||||
cmap[PAL_WHITE] = TFT_WHITE;
|
||||
spr.createPalette(cmap, 16);
|
||||
#endif
|
||||
if (spr.getPointer() == nullptr) {
|
||||
wsErr("Failed to create sprite");
|
||||
}
|
||||
@@ -346,22 +330,18 @@ void drawDate(String &filename, tagRecord *&taginfo, imgParam &imageParams) {
|
||||
|
||||
if (taginfo->hwType == SOLUM_29_SSD1619 || taginfo->hwType == SOLUM_29_UC8151) {
|
||||
initSprite(spr, 296, 128);
|
||||
if (getCurrentLanguage() == 0 && timeinfo.tm_wday == 3) {
|
||||
drawString(spr, languageDays[getCurrentLanguage()][timeinfo.tm_wday], 296 / 2, 10, "fonts/calibrib50", TC_DATUM, PAL_RED);
|
||||
} else {
|
||||
drawString(spr, languageDays[getCurrentLanguage()][timeinfo.tm_wday], 296 / 2, 10, "fonts/calibrib62", TC_DATUM, PAL_RED);
|
||||
}
|
||||
drawString(spr, languageDays[getCurrentLanguage()][timeinfo.tm_wday], 296 / 2, 10, "fonts/calibrib60", TC_DATUM, PAL_RED);
|
||||
drawString(spr, String(timeinfo.tm_mday) + " " + languageMonth[getCurrentLanguage()][timeinfo.tm_mon], 296 / 2, 73, "fonts/calibrib50", TC_DATUM);
|
||||
|
||||
} else if (taginfo->hwType == SOLUM_154_SSD1619) {
|
||||
initSprite(spr, 152, 152);
|
||||
drawString(spr, languageDays[getCurrentLanguage()][timeinfo.tm_wday], 152 / 2, 10, "fonts/calibrib30", TC_DATUM);
|
||||
drawString(spr, String(languageMonth[getCurrentLanguage()][timeinfo.tm_mon]), 152 / 2, 120, "fonts/calibrib30", TC_DATUM);
|
||||
drawString(spr, String(timeinfo.tm_mday), 152 / 2, 42, "fonts/numbers2-1", TC_DATUM, PAL_RED);
|
||||
drawString(spr, String(timeinfo.tm_mday), 152 / 2, 42, "fonts/calibrib100", TC_DATUM, PAL_RED);
|
||||
|
||||
} else if (taginfo->hwType == SOLUM_42_SSD1619) {
|
||||
initSprite(spr, 400, 300);
|
||||
drawString(spr, languageDays[getCurrentLanguage()][timeinfo.tm_wday], 400 / 2, 30, "fonts/calibrib62", TC_DATUM, PAL_RED);
|
||||
drawString(spr, languageDays[getCurrentLanguage()][timeinfo.tm_wday], 400 / 2, 30, "fonts/calibrib60", TC_DATUM, PAL_RED);
|
||||
drawString(spr, String(timeinfo.tm_mday) + " " + languageMonth[getCurrentLanguage()][timeinfo.tm_mon], 400 / 2, 113, "fonts/calibrib50", TC_DATUM);
|
||||
}
|
||||
|
||||
@@ -401,9 +381,10 @@ void drawNumber(String &filename, int32_t count, int32_t thresholdred, tagRecord
|
||||
} else {
|
||||
spr.setTextColor(PAL_BLACK, PAL_WHITE);
|
||||
}
|
||||
String font = "fonts/numbers1-2";
|
||||
if (count > 999) font = "fonts/numbers2-2";
|
||||
if (count > 9999) font = "fonts/numbers3-2";
|
||||
String font = "fonts/calibrib150";
|
||||
if (count > 99) font = "fonts/calibrib150";
|
||||
if (count > 999) font = "fonts/calibrib120";
|
||||
if (count > 9999) font = "fonts/calibrib100";
|
||||
spr.loadFont(font, LittleFS);
|
||||
spr.drawString(String(count), 296 / 2, 128 / 2 + 10);
|
||||
spr.unloadFont();
|
||||
@@ -416,9 +397,10 @@ void drawNumber(String &filename, int32_t count, int32_t thresholdred, tagRecord
|
||||
} else {
|
||||
spr.setTextColor(PAL_BLACK, PAL_WHITE);
|
||||
}
|
||||
String font = "fonts/numbers1-1";
|
||||
if (count > 99) font = "fonts/numbers2-1";
|
||||
if (count > 999) font = "fonts/numbers3-1";
|
||||
String font = "fonts/calibrib120";
|
||||
if (count > 99) font = "fonts/calibrib80";
|
||||
if (count > 999) font = "fonts/calibrib50";
|
||||
if (count > 9999) font = "fonts/calibrib50";
|
||||
spr.loadFont(font, LittleFS);
|
||||
spr.drawString(String(count), 152 / 2, 152 / 2 + 7);
|
||||
spr.unloadFont();
|
||||
@@ -431,9 +413,10 @@ void drawNumber(String &filename, int32_t count, int32_t thresholdred, tagRecord
|
||||
} else {
|
||||
spr.setTextColor(PAL_BLACK, PAL_WHITE);
|
||||
}
|
||||
String font = "fonts/numbers1-2";
|
||||
if (count > 999) font = "fonts/numbers2-2";
|
||||
if (count > 9999) font = "fonts/numbers3-2";
|
||||
String font = "fonts/calibrib150";
|
||||
if (count > 99) font = "fonts/calibrib150";
|
||||
if (count > 999) font = "fonts/calibrib120";
|
||||
if (count > 9999) font = "fonts/calibrib100";
|
||||
spr.loadFont(font, LittleFS);
|
||||
spr.drawString(String(count), 400 / 2, 300 / 2 + 7);
|
||||
spr.unloadFont();
|
||||
@@ -679,7 +662,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
|
||||
for (uint8_t dag = 0; dag < 5; dag++) {
|
||||
time_t weatherday = doc["daily"]["time"][dag].as<time_t>();
|
||||
struct tm *datum = localtime(&weatherday);
|
||||
drawString(spr, String(languageDaysShort[getCurrentLanguage()][datum->tm_wday]), dag * 59 + 30, 18, "fonts/twbold20", TC_DATUM, PAL_BLACK);
|
||||
drawString(spr, String(languageDaysShort[getCurrentLanguage()][datum->tm_wday]), dag * 59 + 30, 18, "fonts/twcondensed20", TC_DATUM, PAL_BLACK);
|
||||
|
||||
uint8_t weathercode = doc["daily"]["weathercode"][dag].as<int>();
|
||||
if (weathercode > 40) weathercode -= 40;
|
||||
@@ -703,7 +686,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
|
||||
int8_t tmax = round(doc["daily"]["temperature_2m_max"][dag].as<double>());
|
||||
uint8_t wind = windSpeedToBeaufort(doc["daily"]["windspeed_10m_max"][dag].as<double>());
|
||||
|
||||
spr.loadFont("fonts/GillSC20", LittleFS);
|
||||
spr.loadFont("fonts/twcondensed20", LittleFS);
|
||||
drawString(spr, String(tmin) + " ", dag * 59 + 30, 108, "", TR_DATUM, (tmin < 0 ? PAL_RED : PAL_BLACK));
|
||||
drawString(spr, String(" ") + String(tmax), dag * 59 + 30, 108, "", TL_DATUM, (tmax < 0 ? PAL_RED : PAL_BLACK));
|
||||
drawString(spr, String(" ") + String(wind), dag * 59 + 30, 43, "", TL_DATUM, (wind > 5 ? PAL_RED : PAL_BLACK));
|
||||
@@ -724,7 +707,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
|
||||
for (uint8_t dag = 0; dag < 5; dag++) {
|
||||
time_t weatherday = doc["daily"]["time"][dag].as<time_t>();
|
||||
struct tm *datum = localtime(&weatherday);
|
||||
drawString(spr, String(languageDaysShort[getCurrentLanguage()][datum->tm_wday]), dag * 59 + 30, 18, "fonts/twbold20", TC_DATUM, PAL_BLACK);
|
||||
drawString(spr, String(languageDaysShort[getCurrentLanguage()][datum->tm_wday]), dag * 59 + 30, 18, "fonts/twcondensed20", TC_DATUM, PAL_BLACK);
|
||||
|
||||
uint8_t weathercode = doc["daily"]["weathercode"][dag].as<int>();
|
||||
if (weathercode > 40) weathercode -= 40;
|
||||
@@ -748,7 +731,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
|
||||
int8_t tmax = round(doc["daily"]["temperature_2m_max"][dag].as<double>());
|
||||
uint8_t wind = windSpeedToBeaufort(doc["daily"]["windspeed_10m_max"][dag].as<double>());
|
||||
|
||||
spr.loadFont("fonts/GillSC20", LittleFS);
|
||||
spr.loadFont("fonts/twcondensed20", LittleFS);
|
||||
drawString(spr, String(tmin) + " ", dag * 59 + 30, 108, "", TR_DATUM, (tmin < 0 ? PAL_RED : PAL_BLACK));
|
||||
drawString(spr, String(" ") + String(tmax), dag * 59 + 30, 108, "", TL_DATUM, (tmax < 0 ? PAL_RED : PAL_BLACK));
|
||||
drawString(spr, String(" ") + String(wind), dag * 59 + 30, 43, "", TL_DATUM, (wind > 5 ? PAL_RED : PAL_BLACK));
|
||||
|
||||
@@ -39,12 +39,12 @@ void handleSysinfoRequest(AsyncWebServerRequest* request) {
|
||||
doc["rollback"] = Update.canRollBack();
|
||||
|
||||
size_t bufferSize = measureJson(doc) + 1;
|
||||
AsyncResponseStream *response = request->beginResponseStream("application/json", bufferSize);
|
||||
AsyncResponseStream* response = request->beginResponseStream("application/json", bufferSize);
|
||||
serializeJson(doc, *response);
|
||||
request->send(response);
|
||||
};
|
||||
|
||||
void handleCheckFile(AsyncWebServerRequest *request) {
|
||||
void handleCheckFile(AsyncWebServerRequest* request) {
|
||||
if (!request->hasParam("path")) {
|
||||
request->send(400);
|
||||
return;
|
||||
@@ -110,7 +110,7 @@ void handleGetExtUrl(AsyncWebServerRequest* request) {
|
||||
}
|
||||
}
|
||||
|
||||
void handleLittleFSUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
|
||||
void handleLittleFSUpload(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final) {
|
||||
bool error = false;
|
||||
if (!index) {
|
||||
String path;
|
||||
@@ -183,9 +183,9 @@ void updateFirmware(const char* url, const char* expectedMd5, size_t size) {
|
||||
|
||||
config.runStatus = RUNSTATUS_STOP;
|
||||
vTaskDelay(3000 / portTICK_PERIOD_MS);
|
||||
//xSemaphoreTake(tagDBOwner, portMAX_DELAY);
|
||||
// xSemaphoreTake(tagDBOwner, portMAX_DELAY);
|
||||
saveDB("/current/tagDB.json");
|
||||
//destroyDB();
|
||||
// destroyDB();
|
||||
|
||||
HTTPClient httpClient;
|
||||
|
||||
@@ -222,7 +222,7 @@ void updateFirmware(const char* url, const char* expectedMd5, size_t size) {
|
||||
wsSerial("Reboot system now");
|
||||
wsSerial("[reboot]");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
//ESP.restart();
|
||||
// ESP.restart();
|
||||
} else {
|
||||
wsSerial("Error updating firmware:");
|
||||
wsSerial(Update.errorString());
|
||||
@@ -241,9 +241,9 @@ void updateFirmware(const char* url, const char* expectedMd5, size_t size) {
|
||||
}
|
||||
|
||||
httpClient.end();
|
||||
//loadDB("/current/tagDB.json");
|
||||
// loadDB("/current/tagDB.json");
|
||||
config.runStatus = RUNSTATUS_RUN;
|
||||
//xSemaphoreGive(tagDBOwner);
|
||||
// xSemaphoreGive(tagDBOwner);
|
||||
}
|
||||
|
||||
void handleRollback(AsyncWebServerRequest* request) {
|
||||
@@ -255,7 +255,7 @@ void handleRollback(AsyncWebServerRequest* request) {
|
||||
wsSerial("Reboot system now");
|
||||
wsSerial("[reboot]");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
//ESP.restart();
|
||||
// ESP.restart();
|
||||
} else {
|
||||
wsSerial("Rollback failed");
|
||||
request->send(400, "Rollback failed");
|
||||
@@ -264,4 +264,26 @@ void handleRollback(AsyncWebServerRequest* request) {
|
||||
wsSerial("Rollback not allowed");
|
||||
request->send(400, "Rollback not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
void handleUpdateActions(AsyncWebServerRequest* request) {
|
||||
wsSerial("Performing cleanup");
|
||||
File file = LittleFS.open("/update_actions.json", "r");
|
||||
if (!file) {
|
||||
wsSerial("No update_actions.json present");
|
||||
request->send(200, "No update actions needed");
|
||||
return;
|
||||
}
|
||||
StaticJsonDocument<1000> doc;
|
||||
DeserializationError error = deserializeJson(doc, file);
|
||||
JsonArray deleteFiles = doc["deletefile"].as<JsonArray>();
|
||||
for (const auto& filePath : deleteFiles) {
|
||||
if (LittleFS.remove(filePath.as<const char*>())) {
|
||||
wsSerial("deleted file: " + filePath.as<String>());
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
wsSerial("Cleanup finished");
|
||||
request->send(200, "Clean up finished");
|
||||
LittleFS.remove("/update_actions.json");
|
||||
}
|
||||
@@ -143,7 +143,7 @@ void saveDB(String filename) {
|
||||
if (c > 0) {
|
||||
file.write(',');
|
||||
}
|
||||
serializeJson(doc, file);
|
||||
serializeJsonPretty(doc, file);
|
||||
}
|
||||
file.write(']');
|
||||
|
||||
|
||||
@@ -275,6 +275,8 @@ void init_web() {
|
||||
uint8_t mac[8];
|
||||
if (hex2mac(dst, mac)) {
|
||||
json = tagDBtoJson(mac);
|
||||
} else {
|
||||
json = "{\"error\": \"malformatted parameter\"}";
|
||||
}
|
||||
} else {
|
||||
uint8_t startPos = 0;
|
||||
@@ -398,11 +400,11 @@ void init_web() {
|
||||
server.on("/sysinfo", HTTP_GET, handleSysinfoRequest);
|
||||
server.on("/check_file", HTTP_GET, handleCheckFile);
|
||||
server.on("/getexturl", HTTP_GET, handleGetExtUrl);
|
||||
server.on("/rollback", HTTP_POST, handleRollback);
|
||||
server.on("/update_actions", HTTP_POST, handleUpdateActions);
|
||||
server.on("/update_ota", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
handleUpdateOTA(request);
|
||||
});
|
||||
server.on("/rollback", HTTP_POST, handleRollback);
|
||||
|
||||
server.on(
|
||||
"/littlefs_put", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
request->send(200);
|
||||
|
||||
Reference in New Issue
Block a user