|
@@ -400,11 +400,42 @@ unsigned int get_dist_avg_speed_x100(void) {
|
|
|
return (unsigned int)((unsigned long int)System.distance * 36UL / (10UL * moving));
|
|
return (unsigned int)((unsigned long int)System.distance * 36UL / (10UL * moving));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Call exactly once, at the moment tracking_paused/tracking_auto_paused
|
|
|
|
|
+ * actually transitions to true (auto_pause_activate(), tracking_pause()) -
|
|
|
|
|
+ * not deferred until the next accepted point, which may never come before
|
|
|
|
|
+ * the pause ends (a near-stationary point, which is exactly what triggers a
|
|
|
|
|
+ * pause, is also exactly what a min-distance/Kalman/distdiff reject in
|
|
|
|
|
+ * gpx_process_point() would drop) or may come from a much later, unrelated
|
|
|
|
|
+ * pause, corrupting current_pause_start into a stale value that then leaks
|
|
|
|
|
+ * into get_pause_time() and the pause_time carried forward on resume. */
|
|
|
|
|
+void pause_time_start(void) {
|
|
|
|
|
+ System.current_pause_start = utc;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Call exactly once, at the moment tracking_paused/tracking_auto_paused
|
|
|
|
|
+ * actually transitions to false (auto_unpause(), tracking_pause()) - folds
|
|
|
|
|
+ * this pause's duration into the permanent accumulator and clears the
|
|
|
|
|
+ * start, so a later summary/query while not paused never reuses it. */
|
|
|
|
|
+void pause_time_end(void) {
|
|
|
|
|
+ /* Same time_start floor as get_pause_time() - a pause that started (and
|
|
|
|
|
+ * possibly also ended) before the first fix contributes no pause time,
|
|
|
|
|
+ * since logging itself hadn't started yet either. */
|
|
|
|
|
+ if (System.current_pause_start && System.current_pause_start >= System.time_start)
|
|
|
|
|
+ System.pause_time += utc - System.current_pause_start;
|
|
|
|
|
+ System.current_pause_start = 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
time_t get_pause_time(void) {
|
|
time_t get_pause_time(void) {
|
|
|
time_t res = System.pause_time;
|
|
time_t res = System.pause_time;
|
|
|
- if (System.current_pause_start < System.time_start)
|
|
|
|
|
- System.current_pause_start = System.time_start; /* disallow negative pause time */
|
|
|
|
|
- if (is_paused() && System.current_pause_start)
|
|
|
|
|
|
|
+ /* current_pause_start is 0 whenever there's no in-progress pause to add -
|
|
|
|
|
+ * either genuinely not paused, or paused but reset_counters() cleared it
|
|
|
|
|
+ * (along with time_start) after pause_time_start() ran for this pause.
|
|
|
|
|
+ * The time_start floor guards the one remaining case reset_counters()
|
|
|
|
|
+ * doesn't cover: pause_time_start() ran before the first fix (e.g. the
|
|
|
|
|
+ * boot-time "don't log until moving" pause), leaving current_pause_start
|
|
|
|
|
+ * at an earlier (possibly 0) utc than time_start - only time since
|
|
|
|
|
+ * logging actually started counts as pause time. */
|
|
|
|
|
+ if (is_paused() && System.current_pause_start && System.current_pause_start >= System.time_start)
|
|
|
res += utc - System.current_pause_start;
|
|
res += utc - System.current_pause_start;
|
|
|
return res;
|
|
return res;
|
|
|
}
|
|
}
|