Handle devices where flash is not 1:1 memory mapped
This commit is contained in:
@@ -63,10 +63,10 @@
|
|||||||
* OLED Brightness
|
* OLED Brightness
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define MIN_BRIGHTNESS 0 // Min OLED brightness selectable
|
#define MIN_BRIGHTNESS 0 // Min OLED brightness selectable
|
||||||
#define MAX_BRIGHTNESS 100 // Max OLED brightness selectable
|
#define MAX_BRIGHTNESS 100 // Max OLED brightness selectable
|
||||||
#define BRIGHTNESS_STEP 25 // OLED brightness increment
|
#define BRIGHTNESS_STEP 25 // OLED brightness increment
|
||||||
#define DEFAULT_BRIGHTNESS 25 // default OLED brightness
|
#define DEFAULT_BRIGHTNESS 25 // default OLED brightness
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temp change settings
|
* Temp change settings
|
||||||
@@ -162,10 +162,11 @@
|
|||||||
#define HARDWARE_MAX_WATTAGE_X10 750
|
#define HARDWARE_MAX_WATTAGE_X10 750
|
||||||
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
|
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
|
||||||
#define TIP_RESISTANCE 75 // x10 ohms, 7.5 typical for Pinecil tips
|
#define TIP_RESISTANCE 75 // x10 ohms, 7.5 typical for Pinecil tips
|
||||||
|
#define CANT_DIRECT_READ_SETTINGS
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FLASH_LOGOADDR (0x08000000 + (126 * 1024))
|
#define FLASH_LOGOADDR (0x08000000 + (126 * 1024))
|
||||||
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))
|
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))
|
||||||
|
|
||||||
#define HAS_POWER_DEBUG_MENU
|
#define HAS_POWER_DEBUG_MENU
|
||||||
|
|||||||
@@ -163,7 +163,7 @@
|
|||||||
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
|
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
|
||||||
#define BLE_ENABLED
|
#define BLE_ENABLED
|
||||||
#define NEEDS_VBUS_PROBE 0
|
#define NEEDS_VBUS_PROBE 0
|
||||||
|
#define CANT_DIRECT_READ_SETTINGS
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -106,9 +106,20 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
|
|||||||
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));
|
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));
|
||||||
|
|
||||||
void saveSettings() {
|
void saveSettings() {
|
||||||
|
#ifdef CANT_DIRECT_READ_SETTINGS
|
||||||
|
// For these devices flash is not 1:1 mapped, so need to read into staging buffer
|
||||||
|
systemSettingsType temp;
|
||||||
|
flash_read_buffer((uint8_t *)&temp, sizeof(systemSettingsType));
|
||||||
|
if (memcmp((void *)&temp, (void *)&systemSettings, sizeof(systemSettingsType))) {
|
||||||
|
flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
if (memcmp((void *)SETTINGS_START_PAGE, (void *)&systemSettings, sizeof(systemSettingsType))) {
|
if (memcmp((void *)SETTINGS_START_PAGE, (void *)&systemSettings, sizeof(systemSettingsType))) {
|
||||||
flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
|
flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadSettings() {
|
bool loadSettings() {
|
||||||
@@ -157,13 +168,12 @@ void resetSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setSettingValue(const enum SettingsOptions option, const uint16_t newValue) {
|
void setSettingValue(const enum SettingsOptions option, const uint16_t newValue) {
|
||||||
const auto constants = settingsConstants[(int)option];
|
const auto constants = settingsConstants[(int)option];
|
||||||
uint16_t constrainedValue = newValue;
|
uint16_t constrainedValue = newValue;
|
||||||
if (constrainedValue < constants.min) {
|
if (constrainedValue < constants.min) {
|
||||||
// If less than min, constrain
|
// If less than min, constrain
|
||||||
constrainedValue = constants.min;
|
constrainedValue = constants.min;
|
||||||
}
|
} else if (constrainedValue > constants.max) {
|
||||||
else if (constrainedValue > constants.max) {
|
|
||||||
// If hit max, constrain
|
// If hit max, constrain
|
||||||
constrainedValue = constants.max;
|
constrainedValue = constants.max;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user