From 17f03e9472a5db98d2117a16be28cd12b5902ec0 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Fri, 29 Aug 2025 17:57:23 +0200 Subject: [PATCH] feat: add display delay for vendor, filament, and spool creation processes --- src/api.cpp | 11 ++++++++++- src/scale.cpp | 12 +++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/api.cpp b/src/api.cpp index e025725..70adeb6 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -654,6 +654,9 @@ uint16_t createVendor(String vendor) { vendorDoc.clear(); + // Delay for Display Bar + vTaskDelay(1000 / portTICK_PERIOD_MS); + // Wait for task completion and return the created vendor ID // Note: createdVendorId will be set by sendToApi when response is received while(createdVendorId == 65535) { @@ -806,6 +809,9 @@ uint16_t createFilament(uint16_t vendorId, const JsonDocument& payload) { filamentDoc.clear(); + // Delay for Display Bar + vTaskDelay(1000 / portTICK_PERIOD_MS); + // Wait for task completion and return the created filament ID // Note: createdFilamentId will be set by sendToApi when response is received while(createdFilamentId == 65535) { @@ -948,7 +954,10 @@ uint16_t createSpool(uint16_t vendorId, uint16_t filamentId, JsonDocument& paylo optimizedPayload.clear(); nfcReaderState = NFC_IDLE; - vTaskDelay(50 / portTICK_PERIOD_MS); + + // Delay for Display Bar + vTaskDelay(1000 / portTICK_PERIOD_MS); + startWriteJsonToTag(true, payloadString.c_str()); return createdSpoolId; diff --git a/src/scale.cpp b/src/scale.cpp index c16ff3b..d3ba2e0 100644 --- a/src/scale.cpp +++ b/src/scale.cpp @@ -48,9 +48,6 @@ void scale_loop(void * parameter) { Serial.println("Scale Loop started"); Serial.println("++++++++++++++++++++++++++++++"); - vTaskDelay(pdMS_TO_TICKS(500)); - scale_tare_counter = 10; // damit beim Starten der Waage automatisch getart wird - for(;;) { if (scale.is_ready()) { @@ -120,12 +117,13 @@ void start_scale(bool touchSensorConnected) { esp_task_wdt_reset(); } - if (scale.wait_ready_timeout(1000)) - { - scale.set_scale(calibrationValue); // this value is obtained by calibrating the scale with known weights; see the README for details - //scale.tare(); + while(!scale.is_ready()) { + vTaskDelay(pdMS_TO_TICKS(5000)); } + scale.set_scale(calibrationValue); // this value is obtained by calibrating the scale with known weights; see the README for details + scale.tare(); + // Display Gewicht oledShowWeight(0);