diff --git a/Core/Inc/iron.h b/Core/Inc/iron.h index 2af5e59c..6412d632 100644 --- a/Core/Inc/iron.h +++ b/Core/Inc/iron.h @@ -94,6 +94,5 @@ bool getIronShakeFlag(void); void clearIronShakeFlag(void); uint32_t getIronLastShakeTime(void); wakeSrc_t getIronWakeSource(void); -uint16_t getUserSetTemperature(void); #endif /* IRON_H_ */ diff --git a/Core/Inc/settings.h b/Core/Inc/settings.h index 098b0233..37a2bab5 100644 --- a/Core/Inc/settings.h +++ b/Core/Inc/settings.h @@ -385,9 +385,8 @@ bool isSystemSettingsChanged(void); bool isCurrentProfileChanged(void); /** Checks if the current addons settings in RAM were changed */ bool isAddonSettingsChanged(void); - -/** Restores settings from the backup ram used in the last session (eg last temp/tip). - * Call this after all the modules */ -void restoreLastSessionSettings(void); +/** Copies las Profile / Temperature / Tip data between flash and ram when battery option is changed*/ void copy_bkp_data(uint8_t mode); +/** Set initial values after setup screen */ +void flashTempSettingsInitialSetup(void); #endif /* SETTINGS_H_ */ diff --git a/Core/Src/settings.c b/Core/Src/settings.c index 32f3e93a..5e27e556 100644 --- a/Core/Src/settings.c +++ b/Core/Src/settings.c @@ -419,7 +419,6 @@ static void storeSettings(uint8_t mode){ resetSystemSettings(&flashBufferSettings->settings); // Load defaults if(mode == reset_All){ flashBufferSettings->settings.version = 0xFF; // To trigger setup screen - flashTempSettingsErase(); } } else if(mode & save_Settings){ // Save current settings @@ -578,8 +577,9 @@ void restoreSettings(void) { loadProfile(systemSettings.currentProfile); // loadProfile will restore lastTemp and lastTip from the correct source (Flash or backup SRAM). } } - if(!setup && reset) // If not in setup mode and we have bad data + if(!setup && reset){ // If not in setup mode and we have bad data saveSettings(perform_scanFix, do_reboot); // Store settings with no arguments, this will check and reset any bad setting + } } // Otherwise, everything be resetted when exiting the boot screen void loadSettingsFromBackupRam(void) { @@ -655,6 +655,22 @@ static uint32_t ChecksumBackupRam(){ return checksum; } +void flashTempSettingsInitialSetup(void){ // To be called after initial setup screen + flashTempSettingsErase(); + for(uint8_t i=0;iprofile_C210) // Sanity check + if(profile==0xFF) // Erased flash, load T12 + profile=profile_T12; + else if(profile>profile_C210) // Sanity check Error_Handler(); uint32_t _irq = __get_PRIMASK(); diff --git a/Drivers/graphics/gui/screens/boot_screen.c b/Drivers/graphics/gui/screens/boot_screen.c index e90f6939..651bcc5d 100644 --- a/Drivers/graphics/gui/screens/boot_screen.c +++ b/Drivers/graphics/gui/screens/boot_screen.c @@ -215,6 +215,7 @@ void boot_screen_onExit(screen_t *scr){ if(systemSettings.setupMode){ saveSettings(save_Settings, no_reboot); // Save now we have all heap free. All other flash settings (Profile, tips, addons) will be checked and set to default if wrong loadProfile(profile); // Now flash is initialized and we can properly load a profile + updateTempData(force_update); systemSettings.setupMode=0; // Disable setup mode } setSafeMode(disable); // Disable safe mode before exit