From 27ef8399e48a99ef51116480212aa6f0241daeff Mon Sep 17 00:00:00 2001 From: Jan Philipp Ecker Date: Thu, 19 Jun 2025 10:08:15 +0200 Subject: [PATCH] Adds slight debouncing to the scale loop weight logic Adds slight debouncing to the scale loop to prevent jitter of the weight displayed on the screen. --- src/scale.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scale.cpp b/src/scale.cpp index 5808829..83edeeb 100644 --- a/src/scale.cpp +++ b/src/scale.cpp @@ -74,7 +74,11 @@ void scale_loop(void * parameter) { scaleTareRequest = false; } - weight = round(scale.get_units()); + // Only update weight if median changed more than 1 + int16_t newWeight = round(scale.get_units()); + if(abs(weight-newWeight) > 1){ + weight = newWeight; + } } vTaskDelay(pdMS_TO_TICKS(100));