Compare commits

..
8 Commits
13 changed files with 108 additions and 20 deletions

No files matched your search

+4 -4
View File
@@ -7,12 +7,12 @@
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
<script>
fetch('/api/version')
.then(response => response.json())
.then(data => {
fetch('/version.txt')
.then(response => response.text())
.then(version => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
versionSpan.textContent = 'v' + version.trim();
}
})
.catch(error => console.error('Error fetching version:', error));
+1 -2
View File
@@ -30,8 +30,7 @@
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/config">Config</a>
<a href="/about">About</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
+18 -1
View File
@@ -6,13 +6,24 @@
<title>FilaMan - Setup</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
<script>
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan</h1>
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
@@ -22,6 +33,12 @@
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
+7 -2
View File
@@ -30,10 +30,15 @@
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/config">Config</a>
<a href="/about">About</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
+1 -1
View File
@@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[common]
version = "3.0.6"
version = "3.0.8"
to_old_version = "2.0.10"
##
+23 -1
View File
@@ -105,8 +105,30 @@ bool sendWeight(int spoolId, String tagUuid, float measuredWeight) {
String payload;
serializeJson(doc, payload);
int httpCode = http.POST(payload);
if (httpCode == 200) {
String response = http.getString();
JsonDocument responseDoc;
DeserializationError error = deserializeJson(responseDoc, response);
if (!error && responseDoc["remaining_weight_g"].is<float>()) {
int remaining = (int)responseDoc["remaining_weight_g"].as<float>();
pauseMainTask = 1;
oledShowRemainingWeight(remaining);
vTaskDelay(pdMS_TO_TICKS(3000));
pauseMainTask = 0;
}
http.end();
return true;
}
else {
pauseMainTask = 1;
oledShowProgressBar(1, 1, "Failure", "API Error");
vTaskDelay(pdMS_TO_TICKS(2000));
pauseMainTask = 0;
}
http.end();
return (httpCode == 200);
return false;
}
bool sendLocation(int spoolId, String spoolTagUuid, int locationId, String locationTagUuid) {
+15
View File
@@ -50,6 +50,21 @@ bool loadJsonValue(const char* filename, JsonDocument& doc) {
return true;
}
String readFile(const char* filename) {
File file = LittleFS.open(filename, "r");
if (!file) {
Serial.print("Fehler beim Öffnen der Datei: ");
Serial.println(filename);
return "";
}
String content = "";
while (file.available()) {
content += (char)file.read();
}
file.close();
return content;
}
void initializeFileSystem() {
if (!LittleFS.begin(true)) {
Serial.println("LittleFS Mount Failed");
+1
View File
@@ -8,6 +8,7 @@
bool removeJsonValue(const char* filename);
bool saveJsonValue(const char* filename, const JsonDocument& doc);
bool loadJsonValue(const char* filename, JsonDocument& doc);
String readFile(const char* filename);
void initializeFileSystem();
#endif
+13
View File
@@ -254,6 +254,19 @@ void oledShowWeight(uint16_t weight) {
display.display();
}
void oledShowRemainingWeight(uint16_t remainingWeight) {
oledcleardata();
display.setTextSize(1);
display.setCursor(oled_center_h("Weight sent, rest:"), OLED_DATA_START + 4);
display.print("Weight sent, rest:");
display.setTextSize(3);
String weightStr = String(remainingWeight) + " g";
display.setCursor(oled_center_h(weightStr), OLED_DATA_START + 22);
display.print(weightStr);
display.display();
}
void oledShowConnectionError(const char* error, const String& ip) {
oledcleardata();
display.setTextSize(1);
+1
View File
@@ -19,6 +19,7 @@ int oled_center_v(const String &text);
void oledShowProgressBar(const uint8_t step, const uint8_t numSteps, const char* largeText, const char* statusMessage);
void oledShowWeight(uint16_t weight);
void oledShowRemainingWeight(uint16_t remainingWeight);
void oledDisplayText(const String &message, uint8_t size = 2);
void oledShowConnectionError(const char* error, const String& ip);
void oledShowTopRow();
+9 -7
View File
@@ -162,7 +162,7 @@ void loop() {
{
// Use filtered weight for smooth display, but still check API weight for significant changes
int16_t displayWeight = getFilteredDisplayWeight();
if (mainTaskWasPaused || (weight != lastWeight && nfcReaderState == NFC_IDLE))
if (mainTaskWasPaused || (weight != lastWeight && (nfcReaderState == NFC_IDLE || tagProcessed)))
{
(displayWeight < 2) ? ((displayWeight < -2) ? oledDisplayText("!! -0") : oledShowWeight(0)) : oledShowWeight(displayWeight);
}
@@ -191,12 +191,6 @@ void loop() {
}
}
// reset weight counter after writing tag
if (currentMillis - lastWeightReadTime >= weightReadInterval && nfcReaderState != NFC_IDLE && nfcReaderState != NFC_READ_SUCCESS)
{
weightCounterToApi = 0;
}
lastWeight = weight;
// Wenn ein Tag erkannt wurde und das Gewicht stabil ist, an FilaMan senden
@@ -211,6 +205,10 @@ void loop() {
sendWeightAsync(sId, activeTagUuid, weight);
weightSend = 1;
Serial.println("Weight queued for FilaMan");
// Feedback to user
pauseMainTask = 1;
oledShowProgressBar(3, 4, "Spool Tag", "Sending...");
}
// Handle successful tag write
@@ -221,6 +219,10 @@ void loop() {
sendWeightAsync(sId, activeTagUuid, weight);
weightSend = 1;
Serial.println("Weight queued for FilaMan after tag write");
// Feedback to user
pauseMainTask = 1;
oledShowProgressBar(3, 4, "Tag written", "Sending...");
}
}
+2
View File
@@ -2025,6 +2025,7 @@ void scanRfidTask(void * parameter) {
nfcJsonData = "";
activeSpoolId = "";
activeTagUuid = "";
tagProcessed = false;
oledShowWeight(weight);
}
@@ -2032,6 +2033,7 @@ void scanRfidTask(void * parameter) {
else if (!success && nfcReaderState == NFC_READ_SUCCESS)
{
nfcReaderState = NFC_IDLE;
tagProcessed = false;
Serial.println("Tag nach erfolgreichem Lesen entfernt - bereit für nächsten Tag");
}
+13 -2
View File
@@ -128,14 +128,19 @@ void setupWebserver(AsyncWebServer &server) {
server.on("/waage", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.println("Web: Request /waage");
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/waage.html", "text/html");
String html = readFile("/waage.html");
html.replace("{{autoTare}}", autoTare ? "checked" : "");
auto response = request->beginResponse(200, "text/html", html);
response->addHeader("Cache-Control", NO_CACHE);
request->send(response);
});
server.on("/setup", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.println("Web: Request /setup");
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/setup.html", "text/html");
String html = readFile("/setup.html");
html.replace("{{registered}}", filamanRegistered ? "Registered" : "Not Registered");
html.replace("{{filamanUrl}}", filamanUrl);
auto response = request->beginResponse(200, "text/html", html);
response->addHeader("Cache-Control", NO_CACHE);
request->send(response);
});
@@ -154,6 +159,12 @@ void setupWebserver(AsyncWebServer &server) {
request->send(response);
});
server.on("/version.txt", HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/version.txt", "text/plain");
response->addHeader("Cache-Control", NO_CACHE);
request->send(response);
});
server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/style.css", "text/css");
response->addHeader("Cache-Control", NO_CACHE);