int read_settings() { // Check version-byte of eeprom uint8_t version = eeprom_get_char(0); if (version == SETTINGS_VERSION) { // Read settings-record and check checksum if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) { return(false); } } else if (version == 1) { // Migrate from settings version 1 if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v1_t)))) { return(false); } settings.acceleration = DEFAULT_ACCELERATION; settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION; write_settings(); } else if ((version == 2) || (version == 3)) { // Migrate from settings version 2 and 3 if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) { return(false); } if (version == 2) { settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION; } settings.acceleration *= 3600; // Convert to mm/min^2 from mm/sec^2 write_settings(); } else { return(false); } return(true); }
// Reads Grbl global settings struct from EEPROM. uint8_t read_global_settings() { // Check version-byte of eeprom uint8_t version = eeprom_get_char(0); if (version == SETTINGS_VERSION) { // Read settings-record and check checksum if (!(memcpy_from_eeprom_with_checksum((char*)&settings, EEPROM_ADDR_GLOBAL, sizeof(settings_t)))) { return(false); } } else { return(false); } return(true); }
int read_settings() { // Check version-byte of eeprom uint8_t version = eeprom_get_char(0); if (version == SETTINGS_VERSION) { // Read settings-record and check checksum if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) { return(false); } } else if (version == 1) { // Migrate from settings version 1 if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v1_t)))) { return(false); } settings.acceleration = DEFAULT_ACCELERATION; settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION; // settings.auto_start = DEFAULT_AUTO_START; write_settings(); } else if ((version == 2) || (version == 3)) { // Migrate from settings version 2 and 3 if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) { return(false); } if (version == 2) { settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION; } settings.acceleration *= 3600; // Convert to mm/min^2 from mm/sec^2 // settings.auto_start = DEFAULT_AUTO_START; write_settings(); } else if (version == 4) { // Migrate from settings version 4 if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) { return(false); } //settings.auto_start = DEFAULT_AUTO_START; settings.spindle_pwm = SPINDLE_PWM; settings.default_spindle = DEFAULT_SPINDLE_SPEED; settings.max_spindle = MAX_SPINDLE_SPEED; write_settings(); } else return false; return true; }
int read_settings() { // Check version-byte of eeprom uint8_t version = eeprom_get_char(0); if (version == SETTINGS_VERSION) { // Read settings-record and check checksum if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) { return(FALSE); } } else if (version == 1) { // Migrate from old settings version if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v1_t)))) { return(FALSE); } settings.acceleration = DEFAULT_ACCELERATION; settings.max_jerk = DEFAULT_MAX_JERK; } else { return(FALSE); } return(TRUE); }
// Reads Grbl global settings struct from EEPROM. uint8_t read_global_settings() { // Check version-byte of eeprom uint8_t version = eeprom_get_char(0); if (version == SETTINGS_VERSION) { // Read settings-record and check checksum if (!(memcpy_from_eeprom_with_checksum((char*)&settings, EEPROM_ADDR_GLOBAL, sizeof(settings_t)))) { return(false); } } else { if (version <= 4) { // Migrate from settings version 4 to current version. if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v4_t)))) { return(false); } settings_reset(false); // Old settings ok. Write new settings only. } else { return(false); } } return(true); }