From b29c5a9602e78a7c31f0e27d589ac1633af1568a Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Fri, 19 Nov 2021 19:52:14 +1100 Subject: [PATCH 1/5] Address settings bounds checks --- source/Core/Src/Settings.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index 1f50662dbb..3391452efa 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -113,7 +113,7 @@ bool sanitiseSettings() { } for (int i = 0; i < (int)SettingsOptions::SettingsOptionsLength; i++) { // Check min max for all settings, if outside the range, move to default - if (systemSettings.settingsValues[i] < settingsConstants[i].min || systemSettings.settingsValues[i] > settingsConstants[i].max) { + if (systemSettings.settingsValues[i] < settingsConstants[i].min || systemSettings.settingsValues[i] >= settingsConstants[i].max) { systemSettings.settingsValues[i] = settingsConstants[i].defaultValue; dirty = true; @@ -158,9 +158,8 @@ bool prevSettingValue(const enum SettingsOptions option) { int value = systemSettings.settingsValues[(int)option]; if (value <= constants.min) { value = constants.max; - } else { - value -= constants.increment; } + value -= constants.increment; systemSettings.settingsValues[(int)option] = value; return systemSettings.settingsValues[(int)option] == constants.min; } From 6d7fc2f689f28c677bf2119d5e2798f6a0bae7a3 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 15 Dec 2021 11:19:35 +1100 Subject: [PATCH 2/5] Update configuration.h --- source/Core/BSP/MHP30/configuration.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Core/BSP/MHP30/configuration.h b/source/Core/BSP/MHP30/configuration.h index 989f518d70..e550540fd8 100644 --- a/source/Core/BSP/MHP30/configuration.h +++ b/source/Core/BSP/MHP30/configuration.h @@ -94,9 +94,9 @@ */ #define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0 #define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0 - -#define THERMAL_RUNAWAY_TIME_SEC 20 -#define THERMAL_RUNAWAY_TEMP_C 20 +// Due to large thermal mass of the PCB being heated we need to pull this back a bit +#define THERMAL_RUNAWAY_TIME_SEC 30 +#define THERMAL_RUNAWAY_TEMP_C 3 #define CUT_OUT_SETTING 0 // default to no cut-off voltage #define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33)) From e33b900cff2ac02a14cb830c9f5971cc6a259ca5 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 19 Dec 2021 10:21:19 +1100 Subject: [PATCH 3/5] Rework settings to be min-max inclusive --- source/Core/Src/Settings.cpp | 75 ++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index 3391452efa..d093a4f4b7 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -26,6 +26,7 @@ bool sanitiseSettings(); * flash in uint16_t chunks */ typedef struct { + uint16_t versionMarker; uint16_t length; // Length of valid bytes following uint16_t settingsValues[SettingsOptionsLength]; // used to make this nicely "good enough" aligned to 32 butes to make driver code trivial @@ -41,48 +42,48 @@ volatile systemSettingsType systemSettings; // For every setting we need to store the min/max/increment values typedef struct { const uint16_t min; // Inclusive minimum value - const uint16_t max; // Exclusive maximum value + const uint16_t max; // Inclusive maximum value const uint16_t increment; // Standard increment const uint16_t defaultValue; // Default vaue after reset } SettingConstants; static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOptionsLength] = { //{min,max,increment,default} - {10, MAX_TEMP_F, 5, 320}, // SolderingTemp - {10, MAX_TEMP_F, 5, 150}, // SleepTemp - {0, 16, 1, SLEEP_TIME}, // SleepTime + {MIN_TEMP_C, MAX_TEMP_F, 5, 320}, // SolderingTemp + {MIN_TEMP_C, MAX_TEMP_F, 5, 150}, // SleepTemp + {0, 15, 1, SLEEP_TIME}, // SleepTime {0, 5, 1, CUT_OUT_SETTING}, // MinDCVoltageCells {24, 38, 1, RECOM_VOL_CELL}, // MinVoltageCells {90, QC_VOLTAGE_MAX, 2, 90}, // QCIdealVoltage - {0, 3, 1, ORIENTATION_MODE}, // OrientationMode - {0, 10, 1, SENSITIVITY}, // Sensitivity - {0, 2, 1, ANIMATION_LOOP}, // AnimationLoop - {0, settingOffSpeed_t::MAX_VALUE, 1, ANIMATION_SPEED}, // AnimationSpeed - {0, 4, 1, AUTO_START_MODE}, // AutoStartMode - {0, 61, 1, SHUTDOWN_TIME}, // ShutdownTime - {0, 2, 1, COOLING_TEMP_BLINK}, // CoolingTempBlink - {0, 2, 1, DETAILED_IDLE}, // DetailedIDLE - {0, 2, 1, DETAILED_SOLDERING}, // DetailedSoldering - {0, 2, 1, TEMPERATURE_INF}, // TemperatureInF - {0, 2, 1, DESCRIPTION_SCROLL_SPEED}, // DescriptionScrollSpeed - {0, 3, 1, LOCKING_MODE}, // LockingMode + {0, 2, 1, ORIENTATION_MODE}, // OrientationMode + {0, 9, 1, SENSITIVITY}, // Sensitivity + {0, 1, 1, ANIMATION_LOOP}, // AnimationLoop + {0, settingOffSpeed_t::MAX_VALUE - 1, 1, ANIMATION_SPEED}, // AnimationSpeed + {0, 3, 1, AUTO_START_MODE}, // AutoStartMode + {0, 60, 1, SHUTDOWN_TIME}, // ShutdownTime + {0, 1, 1, COOLING_TEMP_BLINK}, // CoolingTempBlink + {0, 1, 1, DETAILED_IDLE}, // DetailedIDLE + {0, 1, 1, DETAILED_SOLDERING}, // DetailedSoldering + {0, 1, 1, TEMPERATURE_INF}, // TemperatureInF + {0, 1, 1, DESCRIPTION_SCROLL_SPEED}, // DescriptionScrollSpeed + {0, 2, 1, LOCKING_MODE}, // LockingMode {0, 100, 1, POWER_PULSE_DEFAULT}, // KeepAwakePulse {1, POWER_PULSE_WAIT_MAX, 1, POWER_PULSE_WAIT_DEFAULT}, // KeepAwakePulseWait {1, POWER_PULSE_DURATION_MAX, 1, POWER_PULSE_DURATION_DEFAULT}, // KeepAwakePulseDuration {360, 900, 1, VOLTAGE_DIV}, // VoltageDiv - {0, MAX_TEMP_F, 10, BOOST_TEMP}, // BoostTemp + {MIN_TEMP_C, MAX_TEMP_F, 10, BOOST_TEMP}, // BoostTemp {100, 2500, 1, CALIBRATION_OFFSET}, // CalibrationOffset {0, MAX_POWER_LIMIT, POWER_LIMIT_STEPS, POWER_LIMIT}, // PowerLimit - {0, 2, 1, REVERSE_BUTTON_TEMP_CHANGE}, // ReverseButtonTempChangeEnabled + {0, 1, 1, REVERSE_BUTTON_TEMP_CHANGE}, // ReverseButtonTempChangeEnabled {5, TEMP_CHANGE_LONG_STEP_MAX, 5, TEMP_CHANGE_LONG_STEP}, // TempChangeLongStep {1, TEMP_CHANGE_SHORT_STEP_MAX, 1, TEMP_CHANGE_SHORT_STEP}, // TempChangeShortStep - {0, 4, 1, 1}, // HallEffectSensitivity - {0, 10, 1, 0}, // AccelMissingWarningCounter - {0, 10, 1, 0}, // PDMissingWarningCounter + {0, 3, 1, 1}, // HallEffectSensitivity + {0, 9, 1, 0}, // AccelMissingWarningCounter + {0, 9, 1, 0}, // PDMissingWarningCounter {0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage - {0, 51, 1, 0}, // PDNegTimeout - {0, 2, 1, 0}, // OLEDInversion - {0, 100, 11, 33}, // OLEDBrightness + {0, 50, 1, 0}, // PDNegTimeout + {0, 1, 1, 0}, // OLEDInversion + {0, 99, 11, 33}, // OLEDBrightness }; static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength)); @@ -100,6 +101,10 @@ bool sanitiseSettings() { // For all settings, need to ensure settings are in a valid range // First for any not know about due to array growth, reset them and update the length value bool dirty = false; + if (systemSettings.versionMarker != 0x55AA) { + memset((void *)&systemSettings, 0xFF, sizeof(systemSettings)); + systemSettings.versionMarker = 0x55AA; + } if (systemSettings.padding != 0xFFFFFFFF) { systemSettings.padding = 0xFFFFFFFF; // Force padding to 0xFFFFFFFF so that rolling forwards / back should be easier dirty = true; @@ -113,7 +118,7 @@ bool sanitiseSettings() { } for (int i = 0; i < (int)SettingsOptions::SettingsOptionsLength; i++) { // Check min max for all settings, if outside the range, move to default - if (systemSettings.settingsValues[i] < settingsConstants[i].min || systemSettings.settingsValues[i] >= settingsConstants[i].max) { + if (systemSettings.settingsValues[i] < settingsConstants[i].min || systemSettings.settingsValues[i] > settingsConstants[i].max) { systemSettings.settingsValues[i] = settingsConstants[i].defaultValue; dirty = true; @@ -133,26 +138,38 @@ void resetSettings() { void setSettingValue(const enum SettingsOptions option, const uint16_t newValue) { const auto constants = settingsConstants[(int)option]; systemSettings.settingsValues[(int)option] = newValue; + // If less than min, constrain if (systemSettings.settingsValues[(int)option] < constants.min) { systemSettings.settingsValues[(int)option] = constants.min; } // If hit max, constrain - if (systemSettings.settingsValues[(int)option] >= constants.max) { - systemSettings.settingsValues[(int)option] = constants.max - 1; + if (systemSettings.settingsValues[(int)option] > constants.max) { + systemSettings.settingsValues[(int)option] = constants.max; } } +// Lookup wrapper for ease of use (with typing) uint16_t getSettingValue(const enum SettingsOptions option) { return systemSettings.settingsValues[(int)option]; } +// Increment by the step size to the next value. If past the end wrap to the minimum +// Returns true if we are on the _last_ value bool nextSettingValue(const enum SettingsOptions option) { const auto constants = settingsConstants[(int)option]; - if (systemSettings.settingsValues[(int)option] >= (constants.max - constants.increment)) { + if (systemSettings.settingsValues[(int)option] == (constants.max)) { + // Already at max, wrap to the start systemSettings.settingsValues[(int)option] = constants.min; + } else if (systemSettings.settingsValues[(int)option] >= (constants.max - constants.increment)) { + // If within one increment of the end, constrain to the end + systemSettings.settingsValues[(int)option] = constants.max; } else { + // Otherwise increment systemSettings.settingsValues[(int)option] += constants.increment; } - return (constants.max - systemSettings.settingsValues[(int)option]) <= constants.increment; + // Return if we are at the max + return constants.max == systemSettings.settingsValues[(int)option]; } +// Step backwards on the settings item +// Return true if we are at the end (min) bool prevSettingValue(const enum SettingsOptions option) { const auto constants = settingsConstants[(int)option]; int value = systemSettings.settingsValues[(int)option]; From 47929e9ee019de10077d045f55e4af404eda5c56 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 19 Dec 2021 10:57:57 +1100 Subject: [PATCH 4/5] Update PD stack --- source/Core/Drivers/usb-pd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Drivers/usb-pd b/source/Core/Drivers/usb-pd index a9ea9e9917..4c5a5625ba 160000 --- a/source/Core/Drivers/usb-pd +++ b/source/Core/Drivers/usb-pd @@ -1 +1 @@ -Subproject commit a9ea9e9917ebd0f685a3ae630819aa015993e2e2 +Subproject commit 4c5a5625bab7191b77147e1ef1bd6e2705f9e640 From 7a654caf2acc6c5df0ee22c4e7c30f495ad5f618 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 19 Dec 2021 11:23:42 +1100 Subject: [PATCH 5/5] Handle different calibration offset ranges for MHP30 --- source/Core/BSP/MHP30/configuration.h | 42 ++++----- source/Core/BSP/Miniware/configuration.h | 105 ++++++++++++----------- source/Core/BSP/Pine64/configuration.h | 35 ++++---- source/Core/Src/Settings.cpp | 6 +- 4 files changed, 97 insertions(+), 91 deletions(-) diff --git a/source/Core/BSP/MHP30/configuration.h b/source/Core/BSP/MHP30/configuration.h index e550540fd8..70702cecb7 100644 --- a/source/Core/BSP/MHP30/configuration.h +++ b/source/Core/BSP/MHP30/configuration.h @@ -94,8 +94,9 @@ */ #define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0 #define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0 + // Due to large thermal mass of the PCB being heated we need to pull this back a bit -#define THERMAL_RUNAWAY_TIME_SEC 30 +#define THERMAL_RUNAWAY_TIME_SEC 45 #define THERMAL_RUNAWAY_TEMP_C 3 #define CUT_OUT_SETTING 0 // default to no cut-off voltage @@ -118,25 +119,26 @@ #endif #ifdef MODEL_MHP30 -#define SOLDERING_TEMP 200 // Default soldering temp is 200.0 °C -#define VOLTAGE_DIV 360 // Default for MHP30 -#define PID_POWER_LIMIT 65 // Sets the max pwm power limit -#define CALIBRATION_OFFSET 0 // the adc offset in uV - MHP compensates automagically -#define POWER_LIMIT 65 // 65 watts default power limit -#define MAX_POWER_LIMIT 65 // -#define POWER_LIMIT_STEPS 1 // -#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_MHP30 // -#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate -#define MODEL_HAS_DCDC // Has inductor to current filter -#define PID_TIM_HZ (16) // -#define MAX_TEMP_C 300 // Max soldering temp selectable °C -#define MAX_TEMP_F 570 // Max soldering temp selectable °F -#define MIN_TEMP_C 10 // Min soldering temp selectable °C -#define MIN_TEMP_F 60 // Min soldering temp selectable °F -#define MIN_BOOST_TEMP_C 150 // The min settable temp for boost mode °C -#define MIN_BOOST_TEMP_F 300 // The min settable temp for boost mode °F -#define NO_DISPLAY_ROTATE // Disable OLED rotation by accel -#define SLEW_LIMIT 50 // Limit to 3.0 Watts per 64ms pid loop update rate slew rate +#define SOLDERING_TEMP 200 // Default soldering temp is 200.0 °C +#define VOLTAGE_DIV 360 // Default for MHP30 +#define PID_POWER_LIMIT 65 // Sets the max pwm power limit +#define CALIBRATION_OFFSET 0 // the adc offset in uV - MHP compensates automagically +#define MIN_CALIBRATION_OFFSET 0 // Min value for calibration +#define POWER_LIMIT 65 // 65 watts default power limit +#define MAX_POWER_LIMIT 65 // +#define POWER_LIMIT_STEPS 1 // +#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_MHP30 // +#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate +#define MODEL_HAS_DCDC // Has inductor to current filter +#define PID_TIM_HZ (16) // +#define MAX_TEMP_C 350 // Max soldering temp selectable °C +#define MAX_TEMP_F 660 // Max soldering temp selectable °F +#define MIN_TEMP_C 10 // Min soldering temp selectable °C +#define MIN_TEMP_F 60 // Min soldering temp selectable °F +#define MIN_BOOST_TEMP_C 150 // The min settable temp for boost mode °C +#define MIN_BOOST_TEMP_F 300 // The min settable temp for boost mode °F +#define NO_DISPLAY_ROTATE // Disable OLED rotation by accel +#define SLEW_LIMIT 50 // Limit to 3.0 Watts per 64ms pid loop update rate slew rate #define ACCEL_MSA #define POW_PD 1 #define TEMP_NTC diff --git a/source/Core/BSP/Miniware/configuration.h b/source/Core/BSP/Miniware/configuration.h index 948bf17341..8dc8562585 100644 --- a/source/Core/BSP/Miniware/configuration.h +++ b/source/Core/BSP/Miniware/configuration.h @@ -125,23 +125,24 @@ #endif #ifdef MODEL_TS100 -#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C -#define VOLTAGE_DIV 467 // 467 - Default divider from schematic -#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV -#define PID_POWER_LIMIT 70 // Sets the max pwm power limit -#define POWER_LIMIT 0 // 0 watts default limit -#define MAX_POWER_LIMIT 70 // -#define POWER_LIMIT_STEPS 5 // -#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100 // -#define TEMP_uV_LOOKUP_HAKKO // -#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate -#define PID_TIM_HZ (8) // Tick rate of the PID loop -#define MAX_TEMP_C 450 // Max soldering temp selectable °C -#define MAX_TEMP_F 850 // Max soldering temp selectable °F -#define MIN_TEMP_C 10 // Min soldering temp selectable °C -#define MIN_TEMP_F 60 // Min soldering temp selectable °F -#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C -#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F +#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C +#define VOLTAGE_DIV 467 // 467 - Default divider from schematic +#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV +#define MIN_CALIBRATION_OFFSET 100 // Min value for calibration +#define PID_POWER_LIMIT 70 // Sets the max pwm power limit +#define POWER_LIMIT 0 // 0 watts default limit +#define MAX_POWER_LIMIT 70 // +#define POWER_LIMIT_STEPS 5 // +#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100 // +#define TEMP_uV_LOOKUP_HAKKO // +#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate +#define PID_TIM_HZ (8) // Tick rate of the PID loop +#define MAX_TEMP_C 450 // Max soldering temp selectable °C +#define MAX_TEMP_F 850 // Max soldering temp selectable °F +#define MIN_TEMP_C 10 // Min soldering temp selectable °C +#define MIN_TEMP_F 60 // Min soldering temp selectable °F +#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C +#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F #define POW_DC #define ACCEL_MMA #define POW_PD 0 @@ -150,23 +151,24 @@ #endif #ifdef MODEL_TS80 -#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C -#define VOLTAGE_DIV 780 // Default divider from schematic -#define PID_POWER_LIMIT 24 // Sets the max pwm power limit -#define CALIBRATION_OFFSET 900 // the adc offset in uV -#define POWER_LIMIT 24 // 24 watts default power limit -#define MAX_POWER_LIMIT 40 // -#define POWER_LIMIT_STEPS 2 // -#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 // -#define TEMP_uV_LOOKUP_TS80 // -#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate -#define PID_TIM_HZ (8) // Tick rate of the PID loop -#define MAX_TEMP_C 450 // Max soldering temp selectable °C -#define MAX_TEMP_F 850 // Max soldering temp selectable °F -#define MIN_TEMP_C 10 // Min soldering temp selectable °C -#define MIN_TEMP_F 60 // Min soldering temp selectable °F -#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C -#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F +#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C +#define VOLTAGE_DIV 780 // Default divider from schematic +#define PID_POWER_LIMIT 24 // Sets the max pwm power limit +#define CALIBRATION_OFFSET 900 // the adc offset in uV +#define MIN_CALIBRATION_OFFSET 100 // Min value for calibration +#define POWER_LIMIT 24 // 24 watts default power limit +#define MAX_POWER_LIMIT 40 // +#define POWER_LIMIT_STEPS 2 // +#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 // +#define TEMP_uV_LOOKUP_TS80 // +#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate +#define PID_TIM_HZ (8) // Tick rate of the PID loop +#define MAX_TEMP_C 450 // Max soldering temp selectable °C +#define MAX_TEMP_F 850 // Max soldering temp selectable °F +#define MIN_TEMP_C 10 // Min soldering temp selectable °C +#define MIN_TEMP_F 60 // Min soldering temp selectable °F +#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C +#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F #define ACCEL_LIS #define POW_QC #define POW_PD 0 @@ -176,23 +178,24 @@ #endif #ifdef MODEL_TS80P -#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C -#define VOLTAGE_DIV 650 // Default for TS80P with slightly different resistors -#define PID_POWER_LIMIT 35 // Sets the max pwm power limit -#define CALIBRATION_OFFSET 1500 // the adc offset in uV -#define POWER_LIMIT 30 // 30 watts default power limit -#define MAX_POWER_LIMIT 40 // -#define POWER_LIMIT_STEPS 2 // -#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 // -#define TEMP_uV_LOOKUP_TS80 // -#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate -#define PID_TIM_HZ (8) // Tick rate of the PID loop -#define MAX_TEMP_C 450 // Max soldering temp selectable °C -#define MAX_TEMP_F 850 // Max soldering temp selectable °F -#define MIN_TEMP_C 10 // Min soldering temp selectable °C -#define MIN_TEMP_F 60 // Min soldering temp selectable °F -#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C -#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F +#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C +#define VOLTAGE_DIV 650 // Default for TS80P with slightly different resistors +#define PID_POWER_LIMIT 35 // Sets the max pwm power limit +#define CALIBRATION_OFFSET 1500 // the adc offset in uV +#define MIN_CALIBRATION_OFFSET 100 // Min value for calibration +#define POWER_LIMIT 30 // 30 watts default power limit +#define MAX_POWER_LIMIT 40 // +#define POWER_LIMIT_STEPS 2 // +#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 // +#define TEMP_uV_LOOKUP_TS80 // +#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate +#define PID_TIM_HZ (8) // Tick rate of the PID loop +#define MAX_TEMP_C 450 // Max soldering temp selectable °C +#define MAX_TEMP_F 850 // Max soldering temp selectable °F +#define MIN_TEMP_C 10 // Min soldering temp selectable °C +#define MIN_TEMP_F 60 // Min soldering temp selectable °F +#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C +#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F #define ACCEL_LIS #define ACCEL_MSA #define POW_PD 1 diff --git a/source/Core/BSP/Pine64/configuration.h b/source/Core/BSP/Pine64/configuration.h index 97e692bae2..a77450bf5d 100644 --- a/source/Core/BSP/Pine64/configuration.h +++ b/source/Core/BSP/Pine64/configuration.h @@ -114,23 +114,24 @@ #endif #ifdef MODEL_Pinecil -#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C -#define VOLTAGE_DIV 467 // 467 - Default divider from schematic -#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV -#define PID_POWER_LIMIT 70 // Sets the max pwm power limit -#define POWER_LIMIT 0 // 0 watts default limit -#define MAX_POWER_LIMIT 70 // -#define POWER_LIMIT_STEPS 5 // -#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors -#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table -#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate -#define PID_TIM_HZ (8) // Tick rate of the PID loop -#define MAX_TEMP_C 450 // Max soldering temp selectable °C -#define MAX_TEMP_F 850 // Max soldering temp selectable °F -#define MIN_TEMP_C 10 // Min soldering temp selectable °C -#define MIN_TEMP_F 60 // Min soldering temp selectable °F -#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C -#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F +#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C +#define VOLTAGE_DIV 467 // 467 - Default divider from schematic +#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV +#define MIN_CALIBRATION_OFFSET 100 // Min value for calibration +#define PID_POWER_LIMIT 70 // Sets the max pwm power limit +#define POWER_LIMIT 0 // 0 watts default limit +#define MAX_POWER_LIMIT 70 // +#define POWER_LIMIT_STEPS 5 // +#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors +#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table +#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate +#define PID_TIM_HZ (8) // Tick rate of the PID loop +#define MAX_TEMP_C 450 // Max soldering temp selectable °C +#define MAX_TEMP_F 850 // Max soldering temp selectable °F +#define MIN_TEMP_C 10 // Min soldering temp selectable °C +#define MIN_TEMP_F 60 // Min soldering temp selectable °F +#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C +#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F #define POW_PD 1 #define POW_QC 1 diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index d093a4f4b7..3f06466ec1 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -72,7 +72,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp {1, POWER_PULSE_DURATION_MAX, 1, POWER_PULSE_DURATION_DEFAULT}, // KeepAwakePulseDuration {360, 900, 1, VOLTAGE_DIV}, // VoltageDiv {MIN_TEMP_C, MAX_TEMP_F, 10, BOOST_TEMP}, // BoostTemp - {100, 2500, 1, CALIBRATION_OFFSET}, // CalibrationOffset + {MIN_CALIBRATION_OFFSET, 2500, 1, CALIBRATION_OFFSET}, // CalibrationOffset {0, MAX_POWER_LIMIT, POWER_LIMIT_STEPS, POWER_LIMIT}, // PowerLimit {0, 1, 1, REVERSE_BUTTON_TEMP_CHANGE}, // ReverseButtonTempChangeEnabled {5, TEMP_CHANGE_LONG_STEP_MAX, 5, TEMP_CHANGE_LONG_STEP}, // TempChangeLongStep @@ -104,6 +104,7 @@ bool sanitiseSettings() { if (systemSettings.versionMarker != 0x55AA) { memset((void *)&systemSettings, 0xFF, sizeof(systemSettings)); systemSettings.versionMarker = 0x55AA; + dirty = true; } if (systemSettings.padding != 0xFFFFFFFF) { systemSettings.padding = 0xFFFFFFFF; // Force padding to 0xFFFFFFFF so that rolling forwards / back should be easier @@ -120,8 +121,7 @@ bool sanitiseSettings() { // Check min max for all settings, if outside the range, move to default if (systemSettings.settingsValues[i] < settingsConstants[i].min || systemSettings.settingsValues[i] > settingsConstants[i].max) { systemSettings.settingsValues[i] = settingsConstants[i].defaultValue; - - dirty = true; + dirty = true; } } if (dirty) {