From 147d96baa849be187a38598da984397f2df9402c Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 6 Jun 2022 20:32:07 +1000 Subject: [PATCH 01/10] Reduce PPS max to 20V to avoid instability Some PSU's cant actually run at 21V --- source/Core/BSP/Pine64/configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/BSP/Pine64/configuration.h b/source/Core/BSP/Pine64/configuration.h index 09033126d2..27dcd4ccc1 100644 --- a/source/Core/BSP/Pine64/configuration.h +++ b/source/Core/BSP/Pine64/configuration.h @@ -124,7 +124,7 @@ #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 21 // Maximum voltage for PD to negotiate +#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 From 5fc5119ed7828665a3eea2eaaf2ecf98b0bdad69 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 6 Jun 2022 22:08:18 +1000 Subject: [PATCH 02/10] Creating a rough draft of a "pre start check" concept --- source/Core/BSP/BSP.h | 4 ++ source/Core/BSP/MHP30/BSP.cpp | 105 +++++++++++++++++------------- source/Core/BSP/Miniware/BSP.cpp | 3 +- source/Core/BSP/Pine64/BSP.cpp | 2 + source/Core/Threads/PIDThread.cpp | 4 ++ 5 files changed, 71 insertions(+), 47 deletions(-) diff --git a/source/Core/BSP/BSP.h b/source/Core/BSP/BSP.h index b7b2cb7d40..6060f5f0e6 100644 --- a/source/Core/BSP/BSP.h +++ b/source/Core/BSP/BSP.h @@ -86,6 +86,10 @@ enum StatusLED { }; void setStatusLED(const enum StatusLED state); +// preStartChecks are run until they return 0 +// By the PID, after each ADC sample comes in +// For example, on the MHP30 this is used to figure out the resistance of the hotplate +uint8_t preStartChecks(); #ifdef __cplusplus } #endif diff --git a/source/Core/BSP/MHP30/BSP.cpp b/source/Core/BSP/MHP30/BSP.cpp index 12dac96691..38b16672f5 100644 --- a/source/Core/BSP/MHP30/BSP.cpp +++ b/source/Core/BSP/MHP30/BSP.cpp @@ -348,69 +348,82 @@ void setPlatePullup(bool pullingUp) { HAL_GPIO_Init(PLATE_SENSOR_PULLUP_GPIO_Port, &GPIO_InitStruct); } -uint16_t tipSenseResistancex10Ohms = 0; -bool isTipDisconnected() { - static bool lastTipDisconnectedState = true; - static uint16_t adcReadingPD1Set = 0; - static TickType_t lastMeas = 0; +uint16_t tipSenseResistancex10Ohms = 0; +volatile bool tipMeasurementOccuring = false; +void performTipMeasurementStep(bool start) { + static uint16_t adcReadingPD1Set = 0; + static TickType_t lastMeas = 0; + // Inter state that performs the steps to measure the resistor on the tip + // Return 1 if a measurement is ongoing + + // We want to perform our startup measurements of the tip resistance until we detect one fitted + if (start || tipSenseResistancex10Ohms == 0) { + tipMeasurementOccuring = true; + if (lastMeas == 0) { + lastMeas = xTaskGetTickCount(); + setPlatePullup(true); + } else if (xTaskGetTickCount() - lastMeas > (TICKS_100MS)) { + lastMeas = xTaskGetTickCount(); + // We are sensing the resistance + if (adcReadingPD1Set == 0) { + // We will record the reading for PD1 being set + adcReadingPD1Set = getADC(3); + setPlatePullup(false); + } else { + // We have taken reading one + uint16_t adcReadingPD1Cleared = getADC(3); + uint32_t a = ((int)adcReadingPD1Set - (int)adcReadingPD1Cleared); + a *= 10000; + uint32_t b = ((int)adcReadingPD1Cleared + (32768 - (int)adcReadingPD1Set)); + if (b) { + tipSenseResistancex10Ohms = a / b; + } else { + tipSenseResistancex10Ohms = adcReadingPD1Set = lastMeas = 0; + } + if (tipSenseResistancex10Ohms > 1100 || tipSenseResistancex10Ohms < 900) { + tipSenseResistancex10Ohms = 0; // out of range + adcReadingPD1Set = 0; + lastMeas = 0; + } + } + } + } + tipMeasurementOccuring = false; +} +bool isTipDisconnected() { + static bool lastTipDisconnectedState = true; // For the MHP30 we want to include a little extra logic in here // As when the tip is first connected we want to measure the ~100 ohm resistor on the base of the tip // And likewise if its removed we want to clear that measurement /* * plate_sensor_res = ((adc5_value_PD1_set - adc5_value_PD1_cleared) / (adc5_value_PD1_cleared + 4096 - adc5_value_PD1_set)) * 1000.0; * */ + if (tipMeasurementOccuring) { + performTipMeasurementStep(false); + return false; // We fake no tip disconnection during the measurement cycle to mask it + } bool tipDisconnected = getADC(2) > (4090 * 8); - // We have to handle here that this ^ will trip while measuring the gain resistor - if (xTaskGetTickCount() - lastMeas < (TICKS_100MS * 2 + (TICKS_100MS / 2))) { - tipDisconnected = false; + // We have to handle here that this ^ will trip while measuring the gain resistor measurement + if (!tipDisconnected) { + if (tipSenseResistancex10Ohms == 0) { + performTipMeasurementStep(false); + } } - if (tipDisconnected != lastTipDisconnectedState) { if (tipDisconnected) { // Tip is now disconnected - tipSenseResistancex10Ohms = 0; // zero out the resistance - adcReadingPD1Set = 0; - lastMeas = 0; + performTipMeasurementStep(true); } lastTipDisconnectedState = tipDisconnected; } - if (!tipDisconnected) { - if (tipSenseResistancex10Ohms == 0) { - if (lastMeas == 0) { - lastMeas = xTaskGetTickCount(); - setPlatePullup(true); - } else if (xTaskGetTickCount() - lastMeas > (TICKS_100MS)) { - lastMeas = xTaskGetTickCount(); - // We are sensing the resistance - if (adcReadingPD1Set == 0) { - // We will record the reading for PD1 being set - adcReadingPD1Set = getADC(3); - setPlatePullup(false); - } else { - // We have taken reading one - uint16_t adcReadingPD1Cleared = getADC(3); - uint32_t a = ((int)adcReadingPD1Set - (int)adcReadingPD1Cleared); - a *= 10000; - uint32_t b = ((int)adcReadingPD1Cleared + (32768 - (int)adcReadingPD1Set)); - if (b) { - tipSenseResistancex10Ohms = a / b; - } else { - tipSenseResistancex10Ohms = adcReadingPD1Set = lastMeas = 0; - } - if (tipSenseResistancex10Ohms > 1100 || tipSenseResistancex10Ohms < 900) { - tipSenseResistancex10Ohms = 0; // out of range - adcReadingPD1Set = 0; - lastMeas = 0; - } - } - } - return true; // we fake tip being disconnected until this is measured - } - } - return tipDisconnected; } + +uint8_t preStartChecks() { + performTipMeasurementStep(false); + return tipMeasurementOccuring; +} void setBuzzer(bool on) { if (on) { htim3.Instance->CCR2 = 128; diff --git a/source/Core/BSP/Miniware/BSP.cpp b/source/Core/BSP/Miniware/BSP.cpp index 1d77a8c79e..d40a7e170c 100644 --- a/source/Core/BSP/Miniware/BSP.cpp +++ b/source/Core/BSP/Miniware/BSP.cpp @@ -282,4 +282,5 @@ bool isTipDisconnected() { return tipTemp > tipDisconnectedThres; } -void setStatusLED(const enum StatusLED state) {} +void setStatusLED(const enum StatusLED state) {} +uint8_t preStartChecks() { return 0; } \ No newline at end of file diff --git a/source/Core/BSP/Pine64/BSP.cpp b/source/Core/BSP/Pine64/BSP.cpp index 4b06fae32a..2c7de076fc 100644 --- a/source/Core/BSP/Pine64/BSP.cpp +++ b/source/Core/BSP/Pine64/BSP.cpp @@ -90,3 +90,5 @@ bool isTipDisconnected() { } void setStatusLED(const enum StatusLED state) {} + +uint8_t preStartChecks() { return 0; } \ No newline at end of file diff --git a/source/Core/Threads/PIDThread.cpp b/source/Core/Threads/PIDThread.cpp index 4c56372cd0..79d8efc2b0 100644 --- a/source/Core/Threads/PIDThread.cpp +++ b/source/Core/Threads/PIDThread.cpp @@ -46,6 +46,10 @@ void startPIDTask(void const *argument __unused) { } int32_t x10WattsOut = 0; + while (preStartChecks()) { + ulTaskNotifyTake(pdTRUE, 2000); + } + for (;;) { x10WattsOut = 0; // This is a call to block this thread until the ADC does its samples From 1941266dc436904a6af3e619419ce67a541f468f Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 6 Jun 2022 22:08:31 +1000 Subject: [PATCH 03/10] Newer alpine --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4622f33b8b..d420b12bee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.15 +FROM alpine:3.16 LABEL maintainer="Ben V. Brown " WORKDIR /build @@ -14,6 +14,8 @@ RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-el # Install Python3 packages RUN python3 -m pip install bdflib black +# Git trust +RUN git config --global --add safe.directory /build/source COPY . /build/source COPY ./ci /build/ci From bfac25cfa150e64a9ade5864fc65f3777cb49108 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 7 Jun 2022 18:33:54 +1000 Subject: [PATCH 04/10] Cleaning up MHP detection --- source/Core/BSP/MHP30/BSP.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/source/Core/BSP/MHP30/BSP.cpp b/source/Core/BSP/MHP30/BSP.cpp index 38b16672f5..0586d052ac 100644 --- a/source/Core/BSP/MHP30/BSP.cpp +++ b/source/Core/BSP/MHP30/BSP.cpp @@ -362,6 +362,7 @@ void performTipMeasurementStep(bool start) { if (lastMeas == 0) { lastMeas = xTaskGetTickCount(); setPlatePullup(true); + return; } else if (xTaskGetTickCount() - lastMeas > (TICKS_100MS)) { lastMeas = xTaskGetTickCount(); // We are sensing the resistance @@ -369,6 +370,7 @@ void performTipMeasurementStep(bool start) { // We will record the reading for PD1 being set adcReadingPD1Set = getADC(3); setPlatePullup(false); + return; } else { // We have taken reading one uint16_t adcReadingPD1Cleared = getADC(3); @@ -384,6 +386,7 @@ void performTipMeasurementStep(bool start) { tipSenseResistancex10Ohms = 0; // out of range adcReadingPD1Set = 0; lastMeas = 0; + return; } } } @@ -391,7 +394,6 @@ void performTipMeasurementStep(bool start) { tipMeasurementOccuring = false; } bool isTipDisconnected() { - static bool lastTipDisconnectedState = true; // For the MHP30 we want to include a little extra logic in here // As when the tip is first connected we want to measure the ~100 ohm resistor on the base of the tip // And likewise if its removed we want to clear that measurement @@ -405,17 +407,10 @@ bool isTipDisconnected() { bool tipDisconnected = getADC(2) > (4090 * 8); // We have to handle here that this ^ will trip while measuring the gain resistor measurement - if (!tipDisconnected) { - if (tipSenseResistancex10Ohms == 0) { - performTipMeasurementStep(false); - } - } - if (tipDisconnected != lastTipDisconnectedState) { - if (tipDisconnected) { - // Tip is now disconnected - performTipMeasurementStep(true); - } - lastTipDisconnectedState = tipDisconnected; + + if (tipDisconnected) { + // Tip is now disconnected + performTipMeasurementStep(true); } return tipDisconnected; } From 3b67f7d4b67e998702456bbe6fb4c05e8c3b92ff Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 7 Jun 2022 21:43:50 +1000 Subject: [PATCH 05/10] Cleanup comments --- source/Core/BSP/MHP30/ThermoModel.cpp | 3 ++- source/Core/Threads/GUIThread.cpp | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/source/Core/BSP/MHP30/ThermoModel.cpp b/source/Core/BSP/MHP30/ThermoModel.cpp index 19c0e499f3..f43499a0f4 100644 --- a/source/Core/BSP/MHP30/ThermoModel.cpp +++ b/source/Core/BSP/MHP30/ThermoModel.cpp @@ -10,7 +10,8 @@ #include "configuration.h" extern uint16_t tipSenseResistancex10Ohms; uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { - // For the MHP30, we are mimicing the original code and using the resistor fitted to the base of the heater head, this is measured in the isTipDisconnected() function + // For the MHP30, we are mimicing the original code and using the resistor fitted to the base of the heater head, + // this is measured at boot in pid task and in the disconnected tip check if tip is removed if (tipSenseResistancex10Ohms > 900 && tipSenseResistancex10Ohms <= 1100) { int32_t a = ((tipSenseResistancex10Ohms / 10) + 300) * (3300000 - tipuVDelta); int32_t b = a / 1000000; diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 822b34b62c..544aa17222 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -172,7 +172,7 @@ static void gui_drawBatteryIcon() { } static void gui_solderingTempAdjust() { uint32_t lastChange = xTaskGetTickCount(); - currentTempTargetDegC = 0; + currentTempTargetDegC = 0; // Turn off header while adjusting temp uint32_t autoRepeatTimer = 0; uint8_t autoRepeatAcceleration = 0; bool waitForRelease = false; @@ -511,12 +511,8 @@ static void gui_solderingMode(uint8_t jumpToSleep) { boostModeOn = false; break; case BUTTON_BOTH: - // exit - return; - break; case BUTTON_B_LONG: return; // exit on back long hold - break; case BUTTON_F_LONG: // if boost mode is enabled turn it on if (getSettingValue(SettingsOptions::BoostTemp)) @@ -665,8 +661,6 @@ static void gui_solderingMode(uint8_t jumpToSleep) { // If we have tripped thermal runaway, turn off heater and show warning if (heaterThermalRunaway) { currentTempTargetDegC = 0; // heater control off - // TODO WARNING - warnUser(translatedString(Tr->WarningThermalRunaway), 10 * TICKS_SECOND); heaterThermalRunaway = false; return; From 22da891e28098064706b9c43daba9d659b39bd52 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 7 Jun 2022 21:44:10 +1000 Subject: [PATCH 06/10] PID: Run prestart based on ADC IRQ rather than times --- source/Core/Threads/PIDThread.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/Core/Threads/PIDThread.cpp b/source/Core/Threads/PIDThread.cpp index 79d8efc2b0..161fa3658f 100644 --- a/source/Core/Threads/PIDThread.cpp +++ b/source/Core/Threads/PIDThread.cpp @@ -39,25 +39,26 @@ void startPIDTask(void const *argument __unused) { pidTaskNotification = xTaskGetCurrentTaskHandle(); uint32_t PIDTempTarget = 0; // Pre-seed the adc filters - for (int i = 0; i < 128; i++) { - osDelay(5); + for (int i = 0; i < 32; i++) { + ulTaskNotifyTake(pdTRUE, 5); TipThermoModel::getTipInC(true); getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 1); } - int32_t x10WattsOut = 0; - while (preStartChecks()) { + while (preStartChecks() != 0) { ulTaskNotifyTake(pdTRUE, 2000); } + int32_t x10WattsOut = 0; + for (;;) { x10WattsOut = 0; // This is a call to block this thread until the ADC does its samples - if (ulTaskNotifyTake(pdTRUE, 2000)) { + if (ulTaskNotifyTake(pdTRUE, TICKS_SECOND * 2)) { // Do the reading here to keep the temp calculations churning along uint32_t currentTipTempInC = TipThermoModel::getTipInC(true); PIDTempTarget = currentTempTargetDegC; - if (PIDTempTarget) { + if (PIDTempTarget > 0) { // Cap the max set point to 450C if (PIDTempTarget > (450)) { // Maximum allowed output From 36364e1e873c818fa09950e1d00f1b2383c248f0 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 7 Jun 2022 21:44:23 +1000 Subject: [PATCH 07/10] MHP30: Far better startup for detecting tip gain --- source/Core/BSP/MHP30/BSP.cpp | 106 ++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/source/Core/BSP/MHP30/BSP.cpp b/source/Core/BSP/MHP30/BSP.cpp index 0586d052ac..c1feab5ca3 100644 --- a/source/Core/BSP/MHP30/BSP.cpp +++ b/source/Core/BSP/MHP30/BSP.cpp @@ -13,13 +13,15 @@ #include WS2812 ws2812; -volatile uint16_t PWMSafetyTimer = 0; -volatile uint8_t pendingPWM = 0; -uint16_t totalPWM = 255; -const uint16_t powerPWM = 255; +volatile uint16_t PWMSafetyTimer = 0; +volatile uint8_t pendingPWM = 0; +uint16_t totalPWM = 255; +const uint16_t powerPWM = 255; +uint16_t tipSenseResistancex10Ohms = 0; +volatile bool tipMeasurementOccuring = false; +history rawTempFilter = {{0}, 0, 0}; -history rawTempFilter = {{0}, 0, 0}; -void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); } +void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); } #ifdef TEMP_NTC // Lookup table for the NTC @@ -208,7 +210,8 @@ uint16_t getHandleTemperature(uint8_t sample) { uint16_t getTipInstantTemperature() { return getADC(2); } uint16_t getTipRawTemp(uint8_t refresh) { - if (refresh) { + if (refresh && (tipMeasurementOccuring == false)) { + uint16_t lastSample = getTipInstantTemperature(); rawTempFilter.update(lastSample); return lastSample; @@ -348,52 +351,57 @@ void setPlatePullup(bool pullingUp) { HAL_GPIO_Init(PLATE_SENSOR_PULLUP_GPIO_Port, &GPIO_InitStruct); } -uint16_t tipSenseResistancex10Ohms = 0; -volatile bool tipMeasurementOccuring = false; -void performTipMeasurementStep(bool start) { +void performTipMeasurementStep(bool start) { static uint16_t adcReadingPD1Set = 0; static TickType_t lastMeas = 0; // Inter state that performs the steps to measure the resistor on the tip // Return 1 if a measurement is ongoing // We want to perform our startup measurements of the tip resistance until we detect one fitted - if (start || tipSenseResistancex10Ohms == 0) { - tipMeasurementOccuring = true; - if (lastMeas == 0) { - lastMeas = xTaskGetTickCount(); - setPlatePullup(true); - return; - } else if (xTaskGetTickCount() - lastMeas > (TICKS_100MS)) { - lastMeas = xTaskGetTickCount(); - // We are sensing the resistance - if (adcReadingPD1Set == 0) { - // We will record the reading for PD1 being set - adcReadingPD1Set = getADC(3); - setPlatePullup(false); - return; - } else { - // We have taken reading one - uint16_t adcReadingPD1Cleared = getADC(3); - uint32_t a = ((int)adcReadingPD1Set - (int)adcReadingPD1Cleared); - a *= 10000; - uint32_t b = ((int)adcReadingPD1Cleared + (32768 - (int)adcReadingPD1Set)); - if (b) { - tipSenseResistancex10Ohms = a / b; - } else { - tipSenseResistancex10Ohms = adcReadingPD1Set = lastMeas = 0; - } - if (tipSenseResistancex10Ohms > 1100 || tipSenseResistancex10Ohms < 900) { - tipSenseResistancex10Ohms = 0; // out of range - adcReadingPD1Set = 0; - lastMeas = 0; - return; - } - } - } + + // Step 1; if not setup, we turn on pullup and then wait + if (tipMeasurementOccuring == false && (start || tipSenseResistancex10Ohms == 0 || lastMeas == 0)) { + tipMeasurementOccuring = true; + tipSenseResistancex10Ohms = 0; + lastMeas = xTaskGetTickCount(); + adcReadingPD1Set = 0; + setPlatePullup(true); + return; + } + + // Wait 100ms for settle time + if ((xTaskGetTickCount() - lastMeas) < (TICKS_100MS)) { + return; + } + + lastMeas = xTaskGetTickCount(); + // We are sensing the resistance + if (adcReadingPD1Set == 0) { + // We will record the reading for PD1 being set + adcReadingPD1Set = getADC(3); + setPlatePullup(false); + return; + } + // Taking reading two + uint16_t adcReadingPD1Cleared = getADC(3); + uint32_t a = ((int)adcReadingPD1Set - (int)adcReadingPD1Cleared); + a *= 10000; + uint32_t b = ((int)adcReadingPD1Cleared + (32768 - (int)adcReadingPD1Set)); + if (b) { + tipSenseResistancex10Ohms = a / b; + } else { + tipSenseResistancex10Ohms = adcReadingPD1Set = lastMeas = 0; + } + if (tipSenseResistancex10Ohms > 1100 || tipSenseResistancex10Ohms < 900) { + tipSenseResistancex10Ohms = 0; // out of range + adcReadingPD1Set = 0; + lastMeas = 0; + return; } tipMeasurementOccuring = false; } bool isTipDisconnected() { + static bool lastDisconnectedState = false; // For the MHP30 we want to include a little extra logic in here // As when the tip is first connected we want to measure the ~100 ohm resistor on the base of the tip // And likewise if its removed we want to clear that measurement @@ -402,22 +410,22 @@ bool isTipDisconnected() { * */ if (tipMeasurementOccuring) { performTipMeasurementStep(false); - return false; // We fake no tip disconnection during the measurement cycle to mask it + return true; // We fake no tip disconnection during the measurement cycle to mask it } - bool tipDisconnected = getADC(2) > (4090 * 8); - // We have to handle here that this ^ will trip while measuring the gain resistor measurement - - if (tipDisconnected) { + // If we are too close to the top, most likely disconnected tip + bool tipDisconnected = getTipInstantTemperature() > (4090 * 8); + if (tipDisconnected == false && lastDisconnectedState == true) { // Tip is now disconnected performTipMeasurementStep(true); } + lastDisconnectedState = tipDisconnected; return tipDisconnected; } uint8_t preStartChecks() { performTipMeasurementStep(false); - return tipMeasurementOccuring; + return tipMeasurementOccuring ? 1 : 0; } void setBuzzer(bool on) { if (on) { From 5e778b4aaa181f49b23658f01f6aa14b85bb0214 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 7 Jun 2022 21:46:28 +1000 Subject: [PATCH 08/10] Newer alpine for github CI --- .github/workflows/push.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9c1eb85b67..5720a00619 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -6,7 +6,7 @@ jobs: build: runs-on: ubuntu-20.04 container: - image: alpine:3.15 + image: alpine:3.16 strategy: matrix: model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30"] @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - + - name: Git ownership exception run: git config --global --add safe.directory /__w/IronOS/IronOS && git config --global safe.directory "$GITHUB_WORKSPACE" @@ -57,7 +57,7 @@ jobs: build_multi-lang: runs-on: ubuntu-20.04 container: - image: alpine:3.15 + image: alpine:3.16 strategy: matrix: model: ["Pinecil"] @@ -72,10 +72,10 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - + - name: Git ownership exception run: git config --global --add safe.directory /__w/IronOS/IronOS && git config --global safe.directory "$GITHUB_WORKSPACE" - + - name: build ${{ matrix.model }} run: cd source && make -j$(nproc) model="${{ matrix.model }}" firmware-multi_compressed_European firmware-multi_compressed_Bulgarian+Russian+Serbian+Ukrainian firmware-multi_Chinese+Japanese @@ -107,7 +107,7 @@ jobs: tests: runs-on: ubuntu-20.04 container: - image: alpine:3.15 + image: alpine:3.16 steps: - name: deps @@ -134,7 +134,7 @@ jobs: check_formatting: runs-on: ubuntu-20.04 container: - image: alpine:3.15 + image: alpine:3.16 steps: - name: deps From 261ad77c31dd96b1829762a47dcbeeda204fe802 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 7 Jun 2022 22:08:06 +1000 Subject: [PATCH 09/10] Bugfix: Exit on movement --- source/Core/Src/settingsGUI.cpp | 36 +++++++++++++++---------------- source/Core/Threads/GUIThread.cpp | 36 ++++++++++++++++--------------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/source/Core/Src/settingsGUI.cpp b/source/Core/Src/settingsGUI.cpp index adde30145c..0f44e6ee44 100644 --- a/source/Core/Src/settingsGUI.cpp +++ b/source/Core/Src/settingsGUI.cpp @@ -27,13 +27,13 @@ static void settings_displayQCInputV(void); #if POW_PD static void settings_displayPDNegTimeout(void); #endif -#ifndef NO_SLEEP_MODE static void settings_displaySensitivity(void); +static void settings_displayShutdownTime(void); static bool settings_showSleepOptions(void); +#ifndef NO_SLEEP_MODE static bool settings_setSleepTemp(void); static void settings_displaySleepTemp(void); static void settings_displaySleepTime(void); -static void settings_displayShutdownTime(void); #endif static bool settings_setTempF(void); static void settings_displayTempF(void); @@ -195,18 +195,18 @@ const menuitem solderingMenu[] = { {0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength} // end of menu marker. DO NOT REMOVE }; const menuitem PowerSavingMenu[] = { -/* - * Motion Sensitivity - * -Sleep Temp - * -Sleep Time - * -Shutdown Time - */ + /* + * Motion Sensitivity + * -Sleep Temp + * -Sleep Time + * -Shutdown Time + */ + {SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, settings_displaySensitivity, nullptr, SettingsOptions::Sensitivity}, /* Motion Sensitivity*/ #ifndef NO_SLEEP_MODE - {SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, settings_displaySensitivity, nullptr, SettingsOptions::Sensitivity}, /* Motion Sensitivity*/ {SETTINGS_DESC(SettingsItemIndex::SleepTemperature), settings_setSleepTemp, settings_displaySleepTemp, settings_showSleepOptions, SettingsOptions::SettingsOptionsLength}, /*Sleep Temp*/ {SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, settings_displaySleepTime, settings_showSleepOptions, SettingsOptions::SleepTime}, /*Sleep Time*/ - {SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, settings_displayShutdownTime, settings_showSleepOptions, SettingsOptions::ShutdownTime}, /*Shutdown Time*/ #endif + {SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, settings_displayShutdownTime, settings_showSleepOptions, SettingsOptions::ShutdownTime}, /*Shutdown Time*/ #ifdef HALL_SENSOR {SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, settings_displayHallEffect, settings_showHallEffect, SettingsOptions::HallEffectSensitivity}, /* HallEffect Sensitivity*/ #endif @@ -362,8 +362,6 @@ static void settings_displayPDNegTimeout(void) { } #endif -#ifndef NO_SLEEP_MODE - static void settings_displayShutdownTime(void) { printShortDescription(SettingsItemIndex::ShutdownTimeout, 5); if (getSettingValue(SettingsOptions::ShutdownTime) == 0) { @@ -374,6 +372,14 @@ static void settings_displayShutdownTime(void) { } } +static void settings_displaySensitivity(void) { + printShortDescription(SettingsItemIndex::MotionSensitivity, 7); + OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false); +} +static bool settings_showSleepOptions(void) { return getSettingValue(SettingsOptions::Sensitivity) > 0; } + +#ifndef NO_SLEEP_MODE + static bool settings_setSleepTemp(void) { // If in C, 10 deg, if in F 20 deg uint16_t temp = getSettingValue(SettingsOptions::SleepTemp); @@ -392,12 +398,6 @@ static bool settings_setSleepTemp(void) { } } -static void settings_displaySensitivity(void) { - printShortDescription(SettingsItemIndex::MotionSensitivity, 7); - OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false); -} - -static bool settings_showSleepOptions(void) { return getSettingValue(SettingsOptions::Sensitivity) > 0; } static void settings_displaySleepTemp(void) { printShortDescription(SettingsItemIndex::SleepTemperature, 5); OLED::printNumber(getSettingValue(SettingsOptions::SleepTemp), 3, FontStyle::LARGE); diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 544aa17222..ea9f3fddb5 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -350,28 +350,11 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) { OLED::refresh(); GUIDelay(); -#ifdef ACCEL_EXITS_ON_MOVEMENT - // If the accel works in reverse where movement will cause exiting the soldering mode - if (getSettingValue(SettingsOptions::Sensitivity)) { - if (lastMovementTime) { - if (lastMovementTime > TICKS_SECOND * 10) { - // If we have moved recently; in the last second - // Then exit soldering mode - - if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND)) { - currentTempTargetDegC = 0; - return 1; - } - } - } - } -#else if (!shouldBeSleeping(autoStarted)) { return 0; } -#endif if (shouldShutdown()) { // shutdown currentTempTargetDegC = 0; @@ -645,6 +628,25 @@ static void gui_solderingMode(uint8_t jumpToSleep) { } #endif +#ifdef ACCEL_EXITS_ON_MOVEMENT + // If the accel works in reverse where movement will cause exiting the soldering mode + if (getSettingValue(SettingsOptions::Sensitivity)) { + if (lastMovementTime) { + if (lastMovementTime > TICKS_SECOND * 10) { + // If we have moved recently; in the last second + // Then exit soldering mode + + if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND)) { + currentTempTargetDegC = 0; + return; + } + } + } + } +#endif +#ifdef NO_SLEEP_MODE + +#endif if (shouldBeSleeping()) { if (gui_SolderingSleepingMode(false, false)) { return; // If the function returns non-0 then exit From 898f4036550628875f668b4b052e922530d3596d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 7 Jun 2022 22:19:54 +1000 Subject: [PATCH 10/10] Feature: Shutdown timeout for MHP30 --- source/Core/Inc/main.hpp | 6 +++--- source/Core/Threads/GUIThread.cpp | 8 +++++++- source/Core/Threads/PIDThread.cpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/Core/Inc/main.hpp b/source/Core/Inc/main.hpp index 42ee98e0f7..c2216408fb 100644 --- a/source/Core/Inc/main.hpp +++ b/source/Core/Inc/main.hpp @@ -3,9 +3,9 @@ #include "OLED.hpp" #include "Setup.h" -extern uint32_t currentTempTargetDegC; -extern bool settingsWereReset; -extern bool usb_pd_available; +extern volatile uint32_t currentTempTargetDegC; +extern bool settingsWereReset; +extern bool usb_pd_available; #ifdef __cplusplus extern "C" { #endif diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index ea9f3fddb5..be7ee8641f 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -29,7 +29,7 @@ extern "C" { #include "pd.h" #endif // File local variables -extern uint32_t currentTempTargetDegC; + extern TickType_t lastMovementTime; extern bool heaterThermalRunaway; extern osThreadId GUITaskHandle; @@ -645,7 +645,13 @@ static void gui_solderingMode(uint8_t jumpToSleep) { } #endif #ifdef NO_SLEEP_MODE + // No sleep mode, but still want shutdown timeout + if (shouldShutdown()) { + // shutdown + currentTempTargetDegC = 0; + return; // we want to exit soldering mode + } #endif if (shouldBeSleeping()) { if (gui_SolderingSleepingMode(false, false)) { diff --git a/source/Core/Threads/PIDThread.cpp b/source/Core/Threads/PIDThread.cpp index 161fa3658f..7df72fc58a 100644 --- a/source/Core/Threads/PIDThread.cpp +++ b/source/Core/Threads/PIDThread.cpp @@ -17,7 +17,7 @@ static TickType_t powerPulseWaitUnit = 25 * TICKS_100MS; // 2.5 s static TickType_t powerPulseDurationUnit = (5 * TICKS_100MS) / 2; // 250 ms TaskHandle_t pidTaskNotification = NULL; -uint32_t currentTempTargetDegC = 0; // Current temperature target in C +volatile uint32_t currentTempTargetDegC = 0; // Current temperature target in C int32_t powerSupplyWattageLimit = 0; bool heaterThermalRunaway = false;