Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a7d3318a2 | ||
|
|
9875e85e31 |
No files matched your search
+1
-1
@@ -9,7 +9,7 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[common]
|
||||
version = "3.0.7"
|
||||
version = "3.0.8"
|
||||
to_old_version = "2.0.10"
|
||||
|
||||
##
|
||||
|
||||
+23
-1
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
@@ -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...");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user