Browse Source

GPX points written counter

pblac 2 years ago
parent
commit
310ab3c876
6 changed files with 13 additions and 2 deletions
  1. 6 0
      soft/display.c
  2. 1 0
      soft/display.h
  3. 1 1
      soft/gpx.c
  4. 3 1
      soft/main.c
  5. 1 0
      soft/main.h
  6. 1 0
      soft/working_modes.c

+ 6 - 0
soft/display.c

@@ -147,6 +147,11 @@ void disp_func_temperature(__attribute__ ((unused)) unsigned char changed) {
 	xsprintf(disp.line2, PSTR("%.1f C"), System.temperature);
 }
 
+void disp_gpx_points_written(__attribute__ ((unused)) unsigned char changed) {
+	strcpy_P(disp.line1, PSTR("GPX points"));
+	xsprintf(disp.line2, PSTR("written: %ld"), System.gpx_points_written_nb);
+}
+
 void disp_func_ele_sat(__attribute__ ((unused)) unsigned char changed) {
 	if (System.location_valid == LOC_INVALID) {
 		strcpy_P(disp.line1, PSTR("ele = ???"));
@@ -176,6 +181,7 @@ void (*__flash const disp_funcs[])(unsigned char) = {
 	[DISPLAY_STATE_VOLTAGE] = disp_func_voltage,
 	[DISPLAY_STATE_MAIN_MENU] = disp_func_main_menu,
 	[DISPLAY_STATE_TEMPERATURE] = disp_func_temperature,
+	[DISPLAY_STATE_GPX_POINTS_WRITTEN] = disp_gpx_points_written,
 };
 
 void display_refresh(unsigned char newstate) {

+ 1 - 0
soft/display.h

@@ -14,6 +14,7 @@
 #define DISPLAY_STATE_VOLTAGE	11
 #define DISPLAY_STATE_MAIN_MENU	12
 #define DISPLAY_STATE_TEMPERATURE 13
+#define DISPLAY_STATE_GPX_POINTS_WRITTEN 14
 
 void display_refresh(unsigned char newstate);
 void display_state(unsigned char newstate);

+ 1 - 1
soft/gpx.c

@@ -171,8 +171,8 @@ void gpx_process_point(struct location_s *loc, FIL *file){
 		return;
 	}
 #else
-	xputs_P(PSTR("ACCEPT\r\n"));
 	gpx_write(loc, file);
+	xputs_P(PSTR("GPX point written\r\n"));
 #endif
 }
 

+ 3 - 1
soft/main.c

@@ -407,8 +407,10 @@ int main (void)
 					System.status = STATUS_FILE_WRITE_ERROR;
 					break;
 				}
-				if (System.location_valid == LOC_VALID_NEW) /* a new point */
+				if (System.location_valid == LOC_VALID_NEW) { /* a new point */
 					gpx_process_point(&location, &gpx_file);
+					System.gpx_points_written_nb++;
+				}
 				wdt_reset();
 				if (FLAGS & F_SYNC) {
 					if (f_sync(&gps_log)) {

+ 1 - 0
soft/main.h

@@ -146,6 +146,7 @@ struct system_s {
 	unsigned char location_valid;
 	unsigned char keypress;
 	unsigned char working_mode;
+	unsigned long gpx_points_written_nb;
 };
 
 struct location_s {

+ 1 - 0
soft/working_modes.c

@@ -12,6 +12,7 @@ __flash const unsigned char main_display_modes[] = {
 	DISPLAY_STATE_ELE_SAT,
 	DISPLAY_STATE_VOLTAGE,
 	DISPLAY_STATE_TEMPERATURE,
+	DISPLAY_STATE_GPX_POINTS_WRITTEN,
 };
 
 void change_display_mode(signed char dir) {