Abort mixing on sudden weight loss
authorvolpol <volpol@packet-gain.de>
Sat, 1 Sep 2018 12:34:25 +0000 (14:34 +0200)
committervolpol <volpol@packet-gain.de>
Sat, 1 Sep 2018 12:34:25 +0000 (14:34 +0200)
mgmt.c

diff --git a/mgmt.c b/mgmt.c
index 97681976745da828be20d7decb1d387fca6ff40a..174de477fc71716b9c69d86c4e604b2b1b118494 100644 (file)
--- a/mgmt.c
+++ b/mgmt.c
@@ -48,7 +48,8 @@ int mgmt_stop(void){
     int res = MGMT_CONTINUE;
     double cw = curweight();
     if (cw >= stop_weight) res = MGMT_NORMAL_STOP; else
-    if (time(NULL) >= stop_time && MAX(cw, start_weight) - MIN(cw, start_weight) < MGMT_WEIGHT_GAIN) res = MGMT_ABORT;
+    if (time(NULL) >= stop_time && MAX(cw, start_weight) - MIN(cw, start_weight) < MGMT_WEIGHT_GAIN) res = MGMT_ABORT; else
+    if ((start_weight > cw) && (start_weight - cw >= MGMT_WEIGHT_LOSS)) res = MGMT_ABORT;
     return res;
 }