From 88f248cb7735fbfbdb4a1fa117ca125cfa07fb7e Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 30 Jan 2018 11:31:44 +0100 Subject: [PATCH] Inform user that hardcoded default settings were loaded (EEPROM version change) --- Firmware/ConfigurationStore.cpp | 13 +++++++++++-- Firmware/ConfigurationStore.h | 2 +- Firmware/Marlin_main.cpp | 4 +++- Firmware/language_all.cpp | 6 ++++-- Firmware/language_all.h | 4 ++-- Firmware/language_cz.h | 1 + 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 85c07085..23e886a9 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -47,7 +47,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) // wrong data being written to the variables. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order. -#define EEPROM_VERSION "V1" +#define EEPROM_VERSION "V2" #ifdef EEPROM_SETTINGS void Config_StoreSettings(uint16_t offset, uint8_t level) @@ -285,9 +285,10 @@ void Config_PrintSettings(uint8_t level) #ifdef EEPROM_SETTINGS -void Config_RetrieveSettings(uint16_t offset, uint8_t level) +bool Config_RetrieveSettings(uint16_t offset, uint8_t level) { int i=offset; + bool previous_settings_retrieved = true; char stored_ver[4]; char ver[4]=EEPROM_VERSION; EEPROM_READ_VAR(i,stored_ver); //read stored version @@ -386,10 +387,18 @@ void Config_RetrieveSettings(uint16_t offset, uint8_t level) else { Config_ResetDefault(); + //Return false to inform user that eeprom version was changed and firmware is using default hardcoded settings now. + //In case that storing to eeprom was not used yet, do not inform user that hardcoded settings are used. + if (eeprom_read_byte((uint8_t *)offset) != 0xFF || + eeprom_read_byte((uint8_t *)offset + 1) != 0xFF || + eeprom_read_byte((uint8_t *)offset + 2) != 0xFF) { + previous_settings_retrieved = false; + } } #ifdef EEPROM_CHITCHAT Config_PrintSettings(); #endif + return previous_settings_retrieved; } #endif diff --git a/Firmware/ConfigurationStore.h b/Firmware/ConfigurationStore.h index f5564143..facdcca2 100644 --- a/Firmware/ConfigurationStore.h +++ b/Firmware/ConfigurationStore.h @@ -14,7 +14,7 @@ FORCE_INLINE void Config_PrintSettings() {} #ifdef EEPROM_SETTINGS void Config_StoreSettings(uint16_t offset, uint8_t level = 0); -void Config_RetrieveSettings(uint16_t offset, uint8_t level = 0); +bool Config_RetrieveSettings(uint16_t offset, uint8_t level = 0); #else FORCE_INLINE void Config_StoreSettings() {} FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); } diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7a0abb71..4b1ab70a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -991,7 +991,7 @@ void setup() SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE); //lcd_update_enable(false); // why do we need this?? - andre // loads data from EEPROM if available else uses defaults (and resets step acceleration rate) - Config_RetrieveSettings(EEPROM_OFFSET); + bool previous_settings_retrieved = Config_RetrieveSettings(EEPROM_OFFSET); SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack tp_init(); // Initialize temperature loop @@ -1151,6 +1151,8 @@ void setup() show_fw_version_warnings(); + if (!previous_settings_retrieved) lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version was changed, inform user that default setting were loaded + if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { lcd_wizard(0); } diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 35bdf936..c627cd74 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -479,8 +479,10 @@ const char * const MSG_DATE_LANG_TABLE[LANG_NUM] PROGMEM = { }; const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Default settings loaded"; -const char * const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[1] PROGMEM = { - MSG_DEFAULT_SETTINGS_LOADED_EN +const char MSG_DEFAULT_SETTINGS_LOADED_CZ[] PROGMEM = "Nahrano vychozi nastaveni"; +const char * const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_DEFAULT_SETTINGS_LOADED_EN, + MSG_DEFAULT_SETTINGS_LOADED_CZ }; const char MSG_DISABLE_STEPPERS_EN[] PROGMEM = "Disable steppers"; diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 1ca91ad0..5015666c 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -168,8 +168,8 @@ extern const char* const MSG_CURRENT_LANG_TABLE[LANG_NUM]; #define MSG_CURRENT LANG_TABLE_SELECT(MSG_CURRENT_LANG_TABLE) extern const char* const MSG_DATE_LANG_TABLE[LANG_NUM]; #define MSG_DATE LANG_TABLE_SELECT(MSG_DATE_LANG_TABLE) -extern const char* const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[1]; -#define MSG_DEFAULT_SETTINGS_LOADED LANG_TABLE_SELECT_EXPLICIT(MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE, 0) +extern const char* const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[LANG_NUM]; +#define MSG_DEFAULT_SETTINGS_LOADED LANG_TABLE_SELECT(MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE) extern const char* const MSG_DISABLE_STEPPERS_LANG_TABLE[LANG_NUM]; #define MSG_DISABLE_STEPPERS LANG_TABLE_SELECT(MSG_DISABLE_STEPPERS_LANG_TABLE) extern const char* const MSG_DWELL_LANG_TABLE[1]; diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index afa66d3f..362a29b5 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -375,6 +375,7 @@ #define MSG_CHECK_IDLER "Prosim otevrete idler a manualne odstrante filament." #define MSG_FILE_INCOMPLETE "Soubor nekompletni. Pokracovat?" #define MSG_FILE_CNT "Nektere soubory nebudou setrideny. Maximalni pocet souboru pro setrideni je 100." +#define MSG_DEFAULT_SETTINGS_LOADED "Nahrano vychozi nastaveni" #define MSG_SORT_TIME "Trideni [Cas]" #define MSG_SORT_ALPHA "Trideni [Abeceda]" #define MSG_SORT_NONE "Trideni [Zadne]"