|
@@ -163,113 +163,17 @@
|
|
|
#define VI_LVH 3.4
|
|
#define VI_LVH 3.4
|
|
|
#define VI_MULT (3.3 / 6.6 / 2.495 * 1024)
|
|
#define VI_MULT (3.3 / 6.6 / 2.495 * 1024)
|
|
|
|
|
|
|
|
-/* Configuration flags */
|
|
|
|
|
-#define CONFFLAG_DISABLE_FILTERS 0x01
|
|
|
|
|
-#define CONFFLAG_ENABLE_SBAS 0x02
|
|
|
|
|
-#define CONFFLAG_AUTO_PAUSE 0x04
|
|
|
|
|
-#define CONFFLAG_VERBOSE_LOG 0x08
|
|
|
|
|
-#define CONFFLAG_RESET_ON_NEW_FILE 0x10
|
|
|
|
|
-
|
|
|
|
|
-/* Reject reasons (see soft/syslog.h) */
|
|
|
|
|
-#define REJECT_REASON_KALMAN 0
|
|
|
|
|
-#define REJECT_REASON_DISTDIFF 1
|
|
|
|
|
-#define REJECT_REASON_MINDIST 2
|
|
|
|
|
-#define REJECT_REASON_ALTDIFF 3
|
|
|
|
|
-
|
|
|
|
|
-/* UART log mode (see soft/settings.h) */
|
|
|
|
|
-#define UART_LOG_MODE_MIXED 0
|
|
|
|
|
-#define UART_LOG_MODE_NMEA 1
|
|
|
|
|
-#define UART_LOG_MODE_SYSTEM 2
|
|
|
|
|
-
|
|
|
|
|
-/* Fix type (see soft/main.h) */
|
|
|
|
|
-#define FIX_TYPE_UNKNOWN 0
|
|
|
|
|
-#define FIX_TYPE_2D 2
|
|
|
|
|
-#define FIX_TYPE_3D 3
|
|
|
|
|
-
|
|
|
|
|
-/* GNSS modes */
|
|
|
|
|
-#define GNSS_MODE_GPS_GLONASS_GALILEO 0
|
|
|
|
|
-#define GNSS_MODE_GPS 1
|
|
|
|
|
-#define GNSS_MODE_GPS_GALILEO 2
|
|
|
|
|
-#define GNSS_MODE_GALILEO 3
|
|
|
|
|
-#define GNSS_MODE_GPS_BEIDOU 4
|
|
|
|
|
-#define GNSS_MODE_BEIDOU 5
|
|
|
|
|
-
|
|
|
|
|
-/* GPS initialization states */
|
|
|
|
|
|
|
+/* GPS initialization states (PC-build value only - GPS_INIT_INITIALIZED
|
|
|
|
|
+ * doesn't exist here, this tool has no real GPS module init sequence) */
|
|
|
#define GPS_INIT_NOT_INITIALIZED 0
|
|
#define GPS_INIT_NOT_INITIALIZED 0
|
|
|
#define GPS_INIT_QUERY_SENT 1
|
|
#define GPS_INIT_QUERY_SENT 1
|
|
|
|
|
|
|
|
-/* Location validity states */
|
|
|
|
|
-#define LOC_INVALID 0
|
|
|
|
|
-#define LOC_VALID_NEW 1
|
|
|
|
|
-#define LOC_VALID 2
|
|
|
|
|
-
|
|
|
|
|
-/* Configuration structure */
|
|
|
|
|
-struct config_s {
|
|
|
|
|
- unsigned char skip_points;
|
|
|
|
|
- unsigned char auto_pause_dist;
|
|
|
|
|
- unsigned char auto_pause_time;
|
|
|
|
|
- unsigned char auto_pause_speed;
|
|
|
|
|
- unsigned char gnss_mode;
|
|
|
|
|
- unsigned char min_sat;
|
|
|
|
|
- unsigned char min_sats; /* Alias for compatibility */
|
|
|
|
|
- unsigned char uart_log_mode;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/* System structure */
|
|
|
|
|
-struct system_s {
|
|
|
|
|
- struct config_s conf;
|
|
|
|
|
- unsigned long int distance; /* cm */
|
|
|
|
|
- unsigned long int elevation_gain; /* dm (decimeters, 0.1m resolution); filtered */
|
|
|
|
|
- unsigned long int elevation_loss; /* dm; filtered */
|
|
|
|
|
- unsigned long int elevation_gain_raw; /* dm; unfiltered, for comparison only */
|
|
|
|
|
- unsigned long int elevation_loss_raw; /* dm; unfiltered, for comparison only */
|
|
|
|
|
- unsigned long int alt_max; /* dm; highest smoothed altitude seen */
|
|
|
|
|
- unsigned long int points_written;
|
|
|
|
|
- unsigned long int rejected_count;
|
|
|
|
|
- unsigned long int points_paused;
|
|
|
|
|
- unsigned long int points_skipped;
|
|
|
|
|
- unsigned long int points_accepted;
|
|
|
|
|
- unsigned long int speed_accum_x100;
|
|
|
|
|
- unsigned long int speed_sample_count;
|
|
|
|
|
- unsigned int hdop_x100;
|
|
|
|
|
- unsigned char fix_type;
|
|
|
|
|
- unsigned char speed; /* km/h */
|
|
|
|
|
- float bat_volt;
|
|
|
|
|
- float bat_volt_min;
|
|
|
|
|
- float temperature;
|
|
|
|
|
- unsigned char temperature_ok;
|
|
|
|
|
- time_t time_start;
|
|
|
|
|
- time_t current_pause_start;
|
|
|
|
|
- time_t pause_time;
|
|
|
|
|
- unsigned tracking_paused:1;
|
|
|
|
|
- unsigned tracking_auto_paused:1;
|
|
|
|
|
- unsigned gps_initialized:2;
|
|
|
|
|
- unsigned gps_only:1;
|
|
|
|
|
- unsigned keypress:1;
|
|
|
|
|
- unsigned location_valid:2;
|
|
|
|
|
- unsigned sat_count_low:1;
|
|
|
|
|
- unsigned dgps:1; /* GGA reports a DGPS-quality fix - the receiver's own doing, not CONFFLAG_ENABLE_SBAS (our SBAS-search request) */
|
|
|
|
|
- unsigned satellites_used:5;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/* Location structure */
|
|
|
|
|
-struct location_s {
|
|
|
|
|
- float lon;
|
|
|
|
|
- float lat;
|
|
|
|
|
- float alt;
|
|
|
|
|
- time_t time;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/* Must match soft/autopause.h exactly: soft/autopause.c is compiled into
|
|
|
|
|
- * this tool too (see autopause_wrapper.c). */
|
|
|
|
|
-struct auto_pause_s {
|
|
|
|
|
- unsigned char point_counter;
|
|
|
|
|
- unsigned long int prev_distance;
|
|
|
|
|
- unsigned char speed_counter;
|
|
|
|
|
- struct location_s pause_anchor;
|
|
|
|
|
- unsigned int anchor_sample_count;
|
|
|
|
|
- unsigned char resume_high_history;
|
|
|
|
|
-};
|
|
|
|
|
|
|
+/* struct system_s/location_s/config_s/auto_pause_s and the value constants
|
|
|
|
|
+ * their fields hold are in soft/common.h - shared byte-for-byte with the
|
|
|
|
|
+ * embedded build, since gpx.c/nmea.c/syslog.c/autopause.c (soft/) compile
|
|
|
|
|
+ * unmodified into this tool too (see the *_wrapper.c files). */
|
|
|
|
|
+#include "../soft/common.h"
|
|
|
|
|
+
|
|
|
extern struct auto_pause_s auto_pause;
|
|
extern struct auto_pause_s auto_pause;
|
|
|
|
|
|
|
|
/* Global variables */
|
|
/* Global variables */
|
|
@@ -277,11 +181,22 @@ extern volatile struct system_s System;
|
|
|
extern struct location_s location;
|
|
extern struct location_s location;
|
|
|
extern time_t utc;
|
|
extern time_t utc;
|
|
|
|
|
|
|
|
-/* Configuration flags */
|
|
|
|
|
-extern unsigned char config_flags;
|
|
|
|
|
|
|
+/* Kept in sync with soft/settings.c's get_flag()/set_flag(): System.conf.flags
|
|
|
|
|
+ * is part of struct config_s in common.h, and CONFFLAG_* there is a bit
|
|
|
|
|
+ * index (not a pre-shifted mask), so this must index the same way - not the
|
|
|
|
|
+ * config_flags-bitmask scheme this used to have, which numbered its flags
|
|
|
|
|
+ * differently (and didn't have all of them), a silent mismatch from
|
|
|
|
|
+ * embedded's real indices that a shared header can't paper over unless both
|
|
|
|
|
+ * sides actually agree on what a CONFFLAG_* value means. */
|
|
|
|
|
+static inline unsigned char get_flag(unsigned char index) {
|
|
|
|
|
+ return System.conf.flags[index/8] & (1 << (index % 8));
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-static inline unsigned char get_flag(unsigned char flag) {
|
|
|
|
|
- return (config_flags & flag) ? 1 : 0;
|
|
|
|
|
|
|
+static inline void set_flag(unsigned char index, unsigned char val) {
|
|
|
|
|
+ if (val)
|
|
|
|
|
+ System.conf.flags[index/8] |= (1 << (index % 8));
|
|
|
|
|
+ else
|
|
|
|
|
+ System.conf.flags[index/8] &= ~(1 << (index % 8));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* soft/main.c's helpers, reimplemented here: soft/main.c itself isn't part
|
|
/* soft/main.c's helpers, reimplemented here: soft/main.c itself isn't part
|
|
@@ -294,8 +209,8 @@ static inline unsigned char tracking_is_paused(void) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Kept in sync with soft/main.c's pause_time_start()/pause_time_end()/
|
|
/* Kept in sync with soft/main.c's pause_time_start()/pause_time_end()/
|
|
|
- * get_pause_time(): call *_start()/*_end() exactly once, at the moment a
|
|
|
|
|
- * pause actually begins/ends (not deferred to the next accepted point,
|
|
|
|
|
|
|
+ * get_pause_time(): call the start/end function exactly once, at the moment
|
|
|
|
|
+ * a pause actually begins/ends (not deferred to the next accepted point,
|
|
|
* which may never come before the pause ends, or may come from a much
|
|
* which may never come before the pause ends, or may come from a much
|
|
|
* later, unrelated pause) - see soft/main.c for the full rationale. */
|
|
* later, unrelated pause) - see soft/main.c for the full rationale. */
|
|
|
static inline void pause_time_start(void) {
|
|
static inline void pause_time_start(void) {
|