Эх сурвалжийг харах

autopause: manual resume didn't clear an active auto-pause

auto_pause_process() only forces tracking_auto_paused off while
tracking_paused is true (so an active auto-pause is dropped the
instant a manual pause starts), but that guard never fires the other
way around: manually resuming (tracking_paused -> 0) while auto-pause
was also active left tracking_auto_paused set. tracking_is_paused()
(tracking_paused || tracking_auto_paused) would then still report
paused, and the logger stayed silently paused until the
speed/distance-based auto-resume condition was separately satisfied -
well after the user asked to resume, with no indication why.

Add auto_pause_clear_manual_resume() (no log/beep - the manual resume
already has its own), called from tracking_pause() whenever the
manual-pause transition to resumed also needs to drop an auto-pause
that was riding along with it.
k4be 1 долоо хоног өмнө
parent
commit
b3ac3670d7

+ 17 - 0
soft/autopause.c

@@ -61,6 +61,23 @@ static void auto_pause_activate(void) {
 	beep(50, 3);
 }
 
+/* Call once, when tracking_pause() (working_modes.c) transitions
+ * tracking_paused from set to clear (a manual resume): auto_pause_process()
+ * only clears tracking_auto_paused while tracking_paused is *true* (to force
+ * an active auto-pause off the instant a manual pause starts), so without
+ * this, a manual resume while auto-paused would leave tracking_auto_paused
+ * set - tracking_is_paused() (tracking_paused || tracking_auto_paused) would
+ * still report paused, silently keeping the logger paused until the
+ * speed/distance-based auto-resume condition happened to also be met, well
+ * after the user asked to resume. No log/beep here (unlike auto_unpause()) -
+ * the manual resume already has its own distinct feedback. */
+void auto_pause_clear_manual_resume(void) {
+	System.tracking_auto_paused = 0;
+	auto_pause.prev_distance = System.distance;
+	auto_pause.point_counter = 0;
+	auto_pause.speed_counter = 0;
+}
+
 /* Call once, whenever fix_gap_detected() reports a gap on the point about to
  * be passed to auto_pause_process(). Without this, point_counter keeps
  * counting straight through the gap with no idea how long it was or whether

+ 1 - 0
soft/autopause.h

@@ -13,3 +13,4 @@ extern struct auto_pause_s auto_pause;
 
 void auto_pause_process(void);
 void auto_pause_reset_gap(void);
+void auto_pause_clear_manual_resume(void);

+ 10 - 2
soft/working_modes.c

@@ -2,6 +2,7 @@
 
 void tracking_pause(unsigned char cmd, unsigned char display) {
 	unsigned char was_paused = System.tracking_paused;
+	unsigned char was_auto_paused = System.tracking_auto_paused;
 
 	switch (cmd) {
 		case TRACKING_PAUSE_CMD_TOGGLE:
@@ -15,13 +16,20 @@ void tracking_pause(unsigned char cmd, unsigned char display) {
 			break;
 	}
 	if (System.tracking_paused) {
-		if (!was_paused && !System.tracking_auto_paused)
+		if (!was_paused && !was_auto_paused)
 			pause_time_start();
 		LEDB_ON();
 		if (display)
 			display_event(DISPLAY_EVENT_TRACKING_PAUSED);
 	} else {
-		if (was_paused && !System.tracking_auto_paused)
+		/* A manual resume must actually resume, even if auto-pause is also
+		 * active: auto_pause_process() only clears tracking_auto_paused
+		 * while tracking_paused is *true*, so left alone here it would
+		 * survive this transition and tracking_is_paused() would still
+		 * report paused. */
+		if (was_auto_paused)
+			auto_pause_clear_manual_resume();
+		if (was_paused && (was_auto_paused || !System.tracking_auto_paused))
 			pause_time_end();
 		LEDB_OFF();
 		if (display)