From 9e58b042c82dd11810b81c6df7315fb8995b9ad3 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Wed, 27 Aug 2025 17:21:29 +0200 Subject: [PATCH] fix: improve weight processing logic and add auto-send feature for Bambu spool ID --- .gitignore | 1 + src/main.cpp | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index b9774e9..a6e7ff5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ test/README data/* !data/ !data/.gitkeep +# important html/bambu_credentials.json html/spoolman_url.json _local/* diff --git a/src/main.cpp b/src/main.cpp index 2b75b6c..9c757c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -225,7 +225,8 @@ void loop() { lastWeight = weight; // Wenn ein Tag mit SM id erkannte wurde und der Waage Counter anspricht an SM Senden - if (activeSpoolId != "" && weigthCouterToApi > 3 && weightSend == 0 && nfcReaderState == NFC_READ_SUCCESS && tagProcessed == false && spoolmanApiState == API_IDLE) { + if (activeSpoolId != "" && weigthCouterToApi > 3 && weightSend == 0 && nfcReaderState == NFC_READ_SUCCESS && tagProcessed == false && spoolmanApiState == API_IDLE) + { // set the current tag as processed to prevent it beeing processed again tagProcessed = true; @@ -233,6 +234,11 @@ void loop() { { weightSend = 1; + // Set Bambu spool ID for auto-send if enabled + if (bambuCredentials.autosend_enable) + { + autoSetToBambuSpoolId = activeSpoolId.toInt(); + } } else { @@ -241,13 +247,9 @@ void loop() { } } - if(sendOctoUpdate && spoolmanApiState == API_IDLE){ - autoSetToBambuSpoolId = activeSpoolId.toInt(); - - if(octoEnabled) - { - updateSpoolOcto(autoSetToBambuSpoolId); - } + if(octoEnabled && sendOctoUpdate && spoolmanApiState == API_IDLE) + { + updateSpoolOcto(autoSetToBambuSpoolId); sendOctoUpdate = false; } }