| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /*
- * Auto-pause detection: shared between the firmware and gps-test-tool (see
- * autopause_wrapper.c), since it directly gates what ends up in
- * System.distance/elevation_gain/elevation_loss (excluded while paused) and
- * is a major part of what those tools' output actually looks like.
- */
- #ifdef PC_BUILD
- #include "../gps-test-tool/main.h"
- #else
- #include "main.h"
- #endif
- struct auto_pause_s auto_pause;
- static void auto_unpause(void) {
- if (!System.tracking_auto_paused)
- return;
- System.tracking_auto_paused = 0;
- log_pause_event(0);
- beep(50, 4);
- }
- static void auto_pause_activate(void) {
- System.tracking_auto_paused = 1;
- log_pause_event(1);
- beep(50, 3);
- }
- void auto_pause_process(void) {
- if (System.tracking_paused || !get_flag(CONFFLAG_AUTO_PAUSE)) { /* remove auto-pause */
- System.tracking_auto_paused = 0;
- auto_pause.prev_distance = System.distance;
- auto_pause.point_counter = 0;
- auto_pause.speed_counter = 0;
- return;
- }
- if (System.speed >= System.conf.auto_pause_speed) { /* unpause when set speed is exceeded for 3 consecutive measurements */
- if (++auto_pause.speed_counter >= 3) {
- auto_pause.point_counter = 0;
- auto_pause.speed_counter = 0;
- auto_unpause();
- return;
- }
- } else {
- auto_pause.speed_counter = 0;
- }
- if (++auto_pause.point_counter < System.conf.auto_pause_time)
- return;
- auto_pause.point_counter = 0;
- if ((System.distance - auto_pause.prev_distance)/100 > System.conf.auto_pause_dist) {
- if (System.tracking_auto_paused)
- auto_unpause(); /* unpause when distance exceeded */
- } else {
- if (!System.tracking_auto_paused)
- auto_pause_activate(); /* pause otherwise */
- }
- auto_pause.prev_distance = System.distance;
- }
|