From d27229ad087fb71336c3abf4db0e09269675cb1a Mon Sep 17 00:00:00 2001 From: sinseman Date: Mon, 16 Mar 2015 16:01:19 +0100 Subject: [PATCH] Improve stat trigger improvement of the detection of the altitude to trigger stopping statistics --- Variometer/Variometer.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Variometer/Variometer.ino b/Variometer/Variometer.ino index ed12a72..9b18edf 100644 --- a/Variometer/Variometer.ino +++ b/Variometer/Variometer.ino @@ -1021,10 +1021,11 @@ void loop() // if the altitude out of his "zone", the timer is started if (stat.chrono_start == 0) { - if (Altitude > altitude_temp + ALTI_TRIGGER || Altitude < altitude_temp - ALTI_TRIGGER) { + if (altitude_temp + ALTI_TRIGGER < Altitude || altitude_temp - ALTI_TRIGGER > Altitude) { resetStat(); DateTime now = rtc.now(); stat.chrono_start = now.unixtime(); + chrono_cpt = 0; } else { // every 15 seconds, the altitude "zone" is updated chrono_cpt++; @@ -1035,8 +1036,8 @@ void loop() } } if (stat.chrono_start != 0 && stat.chrono == 0) { - // if altitude left in the same "zone" (2 meters) during 15 seconds, the timer is stopped - if (altitude_temp - 1 <= Altitude && altitude_temp + 1 >= Altitude) { + // if altitude left in the same "zone" (1.5 meters) during 15 seconds, the timer is stopped + if (altitude_temp - 0.75 < Altitude && altitude_temp + 0.75 > Altitude) { chrono_cpt++; if (chrono_cpt >= 15) { DateTime now = rtc.now();