Browse Source

Add option for disabling logging on startup
Add new file command

k4be 1 year ago
parent
commit
e821475a60
6 changed files with 39 additions and 5 deletions
  1. 11 1
      soft/main.c
  2. 1 0
      soft/main.h
  3. 7 0
      soft/settings.c
  4. 3 2
      soft/settings.h
  5. 14 1
      soft/working_modes.c
  6. 3 1
      soft/working_modes.h

+ 11 - 1
soft/main.c

@@ -346,6 +346,10 @@ int main (void)
 		uart0_init();	/* Enable UART */
 		_delay_ms(300);	/* Delay */
 		System.gps_initialized = 0;
+		
+		if (!get_flag(CONFFLAG_LOGGING_AFTER_BOOT)) {
+			tracking_pause();
+		}
 
 		for (;;) { /* main loop */
 			wdt_reset();
@@ -407,6 +411,12 @@ int main (void)
 					}
 					FLAGS &= ~F_SYNC;
 				}
+				if (System.open_new_file) {
+					close_files(1);
+					System.open_new_file = 0;
+					if (!System.tracking_paused)
+						tracking_pause();
+				}
 			}
 			if (System.location_valid == LOC_VALID_NEW) {
 				System.location_valid = LOC_VALID;
@@ -451,7 +461,7 @@ int main (void)
 				wdt_enable(WDTO_4S);
 				FLAGS |= F_FILEOPEN;
 				System.status = STATUS_OK;
-				beep(50, 2);		/* Two beeps. Start logging. */
+				beep(50, System.tracking_paused?5:2);		/* Two beeps. Start logging. */
 				display_state(DISPLAY_STATE_FILE_OPEN);
 				continue;
 			}

+ 1 - 0
soft/main.h

@@ -149,6 +149,7 @@ struct system_s {
 	unsigned gps_initialized:1;
 	unsigned gps_only:1;
 	unsigned tracking_paused:1;
+	unsigned open_new_file:1;
 };
 
 struct location_s {

+ 7 - 0
soft/settings.c

@@ -140,6 +140,7 @@ __flash const char _msg_disable_filters[] = "Nie filtruj";
 __flash const char _msg_enable_sbas[] = "Szukaj SBAS";
 __flash const char _msg_gnss_type[] = "Rodzaj GNSS";
 __flash const char _msg_skip_points[] = "Pomin punkty";
+__flash const char _msg_logging_after_boot[] = "Zapis po wlacz.";
 __flash const char _msg_back[] = "< Powrot";
 
 __flash const struct settings_menu_pos_s settings_menu[SETTINGS_MENU_MAXPOS+1] = {
@@ -173,6 +174,12 @@ __flash const struct settings_menu_pos_s settings_menu[SETTINGS_MENU_MAXPOS+1] =
 		.display = display_gnss_mode,
 		.changed = gps_initialize,
 	},
+	{
+		.type = SETTINGS_TYPE_BOOL,
+		.name = _msg_logging_after_boot,
+		.index = CONFFLAG_LOGGING_AFTER_BOOT,
+		.display = settings_bool_disp_default,
+	},
 };
 
 __flash const char gnss_gps_glonass_galileo[] = "GPS+GL.NS+GAL.EO";

+ 3 - 2
soft/settings.h

@@ -11,8 +11,9 @@
 /* flags list - max 31 */
 #define CONFFLAG_DISABLE_FILTERS	0
 #define CONFFLAG_ENABLE_SBAS		1
+#define CONFFLAG_LOGGING_AFTER_BOOT	2
 
-#define CONFFLAG_LAST				1
+#define CONFFLAG_LAST				2
 
 /* GNSS modes */
 #define GNSS_MODE_GPS_GLONASS_GALILEO	0
@@ -29,7 +30,7 @@
 #define HAVE_NEXT_SETTING_POSITION (mp.settings_menu_pos < SETTINGS_MENU_MAXPOS)
 #define HAVE_PREV_SETTING_POSITION (mp.settings_menu_pos > 0)
 
-#define SETTINGS_MENU_MAXPOS	4
+#define SETTINGS_MENU_MAXPOS	5
 
 struct config_s {
 	union {

+ 14 - 1
soft/working_modes.c

@@ -69,7 +69,7 @@ const char *pause_tracking_get_name(void) {
 const char *save_point_get_name(void) {
 	switch (mp.point_save_state) {
 		default:
-			return PSTR("Zapisz punkt");
+			return PSTR("> Zapisz punkt");
 		case STATE_POINT_SAVE_NOT_DONE:
 			if (timer_expired(info_display))
 				mp.point_save_state = STATE_POINT_SAVE_READY;
@@ -94,6 +94,15 @@ unsigned char save_point(void) {
 	return MODE_NO_CHANGE;
 }
 
+unsigned char new_file(void) {
+	System.open_new_file = 1;
+	return MODE_NO_CHANGE;
+}
+
+const char *new_file_get_name(void) {
+	return PSTR("> Nowy plik");
+}
+
 __flash const struct main_menu_pos_s main_menu[MAIN_MENU_MAXPOS+1] = {
 	{
 		.func = save_point,
@@ -107,6 +116,10 @@ __flash const struct main_menu_pos_s main_menu[MAIN_MENU_MAXPOS+1] = {
 		.func = tracking_pause,
 		.get_name = pause_tracking_get_name,
 	},
+	{
+		.func = new_file,
+		.get_name = new_file_get_name,
+	},
 };
 
 struct menu_params_s mp;

+ 3 - 1
soft/working_modes.h

@@ -5,7 +5,7 @@
 #define MODE_MAIN_MENU	1
 #define MODE_SETTINGS_MENU	2
 
-#define MAIN_MENU_MAXPOS 2
+#define MAIN_MENU_MAXPOS 3
 
 #define STATE_PAUSE_TRACKING_NOTPAUSED	0
 #define STATE_PAUSE_TRACKING_JUSTPAUSED	1
@@ -34,3 +34,5 @@ unsigned char enter_settings(void);
 void display_settings_menu_item(void);
 void display_main_menu_item(void);
 
+unsigned char tracking_pause(void);
+