Merge pull request #448 from PavelSindler/eeprom_versions

EEPROM version change: inform user on LCD that default settings were loaded
This commit is contained in:
XPila 2018-01-31 20:06:19 +01:00 committed by GitHub
commit 822dd8ff9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 8 deletions

View File

@ -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

View File

@ -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(); }

View File

@ -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);
}

View File

@ -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";

View File

@ -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];

View File

@ -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]"