#include #include "main.h" #include "settings.h" #include "display.h" #include "xprintf.h" #include "working_modes.h" #include "nmea.h" EEMEM struct config_s config_eep; EEMEM unsigned char config_crc; const __flash unsigned char limits_max_u8[] = { [CONF_U8_GNSS_MODE] = 5, [CONF_U8_SKIP_POINTS] = 120, }; unsigned char settings_load(void) { /* 0 - ok, 1 - error */ unsigned char crc=0, rcrc, i; unsigned char *cptr = (unsigned char *)&System.conf; unsigned char ret; eeprom_read_block(cptr, &config_eep, sizeof(struct config_s)); for (i=0; i limits_max_u8[i]) { ret = 1; System.conf.conf_u8[i] = 0; } } return ret; } void settings_store(void) { unsigned char i, crc=0; unsigned char *cptr = (unsigned char *)&System.conf; eeprom_update_block(cptr, &config_eep, sizeof(struct config_s)); for (i=0; i ")); else strcpy_P(disp.line2, PSTR("< Nie > ")); strcat_P(disp.line2, HAVE_NEXT_SETTING_POSITION?PSTR(" \x01"):PSTR(" ")); /* down arrow */ strcat_P(disp.line2, HAVE_PREV_SETTING_POSITION?PSTR(" \x02"):PSTR(" ")); /* up arrow */ } void settings_u8_disp_default(unsigned char val) { xsprintf(disp.line2, PSTR("%d"), (int)val); strcat_P(disp.line2, HAVE_NEXT_SETTING_POSITION?PSTR(" \x01"):PSTR(" ")); /* down arrow */ strcat_P(disp.line2, HAVE_PREV_SETTING_POSITION?PSTR(" \x02"):PSTR(" ")); /* up arrow */ } void display_gnss_mode(unsigned char val) { strcpy_P(disp.line2, gnss_names[val]); } /* SETTINGS ITEMS */ __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_back[] = "< Powrot"; __flash const struct settings_menu_pos_s settings_menu[SETTINGS_MENU_MAXPOS+1] = { { .type = SETTINGS_TYPE_BACK, .name = _msg_back, }, { .type = SETTINGS_TYPE_BOOL, .name = _msg_disable_filters, .index = CONFFLAG_DISABLE_FILTERS, .display = settings_bool_disp_default, }, { .type = SETTINGS_TYPE_U8, .name = _msg_skip_points, .index = CONF_U8_SKIP_POINTS, .display = settings_u8_disp_default, }, { .type = SETTINGS_TYPE_BOOL, .name = _msg_enable_sbas, .index = CONFFLAG_ENABLE_SBAS, .display = settings_bool_disp_default, .changed = gps_initialize, }, { .type = SETTINGS_TYPE_U8, .name = _msg_gnss_type, .index = CONF_U8_GNSS_MODE, .display = display_gnss_mode, .changed = gps_initialize, }, }; __flash const char gnss_gps_glonass_galileo[] = "GPS+GL.NS+GAL.EO"; __flash const char gnss_gps[] = "GPS"; __flash const char gnss_gps_galileo[] = "GPS+GALILEO"; __flash const char gnss_galileo[] = "GALILEO"; __flash const char gnss_gps_beidou[] = "GPS+BEIDOU"; __flash const char gnss_beidou[] = "BEIDOU"; __flash const char *gnss_names[] = { gnss_gps_glonass_galileo, gnss_gps, gnss_gps_galileo, gnss_galileo, gnss_gps_beidou, gnss_beidou, };