Return if settings were reset
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
#define SETTINGS_H_
|
#define SETTINGS_H_
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#define SETTINGSVERSION ( 0x1A )
|
#define SETTINGSVERSION ( 0x1B )
|
||||||
/*Change this if you change the struct below to prevent people getting \
|
/*Change this if you change the struct below to prevent people getting \
|
||||||
out of sync*/
|
out of sync*/
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ typedef struct {
|
|||||||
extern volatile systemSettingsType systemSettings;
|
extern volatile systemSettingsType systemSettings;
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
void restoreSettings();
|
bool restoreSettings();
|
||||||
uint8_t lookupVoltageLevel(uint8_t level);
|
uint8_t lookupVoltageLevel(uint8_t level);
|
||||||
void resetSettings();
|
void resetSettings();
|
||||||
bool showBootLogoIfavailable();
|
bool showBootLogoIfavailable();
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ void saveSettings() {
|
|||||||
pEraseInit.PageAddress = FLASH_ADDR;
|
pEraseInit.PageAddress = FLASH_ADDR;
|
||||||
uint32_t failingAddress = 0;
|
uint32_t failingAddress = 0;
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR |
|
__HAL_FLASH_CLEAR_FLAG(
|
||||||
FLASH_FLAG_BSY);
|
FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
HAL_Delay(10);
|
HAL_Delay(10);
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
@@ -45,7 +45,7 @@ void saveSettings() {
|
|||||||
HAL_FLASH_Lock();
|
HAL_FLASH_Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreSettings() {
|
bool restoreSettings() {
|
||||||
// We read the flash
|
// We read the flash
|
||||||
uint16_t *data = (uint16_t*) &systemSettings;
|
uint16_t *data = (uint16_t*) &systemSettings;
|
||||||
for (uint8_t i = 0; i < (sizeof(systemSettingsType) / 2); i++) {
|
for (uint8_t i = 0; i < (sizeof(systemSettingsType) / 2); i++) {
|
||||||
@@ -57,7 +57,9 @@ void restoreSettings() {
|
|||||||
if (systemSettings.version != SETTINGSVERSION) {
|
if (systemSettings.version != SETTINGSVERSION) {
|
||||||
// probably not setup
|
// probably not setup
|
||||||
resetSettings();
|
resetSettings();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// Lookup function for cutoff setting -> X10 voltage
|
// Lookup function for cutoff setting -> X10 voltage
|
||||||
/*
|
/*
|
||||||
@@ -75,8 +77,7 @@ uint8_t lookupVoltageLevel(uint8_t level) {
|
|||||||
}
|
}
|
||||||
void resetSettings() {
|
void resetSettings() {
|
||||||
memset((void*) &systemSettings, 0, sizeof(systemSettingsType));
|
memset((void*) &systemSettings, 0, sizeof(systemSettingsType));
|
||||||
systemSettings.SleepTemp =
|
systemSettings.SleepTemp = 150; // Temperature the iron sleeps at - default 150.0 C
|
||||||
150; // Temperature the iron sleeps at - default 150.0 C
|
|
||||||
systemSettings.SleepTime = 6; // How many seconds/minutes we wait until going
|
systemSettings.SleepTime = 6; // How many seconds/minutes we wait until going
|
||||||
// to sleep - default 1 min
|
// to sleep - default 1 min
|
||||||
systemSettings.SolderingTemp = 320; // Default soldering temp is 320.0 C
|
systemSettings.SolderingTemp = 320; // Default soldering temp is 320.0 C
|
||||||
@@ -84,8 +85,7 @@ void resetSettings() {
|
|||||||
systemSettings.version =
|
systemSettings.version =
|
||||||
SETTINGSVERSION; // Store the version number to allow for easier upgrades
|
SETTINGSVERSION; // Store the version number to allow for easier upgrades
|
||||||
systemSettings.detailedSoldering = 0; // Detailed soldering screen
|
systemSettings.detailedSoldering = 0; // Detailed soldering screen
|
||||||
systemSettings.detailedIDLE =
|
systemSettings.detailedIDLE = 0; // Detailed idle screen (off for first time users)
|
||||||
0; // Detailed idle screen (off for first time users)
|
|
||||||
systemSettings.OrientationMode = 2; // Default to automatic
|
systemSettings.OrientationMode = 2; // Default to automatic
|
||||||
systemSettings.sensitivity = 7; // Default high sensitivity
|
systemSettings.sensitivity = 7; // Default high sensitivity
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
@@ -94,26 +94,23 @@ void resetSettings() {
|
|||||||
#else
|
#else
|
||||||
systemSettings.voltageDiv = 467; // Default divider from schematic
|
systemSettings.voltageDiv = 467; // Default divider from schematic
|
||||||
#endif
|
#endif
|
||||||
systemSettings.ShutdownTime =
|
systemSettings.ShutdownTime = 10; // How many minutes until the unit turns itself off
|
||||||
10; // How many minutes until the unit turns itself off
|
systemSettings.boostModeEnabled = 1; // Default to having boost mode on as most people prefer it
|
||||||
systemSettings.boostModeEnabled =
|
|
||||||
1; // Default to having boost mode on as most people prefer it
|
|
||||||
systemSettings.BoostTemp = 420; // default to 400C
|
systemSettings.BoostTemp = 420; // default to 400C
|
||||||
systemSettings.autoStartMode = 0; // Auto start off for safety
|
systemSettings.autoStartMode = 0; // Auto start off for safety
|
||||||
systemSettings.coolingTempBlink =
|
systemSettings.coolingTempBlink = 0; // Blink the temperature on the cooling screen when its > 50C
|
||||||
0; // Blink the temperature on the cooling screen when its > 50C
|
|
||||||
systemSettings.temperatureInF = 0; // default to 0
|
systemSettings.temperatureInF = 0; // default to 0
|
||||||
systemSettings.descriptionScrollSpeed = 0; // default to slow
|
systemSettings.descriptionScrollSpeed = 0; // default to slow
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
systemSettings.CalibrationOffset = 850; // the adc offset in uV
|
systemSettings.CalibrationOffset = 900; // the adc offset in uV
|
||||||
systemSettings.pidPowerLimit=70; // Sets the max pwm power limit
|
systemSettings.pidPowerLimit=70; // Sets the max pwm power limit
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
systemSettings.pidPowerLimit = 24; // Sets the max pwm power limit
|
systemSettings.pidPowerLimit = 24; // Sets the max pwm power limit
|
||||||
|
|
||||||
systemSettings.CalibrationOffset = 300; // the adc offset in uV
|
systemSettings.CalibrationOffset = 900; // the adc offset in uV
|
||||||
#endif
|
#endif
|
||||||
saveSettings(); // Save defaults
|
saveSettings(); // Save defaults
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user