From 9f87ba3c424bec56fec1741984d366f7905f1243 Mon Sep 17 00:00:00 2001 From: Fisch Date: Tue, 16 Mar 2021 20:59:29 +0100 Subject: [PATCH] make display show filtered weight - tare --- src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 74f185c..f3d1353 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,8 @@ bool vbatSent=false; bool weight_updated=false; +unsigned long last_weightchange=10000; //give some headstart if startup takes a bit longer + #include #define TM1637_CLK D5 @@ -207,6 +209,8 @@ void loop() { Serial.print("new max="); Serial.println(weight_max,3); last_display_blink=loopmillis; //blink } + }else{ + last_weightchange=loopmillis; } @@ -221,7 +225,8 @@ void loop() { #define STAYONTIME_AFTER_SENT 5000 - if (millis() > MAXONTIME || (weight_sent && millis()>weight_sent_time+STAYONTIME_AFTER_SENT)) { + #define STAYONTIME_IDLE 20000 //how long to stay on (ms) after no change in weight detected + if (millis() > MAXONTIME || (weight_sent && millis()>weight_sent_time+STAYONTIME_AFTER_SENT) || millis()>last_weightchange+STAYONTIME_IDLE) { powerOff(); } @@ -232,11 +237,11 @@ void loop() { display.setBrightness(displaybrightness,true); //enable display display.setSegments(display_custom); }else{ //normale weight display - displayNumber(weight_max-weight_tare); + displayNumber(weight_filtered-weight_tare); display.setSegments(display_data); if ((loopmillis >= last_display_blink) && (loopmillis < last_display_blink+display_blink_duration)) { - display.setBrightness(displaybrightness,false); + display.setBrightness(2,true); //dimmed }else{ display.setBrightness(displaybrightness,true); }