|
|
@@ -1,12 +1,20 @@
|
|
|
+#ifdef PC_BUILD
|
|
|
+#include "../gps-test-tool/main.h"
|
|
|
+#else
|
|
|
+#include "main.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+/* These are now included via main.h */
|
|
|
+#ifndef PC_BUILD
|
|
|
#include <string.h>
|
|
|
#include <avr/pgmspace.h>
|
|
|
#include "xprintf.h"
|
|
|
#include "math.h"
|
|
|
-#include "main.h"
|
|
|
#include "gpx.h"
|
|
|
#include "ff.h"
|
|
|
#include "settings.h"
|
|
|
#include "timec.h"
|
|
|
+#endif
|
|
|
|
|
|
#define KALMAN_Q 8.5e-6
|
|
|
#define KALMAN_R 4e-5
|
|
|
@@ -153,8 +161,7 @@ unsigned char gpx_write(struct location_s *loc, FIL *file) {
|
|
|
System.pause_time += utc - System.current_pause_start;
|
|
|
}
|
|
|
time = get_iso_time(loc->time, 0);
|
|
|
- xsprintf(buf, PSTR("\t\t\t<trkpt lat=\"%.8f\" lon=\"%.8f\">\n\t\t\t\t<time>%s</time>\n"), loc->lat, loc->lon, time);
|
|
|
- /* alt */
|
|
|
+ xsprintf(buf, PSTR("\t\t\t<trkpt lat=\"%.8f\" lon=\"%.8f\">\n\t\t\t\t<ele>%.2f</ele>\n\t\t\t\t<time>%s</time>\n"), loc->lat, loc->lon, loc->alt, time);
|
|
|
strcat_P(buf, PSTR("\t\t\t</trkpt>\n"));
|
|
|
}
|
|
|
|
|
|
@@ -197,10 +204,13 @@ void gpx_process_point(struct location_s *loc, FIL *file){
|
|
|
|
|
|
gpx_write(loc, file);
|
|
|
|
|
|
- /* Calculate distance from filtered points */
|
|
|
+ /* Calculate distance and elevation from filtered points */
|
|
|
if (gpx.last_distance_point.lat != 0) {
|
|
|
+ float ele_change;
|
|
|
dist = distance(&gpx.last_distance_point, &filtered_loc);
|
|
|
add_distance(dist);
|
|
|
+ ele_change = filtered_loc.alt - gpx.last_distance_point.alt;
|
|
|
+ add_elevation(ele_change);
|
|
|
}
|
|
|
gpx.last_distance_point = filtered_loc;
|
|
|
|
|
|
@@ -242,10 +252,13 @@ void gpx_process_point(struct location_s *loc, FIL *file){
|
|
|
|
|
|
xputs_P(PSTR("ACCEPT\r\n"));
|
|
|
|
|
|
- /* Calculate distance for accepted point */
|
|
|
+ /* Calculate distance and elevation for accepted point */
|
|
|
if (gpx.last_distance_point.lat != 0) {
|
|
|
+ float ele_change;
|
|
|
dist = distance(&gpx.last_distance_point, ptr);
|
|
|
add_distance(dist);
|
|
|
+ ele_change = ptr->alt - gpx.last_distance_point.alt;
|
|
|
+ add_elevation(ele_change);
|
|
|
}
|
|
|
gpx.last_distance_point = *ptr;
|
|
|
|
|
|
@@ -312,8 +325,22 @@ float distance(struct location_s *pos1, struct location_s *pos2){
|
|
|
}
|
|
|
|
|
|
void add_distance(float dist) {
|
|
|
- if (!gpx.paused)
|
|
|
+ unsigned char paused = System.tracking_paused || System.tracking_auto_paused;
|
|
|
+ if (!paused)
|
|
|
System.distance += (dist+0.005)*100.0;
|
|
|
xprintf(PSTR("Distance: %f m; sum: %f m\r\n"), dist, System.distance/100.0);
|
|
|
}
|
|
|
|
|
|
+void add_elevation(float ele_change) {
|
|
|
+ unsigned char paused = System.tracking_paused || System.tracking_auto_paused;
|
|
|
+ if (!paused) {
|
|
|
+ if (ele_change > 0) {
|
|
|
+ System.elevation_gain += (ele_change+0.05)*10.0;
|
|
|
+ } else if (ele_change < 0) {
|
|
|
+ System.elevation_loss += (-ele_change+0.05)*10.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ xprintf(PSTR("Elevation change: %f m; gain: %f m, loss: %f m\r\n"),
|
|
|
+ ele_change, System.elevation_gain/10.0, System.elevation_loss/10.0);
|
|
|
+}
|
|
|
+
|