123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- #include "main.h"
- #include "working_modes.h"
- #include "display.h"
- #include "HD44780-I2C.h"
- #include "xprintf.h"
- #include "settings.h"
- #include "nmea.h"
- #include "gpx.h"
- #include "menu.h"
- struct menu_params_s mp;
- void tracking_pause(void) {
- System.tracking_paused = !System.tracking_paused;
- if (System.tracking_paused)
- LEDB_ON();
- else
- LEDB_OFF();
- }
- __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!");
- }
- }
- __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!");
- }
- }
- 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;
- }
- }
- set_timer(info_display, 2000);
- }
- void new_file(void) {
- System.open_new_file = 1;
- }
- __flash const char _menu_header[] = " *** MENU *** ";
- __flash const char _settings[] = "> Ustawienia";
- __flash const char _new_file[] = "> Nowy plik";
- __flash const struct menu_pos main_menu_list[] = {
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_NAME_CSFUNCTION,
- .name = _menu_header,
- .csdisplay = save_point_get_name,
- .func = save_point,
- .allow_back = 1,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_STRING,
- .name = _menu_header,
- .value = _settings,
- .func = enter_settings,
- .allow_back = 1,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_NAME_CSFUNCTION,
- .name = _menu_header,
- .csdisplay = pause_tracking_get_name,
- .func = tracking_pause,
- .allow_back = 1,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_STRING,
- .name = _menu_header,
- .value = _new_file,
- .func = new_file,
- .allow_back = 1,
- },
- };
- __flash const struct menu_struct main_menu = {
- .list = main_menu_list,
- .num = sizeof(main_menu_list) / sizeof(main_menu_list[0]),
- };
- __flash const struct menu_pos default_menu_list[] = {
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_FUNCTION,
- .display = disp_func_main_default,
- .func = enter_main_menu,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_FUNCTION,
- .display = disp_func_coord,
- .func = enter_main_menu,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_FUNCTION,
- .display = disp_func_ele_sat,
- .func = enter_main_menu,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_FUNCTION,
- .display = disp_distance_and_time,
- .func = enter_main_menu,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_FUNCTION,
- .display = disp_speed,
- .func = enter_main_menu,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_FUNCTION,
- .display = disp_time,
- .func = enter_main_menu,
- },
- {
- .type = MENU_TYPE_FUNCTION,
- .display_type = MENU_DISPLAY_TYPE_FUNCTION,
- .display = disp_func_temperature,
- .func = enter_main_menu,
- },
- };
- __flash const struct menu_struct default_menu = {
- .list = default_menu_list,
- .num = sizeof(default_menu_list) / sizeof(default_menu_list[0]),
- };
- void enter_settings(void) {
- xprintf(PSTR("ENTER SETTINGS MENU, %d\r\n"), (int)__menu_num);
- menu_push(settings_menu);
- }
- void enter_main_menu(void) {
- xprintf(PSTR("ENTER MAIN MENU, %d\r\n"), (int)__menu_num);
- menu_push(main_menu);
- }
|