#include #include "main.h" #include "settings.h" #include "display.h" #include "xprintf.h" #include "working_modes.h" #include "nmea.h" #include "menu.h" EEMEM struct config_s config_eep; EEMEM unsigned char config_crc; const __flash unsigned char limits_max_u8[] = { [CONF_U8_GNSS_MODE] = GNSS_MODE_BEIDOU, [CONF_U8_SKIP_POINTS] = 120, [CONF_U8_AUTO_PAUSE_TIME] = 120, [CONF_U8_AUTO_PAUSE_DIST] = 100, [CONF_U8_MIN_SATS] = 12, }; const __flash unsigned char limits_min_u8[] = { [CONF_U8_GNSS_MODE] = GNSS_MODE_GPS_GLONASS_GALILEO, [CONF_U8_SKIP_POINTS] = 0, [CONF_U8_AUTO_PAUSE_TIME] = 10, [CONF_U8_AUTO_PAUSE_DIST] = 2, [CONF_U8_MIN_SATS] = 4, }; const __flash unsigned char defaults_u8[] = { [CONF_U8_GNSS_MODE] = GNSS_MODE_GPS_GLONASS_GALILEO, [CONF_U8_SKIP_POINTS] = 15, [CONF_U8_AUTO_PAUSE_TIME] = 30, [CONF_U8_AUTO_PAUSE_DIST] = 10, [CONF_U8_MIN_SATS] = 5, }; 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] || System.conf.conf_u8[i] < limits_min_u8[i]) { ret = 1; System.conf.conf_u8[i] = defaults_u8[i]; } } check_min_sat_limit(); 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