add auto-tare functionality and update scale handling based on touch sensor connection
This commit is contained in:
2025-03-30 16:29:20 +02:00
parent c430c989ef
commit 4dee298b73
6 changed files with 86 additions and 20 deletions
+15 -6
View File
@@ -73,6 +73,11 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
success = calibrate_scale();
}
if (doc["payload"] == "setAutoTare")
{
success = setAutoTare(doc["enabled"].as<bool>());
}
if (success) {
ws.textAll("{\"type\":\"scale\",\"payload\":\"success\"}");
} else {
@@ -201,13 +206,17 @@ void setupWebserver(AsyncWebServer &server) {
});
// Route für Waage
server.on("/waage", HTTP_GET, [](AsyncWebServerRequest *request){
server.on("/waage", HTTP_GET, [](AsyncWebServerRequest *request)
{
Serial.println("Anfrage für /waage erhalten");
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/waage.html.gz", "text/html");
response->addHeader("Content-Encoding", "gzip");
response->addHeader("Cache-Control", CACHE_CONTROL);
request->send(response);
});
//AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/waage.html.gz", "text/html");
//response->addHeader("Content-Encoding", "gzip");
//response->addHeader("Cache-Control", CACHE_CONTROL);
String html = loadHtmlWithHeader("/waage.html");
html.replace("{{autoTare}}", (autoTare) ? "checked" : "");
request->send(200, "text/html", html); });
// Route für RFID
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){