|
@@ -8,93 +8,67 @@
|
|
#include "gpx.h"
|
|
#include "gpx.h"
|
|
#include "menu.h"
|
|
#include "menu.h"
|
|
|
|
|
|
-
|
|
|
|
-struct menu_params_s mp;
|
|
|
|
-
|
|
|
|
-void tracking_pause(void) {
|
|
|
|
- System.tracking_paused = !System.tracking_paused;
|
|
|
|
- if (System.tracking_paused)
|
|
|
|
|
|
+void tracking_pause(unsigned char cmd, unsigned char display) {
|
|
|
|
+ switch (cmd) {
|
|
|
|
+ case TRACKING_PAUSE_CMD_TOGGLE:
|
|
|
|
+ System.tracking_paused = !System.tracking_paused;
|
|
|
|
+ break;
|
|
|
|
+ case TRACKING_PAUSE_CMD_RESUME:
|
|
|
|
+ System.tracking_paused = 0;
|
|
|
|
+ break;
|
|
|
|
+ case TRACKING_PAUSE_CMD_PAUSE:
|
|
|
|
+ System.tracking_paused = 1;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (System.tracking_paused) {
|
|
LEDB_ON();
|
|
LEDB_ON();
|
|
- else
|
|
|
|
|
|
+ if (display)
|
|
|
|
+ display_event(DISPLAY_EVENT_TRACKING_PAUSED);
|
|
|
|
+ } else {
|
|
LEDB_OFF();
|
|
LEDB_OFF();
|
|
|
|
+ if (display)
|
|
|
|
+ display_event(DISPLAY_EVENT_TRACKING_RESUMED);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-__flash const char *pause_tracking_get_name(void) {
|
|
|
|
- static unsigned char state = STATE_PAUSE_TRACKING_NOTPAUSED;
|
|
|
|
- switch (state) {
|
|
|
|
- default:
|
|
|
|
- case STATE_PAUSE_TRACKING_NOTPAUSED:
|
|
|
|
- if (System.tracking_paused) {
|
|
|
|
- set_timer(info_display, 2000);
|
|
|
|
- state = STATE_PAUSE_TRACKING_JUSTPAUSED;
|
|
|
|
- }
|
|
|
|
- return PSTR("> Wstrzymaj rej.");
|
|
|
|
- case STATE_PAUSE_TRACKING_JUSTPAUSED:
|
|
|
|
- if (timer_expired(info_display))
|
|
|
|
- state = STATE_PAUSE_TRACKING_PAUSED;
|
|
|
|
- if (!System.tracking_paused) {
|
|
|
|
- set_timer(info_display, 2000);
|
|
|
|
- state = STATE_PAUSE_TRACKING_JUSTUNPAUSED;
|
|
|
|
- }
|
|
|
|
- return PSTR("Wstrzymano!");
|
|
|
|
- case STATE_PAUSE_TRACKING_PAUSED:
|
|
|
|
- if (!System.tracking_paused) {
|
|
|
|
- set_timer(info_display, 2000);
|
|
|
|
- state = STATE_PAUSE_TRACKING_JUSTUNPAUSED;
|
|
|
|
- }
|
|
|
|
- return PSTR("> Wznow rejestr.");
|
|
|
|
- case STATE_PAUSE_TRACKING_JUSTUNPAUSED:
|
|
|
|
- if (System.tracking_paused) {
|
|
|
|
- set_timer(info_display, 2000);
|
|
|
|
- state = STATE_PAUSE_TRACKING_JUSTPAUSED;
|
|
|
|
- }
|
|
|
|
- if (timer_expired(info_display))
|
|
|
|
- state = STATE_PAUSE_TRACKING_NOTPAUSED;
|
|
|
|
- return PSTR("Wznowiono!");
|
|
|
|
- }
|
|
|
|
|
|
+unsigned char tracking_pause_cmd(void) {
|
|
|
|
+ tracking_pause(TRACKING_PAUSE_CMD_TOGGLE, 1);
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-__flash const char *save_point_get_name(void) {
|
|
|
|
- switch (mp.point_save_state) {
|
|
|
|
- default:
|
|
|
|
- return PSTR("> Zapisz punkt");
|
|
|
|
- case STATE_POINT_SAVE_NOT_DONE:
|
|
|
|
- if (timer_expired(info_display))
|
|
|
|
- mp.point_save_state = STATE_POINT_SAVE_READY;
|
|
|
|
- return PSTR("Nie zapisano!");
|
|
|
|
- case STATE_POINT_SAVE_DONE:
|
|
|
|
- if (timer_expired(info_display))
|
|
|
|
- mp.point_save_state = STATE_POINT_SAVE_READY;
|
|
|
|
- return PSTR("Zapisano!");
|
|
|
|
- }
|
|
|
|
|
|
+__flash const char *pause_tracking_get_name(void) {
|
|
|
|
+ if (System.tracking_paused)
|
|
|
|
+ return PSTR("> Wznow rejestr.");
|
|
|
|
+ else
|
|
|
|
+ return PSTR("> Wstrzymaj rej.");
|
|
}
|
|
}
|
|
|
|
|
|
-void save_point(void) {
|
|
|
|
- if (timer_expired(info_display)) { /* don't save too often */
|
|
|
|
- if (System.location_valid) {
|
|
|
|
- gpx_save_single_point(&location);
|
|
|
|
- mp.point_save_state = STATE_POINT_SAVE_DONE;
|
|
|
|
- } else {
|
|
|
|
- mp.point_save_state = STATE_POINT_SAVE_NOT_DONE;
|
|
|
|
- }
|
|
|
|
|
|
+unsigned char save_point(void) {
|
|
|
|
+ if (System.location_valid) {
|
|
|
|
+ gpx_save_single_point(&location);
|
|
|
|
+ display_event(DISPLAY_EVENT_POINT_SAVED);
|
|
|
|
+ } else {
|
|
|
|
+ display_event(DISPLAY_EVENT_POINT_NOT_SAVED);
|
|
}
|
|
}
|
|
- set_timer(info_display, 2000);
|
|
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-void new_file(void) {
|
|
|
|
|
|
+unsigned char new_file(void) {
|
|
System.open_new_file = 1;
|
|
System.open_new_file = 1;
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
__flash const char _menu_header[] = " *** MENU *** ";
|
|
__flash const char _menu_header[] = " *** MENU *** ";
|
|
__flash const char _settings[] = "> Ustawienia";
|
|
__flash const char _settings[] = "> Ustawienia";
|
|
__flash const char _new_file[] = "> Nowy plik";
|
|
__flash const char _new_file[] = "> Nowy plik";
|
|
|
|
+__flash const char _save_point[] = "> Zapisz punkt";
|
|
|
|
|
|
__flash const struct menu_pos main_menu_list[] = {
|
|
__flash const struct menu_pos main_menu_list[] = {
|
|
{
|
|
{
|
|
.type = MENU_TYPE_FUNCTION,
|
|
.type = MENU_TYPE_FUNCTION,
|
|
- .display_type = MENU_DISPLAY_TYPE_NAME_CSFUNCTION,
|
|
|
|
|
|
+ .display_type = MENU_DISPLAY_TYPE_STRING,
|
|
.name = _menu_header,
|
|
.name = _menu_header,
|
|
- .csdisplay = save_point_get_name,
|
|
|
|
|
|
+ .value = _save_point,
|
|
.func = save_point,
|
|
.func = save_point,
|
|
.allow_back = 1,
|
|
.allow_back = 1,
|
|
},
|
|
},
|
|
@@ -111,7 +85,7 @@ __flash const struct menu_pos main_menu_list[] = {
|
|
.display_type = MENU_DISPLAY_TYPE_NAME_CSFUNCTION,
|
|
.display_type = MENU_DISPLAY_TYPE_NAME_CSFUNCTION,
|
|
.name = _menu_header,
|
|
.name = _menu_header,
|
|
.csdisplay = pause_tracking_get_name,
|
|
.csdisplay = pause_tracking_get_name,
|
|
- .func = tracking_pause,
|
|
|
|
|
|
+ .func = tracking_pause_cmd,
|
|
.allow_back = 1,
|
|
.allow_back = 1,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -180,13 +154,13 @@ __flash const struct menu_struct default_menu = {
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
-void enter_settings(void) {
|
|
|
|
- xprintf(PSTR("ENTER SETTINGS MENU, %d\r\n"), (int)__menu_num);
|
|
|
|
|
|
+unsigned char enter_settings(void) {
|
|
menu_push(settings_menu);
|
|
menu_push(settings_menu);
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|
|
-void enter_main_menu(void) {
|
|
|
|
- xprintf(PSTR("ENTER MAIN MENU, %d\r\n"), (int)__menu_num);
|
|
|
|
|
|
+unsigned char enter_main_menu(void) {
|
|
menu_push(main_menu);
|
|
menu_push(main_menu);
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|