From e2eea84e36ac4ebb0e4baea86331e9fff73dd9e6 Mon Sep 17 00:00:00 2001 From: discip <53649486+discip@users.noreply.github.com> Date: Tue, 14 Jun 2022 07:12:20 +0200 Subject: [PATCH 01/11] removed some more redundant entries (#1312) --- source/Core/BSP/Miniware/configuration.h | 438 +++++++++++------------ 1 file changed, 205 insertions(+), 233 deletions(-) diff --git a/source/Core/BSP/Miniware/configuration.h b/source/Core/BSP/Miniware/configuration.h index 867810aaf7..f33952a013 100644 --- a/source/Core/BSP/Miniware/configuration.h +++ b/source/Core/BSP/Miniware/configuration.h @@ -1,236 +1,208 @@ #ifndef CONFIGURATION_H_ -#define CONFIGURATION_H_ -#include "Settings.h" -#include -/** - * Configuration.h - * Define here your default pre settings for TS80(P) or TS100 - * - */ - -//=========================================================================== -//============================= Default Settings ============================ -//=========================================================================== -/** - * Default soldering temp is 320.0 C - * Temperature the iron sleeps at - default 150.0 C - */ - -#define SLEEP_TEMP 150 // Default sleep temperature -#define BOOST_TEMP 420 // Default boost temp. -#define BOOST_MODE_ENABLED 1 // 0: Disable 1: Enable - -/** - * Blink the temperature on the cooling screen when its > 50C - */ -#define COOLING_TEMP_BLINK 0 // 0: Disable 1: Enable - -/** - * How many seconds/minutes we wait until going to sleep/shutdown. - * Values -> SLEEP_TIME * 10; i.e. 5*10 = 50 Seconds! - */ -#define SLEEP_TIME 5 // x10 Seconds -#define SHUTDOWN_TIME 10 // Minutes - -/** - * Auto start off for safety. - * Pissible values are: - * 0 - none - * 1 - Soldering Temperature - * 2 - Sleep Temperature - * 3 - Sleep Off Temperature - */ -#define AUTO_START_MODE 0 // Default to none - -/** - * Locking Mode - * When in soldering mode a long press on both keys toggle the lock of the buttons - * Possible values are: - * 0 - Desactivated - * 1 - Lock except boost - * 2 - Full lock - */ -#define LOCKING_MODE 0 // Default to desactivated for safety - -/** - * OLED Orientation - * - */ -#define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic -#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change - -/** - * Temp change settings - */ -#define TEMP_CHANGE_SHORT_STEP 1 // Default temp change short step +1 -#define TEMP_CHANGE_LONG_STEP 10 // Default temp change long step +10 -#define TEMP_CHANGE_SHORT_STEP_MAX 50 // Temp change short step MAX value -#define TEMP_CHANGE_LONG_STEP_MAX 90 // Temp change long step MAX value - -/* Power pulse for keeping power banks awake*/ -#define POWER_PULSE_INCREMENT 1 -#define POWER_PULSE_MAX 100 // x10 max watts -#define POWER_PULSE_WAIT_MAX 9 // 9*2.5s = 22.5 seconds -#define POWER_PULSE_DURATION_MAX 9 // 9*250ms = 2.25 seconds - -#ifdef MODEL_TS100 -#define POWER_PULSE_DEFAULT 0 -#else -#define POWER_PULSE_DEFAULT 5 -#endif -#define POWER_PULSE_WAIT_DEFAULT 4 // Default rate of the power pulse: 4*2500 = 10000 ms = 10 s -#define POWER_PULSE_DURATION_DEFAULT 1 // Default duration of the power pulse: 1*250 = 250 ms - -/** - * OLED Orientation Sensitivity on Automatic mode! - * Motion Sensitivity <0=Off 1=Least Sensitive 9=Most Sensitive> - */ -#define SENSITIVITY 7 // Default 7 - -/** - * Detailed soldering screen - * Detailed idle screen (off for first time users) - */ -#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 10 - -#define CUT_OUT_SETTING 0 // default to no cut-off voltage -#define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33)) -#define TEMPERATURE_INF 0 // default to 0 -#define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow -#define ANIMATION_LOOP 1 // 0: off 1: on -#define ANIMATION_SPEED settingOffSpeed_t::MEDIUM - -#define OP_AMP_Rf_TS100 750 * 1000 // 750 Kilo-ohms -> From schematic, R1 -#define OP_AMP_Rin_TS100 2370 // 2.37 Kilo-ohms -> From schematic, R2 - -#define OP_AMP_GAIN_STAGE_TS100 (1 + (OP_AMP_Rf_TS100 / OP_AMP_Rin_TS100)) - -#define OP_AMP_Rf_TS80 180 * 1000 // 180 Kilo-ohms -> From schematic, R6 -#define OP_AMP_Rin_TS80 2000 // 2.0 Kilo-ohms -> From schematic, R3 - -#define OP_AMP_GAIN_STAGE_TS80 (1 + (OP_AMP_Rf_TS80 / OP_AMP_Rin_TS80)) - -// Deriving the Voltage div: -// Vin_max = (3.3*(r1+r2))/(r2) -// vdiv = (32768*4)/(vin_max*10) - -#if defined(MODEL_TS100) + defined(MODEL_TS80) + defined(MODEL_TS80P) > 1 -#error "Multiple models defined!" -#elif defined(MODEL_TS100) + defined(MODEL_TS80) + defined(MODEL_TS80P) == 0 -#error "No model defined!" -#endif - -// Miniware is swapping IMU's around a bit now, so we turn them all on - -#define ACCEL_MMA -#define ACCEL_LIS -#define ACCEL_SC7 -#define ACCEL_MSA -#define ACCEL_BMA - -#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 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 POW_PD 0 - -#define TEMP_TMP36 -#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 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 POW_QC -#define POW_PD 0 -#define TEMP_TMP36 -#define LIS_ORI_FLIP -#define OLED_FLIP -#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 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 POW_PD 1 -#define POW_QC 1 -#define TEMP_NTC -#define I2C_SOFT -#define LIS_ORI_FLIP -#define SC7_ORI_FLIP -#define OLED_FLIP -#endif - -#ifdef MODEL_TS100 -#define HARDWARE_MAX_WATTAGE_X10 750 -#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 ts100 tips -#endif - -#ifdef MODEL_TS80 -#define HARDWARE_MAX_WATTAGE_X10 180 -#define TIP_THERMAL_MASS 40 -#define TIP_RESISTANCE 45 // x10 ohms, 4.5 typical for ts80 tips -#endif - -#ifdef MODEL_TS80P -#define HARDWARE_MAX_WATTAGE_X10 300 -#define TIP_THERMAL_MASS 40 -#define TIP_RESISTANCE 45 // x10 ohms, 4.5 typical for ts80 tips -#endif + #define CONFIGURATION_H_ + #include "Settings.h" + #include + /** + * Configuration.h + * Define here your default pre settings for TS80(P) or TS100 + * + */ + + //=========================================================================== + //============================= Default Settings ============================ + //=========================================================================== + /** + * Default soldering temp is 320.0 C + * Temperature the iron sleeps at - default 150.0 C + */ + + #define SLEEP_TEMP 150 // Default sleep temperature + #define BOOST_TEMP 420 // Default boost temp. + #define BOOST_MODE_ENABLED 1 // 0: Disable 1: Enable + + /** + * Blink the temperature on the cooling screen when its > 50C + */ + #define COOLING_TEMP_BLINK 0 // 0: Disable 1: Enable + + /** + * How many seconds/minutes we wait until going to sleep/shutdown. + * Values -> SLEEP_TIME * 10; i.e. 5*10 = 50 Seconds! + */ + #define SLEEP_TIME 5 // x10 Seconds + #define SHUTDOWN_TIME 10 // Minutes + + /** + * Auto start off for safety. + * Pissible values are: + * 0 - none + * 1 - Soldering Temperature + * 2 - Sleep Temperature + * 3 - Sleep Off Temperature + */ + #define AUTO_START_MODE 0 // Default to none + + /** + * Locking Mode + * When in soldering mode a long press on both keys toggle the lock of the buttons + * Possible values are: + * 0 - Desactivated + * 1 - Lock except boost + * 2 - Full lock + */ + #define LOCKING_MODE 0 // Default to desactivated for safety + + /** + * OLED Orientation + * + */ + #define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic + #define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change + + /** + * Temp change settings + */ + #define TEMP_CHANGE_SHORT_STEP 1 // Default temp change short step +1 + #define TEMP_CHANGE_LONG_STEP 10 // Default temp change long step +10 + #define TEMP_CHANGE_SHORT_STEP_MAX 50 // Temp change short step MAX value + #define TEMP_CHANGE_LONG_STEP_MAX 90 // Temp change long step MAX value + + /* Power pulse for keeping power banks awake*/ + #define POWER_PULSE_INCREMENT 1 + #define POWER_PULSE_MAX 100 // x10 max watts + #define POWER_PULSE_WAIT_MAX 9 // 9*2.5s = 22.5 seconds + #define POWER_PULSE_DURATION_MAX 9 // 9*250ms = 2.25 seconds + + #ifdef MODEL_TS100 + #define POWER_PULSE_DEFAULT 0 + #else + #define POWER_PULSE_DEFAULT 5 + #endif + #define POWER_PULSE_WAIT_DEFAULT 4 // Default rate of the power pulse: 4*2500 = 10000 ms = 10 s + #define POWER_PULSE_DURATION_DEFAULT 1 // Default duration of the power pulse: 1*250 = 250 ms + + /** + * OLED Orientation Sensitivity on Automatic mode! + * Motion Sensitivity <0=Off 1=Least Sensitive 9=Most Sensitive> + */ + #define SENSITIVITY 7 // Default 7 + + /** + * Detailed soldering screen + * Detailed idle screen (off for first time users) + */ + #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 10 + + #define CUT_OUT_SETTING 0 // default to no cut-off voltage + #define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33)) + #define TEMPERATURE_INF 0 // default to 0 + #define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow + #define ANIMATION_LOOP 1 // 0: off 1: on + #define ANIMATION_SPEED settingOffSpeed_t::MEDIUM + + #define OP_AMP_Rf_TS100 750 * 1000 // 750 Kilo-ohms -> From schematic, R1 + #define OP_AMP_Rin_TS100 2370 // 2.37 Kilo-ohms -> From schematic, R2 + + #define OP_AMP_GAIN_STAGE_TS100 (1 + (OP_AMP_Rf_TS100 / OP_AMP_Rin_TS100)) + + #define OP_AMP_Rf_TS80 180 * 1000 // 180 Kilo-ohms -> From schematic, R6 + #define OP_AMP_Rin_TS80 2000 // 2.0 Kilo-ohms -> From schematic, R3 + + #define OP_AMP_GAIN_STAGE_TS80 (1 + (OP_AMP_Rf_TS80 / OP_AMP_Rin_TS80)) + + // Deriving the Voltage div: + // Vin_max = (3.3*(r1+r2))/(r2) + // vdiv = (32768*4)/(vin_max*10) + + #if defined(MODEL_TS100) + defined(MODEL_TS80) + defined(MODEL_TS80P) > 1 + #error "Multiple models defined!" + #elif defined(MODEL_TS100) + defined(MODEL_TS80) + defined(MODEL_TS80P) == 0 + #error "No model defined!" + #endif + + // Miniware is swapping IMU's around a bit now, so we turn them all on + + #define ACCEL_MMA + #define ACCEL_LIS + #define ACCEL_SC7 + #define ACCEL_MSA + #define ACCEL_BMA + + #define MIN_CALIBRATION_OFFSET 100 // Min value for calibration + #define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C + #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 + + #ifdef MODEL_TS100 + #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 HARDWARE_MAX_WATTAGE_X10 750 + #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 ts100 tips + + #define POW_DC + #define POW_PD 0 + #define TEMP_TMP36 + #endif + + #if defined(MODEL_TS80) + defined(MODEL_TS80P) > 0 + #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 TIP_THERMAL_MASS 40 + #define TIP_RESISTANCE 45 // x10 ohms, 4.5 typical for ts80 tips + + #define LIS_ORI_FLIP + #define OLED_FLIP + #endif + + #ifdef MODEL_TS80 + #define VOLTAGE_DIV 780 // Default divider from schematic + #define CALIBRATION_OFFSET 900 // the adc offset in uV + #define PID_POWER_LIMIT 24 // Sets the max pwm power limit + #define POWER_LIMIT 24 // 24 watts default power limit + + #define HARDWARE_MAX_WATTAGE_X10 180 + + #define POW_QC + #define POW_PD 0 + #define TEMP_TMP36 + #endif + + #ifdef MODEL_TS80P + #define VOLTAGE_DIV 650 // Default for TS80P with slightly different resistors + #define CALIBRATION_OFFSET 1500 // the adc offset in uV + #define PID_POWER_LIMIT 35 // Sets the max pwm power limit + #define POWER_LIMIT 30 // 30 watts default power limit + + #define HARDWARE_MAX_WATTAGE_X10 300 + + #define POW_PD 1 + #define POW_QC 1 + #define TEMP_NTC + #define I2C_SOFT + #define SC7_ORI_FLIP + #endif #endif -#define FLASH_LOGOADDR (0x08000000 + (62 * 1024)) \ No newline at end of file +#define FLASH_LOGOADDR (0x08000000 + (62 * 1024)) From f5cb42c9d74e4ce4646fa9e0496411b72eb4c48f Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Thu, 16 Jun 2022 20:21:30 +1000 Subject: [PATCH 02/11] Infinite logo (#1309) * Check for button timeout of infinite * Dedupe * Alpine bump --- .github/workflows/push.yml | 14 +++++++------- Dockerfile | 2 +- source/Core/Drivers/BootLogo.cpp | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 11 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 diff --git a/Dockerfile b/Dockerfile index 4622f33b8b..b1351a5a06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.15 +FROM alpine:3.16 LABEL maintainer="Ben V. Brown " WORKDIR /build diff --git a/source/Core/Drivers/BootLogo.cpp b/source/Core/Drivers/BootLogo.cpp index 37b38eba50..5113fadbd1 100644 --- a/source/Core/Drivers/BootLogo.cpp +++ b/source/Core/Drivers/BootLogo.cpp @@ -4,6 +4,15 @@ #include "OLED.hpp" #include "cmsis_os.h" #define LOGO_PAGE_LENGTH 1024 + +void delay() { + if (getSettingValue(SettingsOptions::LOGOTime) == 5) { + waitForButtonPress(); + } else { + waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime)); + } +} + void BootLogo::handleShowingLogo(const uint8_t *ptrLogoArea) { // Read the first few bytes and figure out what format we are looking at if (OLD_LOGO_HEADER_VALUE == *(reinterpret_cast(ptrLogoArea))) { @@ -21,7 +30,7 @@ void BootLogo::showOldFormat(const uint8_t *ptrLogoArea) { OLED::refresh(); // Delay here until button is pressed or its been the amount of seconds set by the user - waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime)); + delay(); } void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) { @@ -46,9 +55,9 @@ void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) { osDelay(interFrameDelay * 5); } // 1024 less the header type byte and the inter-frame-delay - if (getSettingValue(SettingsOptions::LOGOTime) < 5 && (position == 1022 || len == 0)) { + if (getSettingValue(SettingsOptions::LOGOTime) > 0 && (position == 1022 || len == 0)) { // Delay here until button is pressed or its been the amount of seconds set by the user - waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime)); + delay(); return; } } while (buttons == BUTTON_NONE); From 3bb1b7bc323ab9caddba2ef6e259634b36517388 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Thu, 16 Jun 2022 20:21:46 +1000 Subject: [PATCH 03/11] Startup behaviour fixes (#1306) * Reduce PPS max to 20V to avoid instability Some PSU's cant actually run at 21V * Creating a rough draft of a "pre start check" concept * Newer alpine * Cleaning up MHP detection * Cleanup comments * PID: Run prestart based on ADC IRQ rather than times * MHP30: Far better startup for detecting tip gain * Newer alpine for github CI --- Dockerfile | 2 + source/Core/BSP/BSP.h | 4 + source/Core/BSP/MHP30/BSP.cpp | 134 ++++++++++++++----------- source/Core/BSP/MHP30/ThermoModel.cpp | 3 +- source/Core/BSP/Miniware/BSP.cpp | 3 +- source/Core/BSP/Pine64/BSP.cpp | 2 + source/Core/BSP/Pine64/configuration.h | 2 +- source/Core/Threads/GUIThread.cpp | 8 +- source/Core/Threads/PIDThread.cpp | 13 ++- 9 files changed, 98 insertions(+), 73 deletions(-) diff --git a/Dockerfile b/Dockerfile index b1351a5a06..d420b12bee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 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..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,69 +351,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; +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 + + // 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 /* * plate_sensor_res = ((adc5_value_PD1_set - adc5_value_PD1_cleared) / (adc5_value_PD1_cleared + 4096 - adc5_value_PD1_set)) * 1000.0; * */ - - 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; + if (tipMeasurementOccuring) { + performTipMeasurementStep(false); + return true; // We fake no tip disconnection during the measurement cycle to mask it } - if (tipDisconnected != lastTipDisconnectedState) { - if (tipDisconnected) { - // Tip is now disconnected - tipSenseResistancex10Ohms = 0; // zero out the resistance - adcReadingPD1Set = 0; - lastMeas = 0; - } - 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 - } + // 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 ? 1 : 0; +} void setBuzzer(bool on) { if (on) { htim3.Instance->CCR2 = 128; 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/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/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 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; diff --git a/source/Core/Threads/PIDThread.cpp b/source/Core/Threads/PIDThread.cpp index 4c56372cd0..161fa3658f 100644 --- a/source/Core/Threads/PIDThread.cpp +++ b/source/Core/Threads/PIDThread.cpp @@ -39,21 +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); } + + 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 165a9952c2766718d18bff9d836e2b3f58e4368d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Thu, 16 Jun 2022 20:28:49 +1000 Subject: [PATCH 04/11] MHP30: Shutdown settings (#1307) * Reduce PPS max to 20V to avoid instability Some PSU's cant actually run at 21V * Creating a rough draft of a "pre start check" concept * Newer alpine * Cleaning up MHP detection * Cleanup comments * PID: Run prestart based on ADC IRQ rather than times * MHP30: Far better startup for detecting tip gain * Newer alpine for github CI * Bugfix: Exit on movement * Feature: Shutdown timeout for MHP30 --- source/Core/Inc/main.hpp | 6 ++--- source/Core/Src/settingsGUI.cpp | 36 ++++++++++++------------- source/Core/Threads/GUIThread.cpp | 44 ++++++++++++++++++------------- source/Core/Threads/PIDThread.cpp | 2 +- 4 files changed, 48 insertions(+), 40 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/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..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; @@ -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,31 @@ 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 + // 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)) { return; // If the function returns non-0 then exit 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; From 078b8f5626aae409190c4748588dd5f018f01e7c Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Thu, 16 Jun 2022 21:39:53 +1000 Subject: [PATCH 05/11] DeviceID (#1314) * Ability to print hex * Add device ID getter * Refactor debug menu * No longer need patch * Update make_translation.py * Fix typo * Fix hex drawing --- Translations/make_translation.py | 26 +++++++-- source/Core/BSP/BSP.h | 3 + source/Core/BSP/MHP30/BSP.cpp | 4 ++ source/Core/BSP/Miniware/BSP.cpp | 8 ++- .../STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h | 3 + .../STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c | 18 ++++++ source/Core/BSP/Pine64/BSP.cpp | 3 +- source/Core/Drivers/OLED.cpp | 7 +++ source/Core/Drivers/OLED.hpp | 5 +- source/Core/Threads/GUIThread.cpp | 55 +++++++++++-------- source/Makefile | 8 +-- source/patch.specs | 2 - 12 files changed, 104 insertions(+), 38 deletions(-) delete mode 100644 source/patch.specs diff --git a/Translations/make_translation.py b/Translations/make_translation.py index c2c615904f..5c5478ec14 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -120,9 +120,6 @@ def get_constants(build_version: str) -> List[Tuple[str, str]]: def get_debug_menu() -> List[str]: return [ datetime.today().strftime("%d-%m-%y"), - "HW G ", - "HW M ", - "HW P ", "Time ", "Move ", "RTip ", @@ -131,7 +128,11 @@ def get_debug_menu() -> List[str]: "Vin ", "ACC ", "PWR ", + "ID ", "Max ", + "HW G ", + "HW M ", + "HW P ", "Hall ", ] @@ -429,7 +430,24 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer def get_forced_first_symbols() -> List[str]: - forced_first_symbols = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + forced_first_symbols = [ + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "a", + "b", + "c", + "d", + "e", + "f", + ] return forced_first_symbols diff --git a/source/Core/BSP/BSP.h b/source/Core/BSP/BSP.h index 6060f5f0e6..dd41bc7f9e 100644 --- a/source/Core/BSP/BSP.h +++ b/source/Core/BSP/BSP.h @@ -74,6 +74,9 @@ void log_system_state(int32_t PWMWattsx10); // Returns true if the tip is disconnected bool isTipDisconnected(); +// Return hardware unique ID if possible +uint64_t getDeviceID(); + // Status LED controls enum StatusLED { diff --git a/source/Core/BSP/MHP30/BSP.cpp b/source/Core/BSP/MHP30/BSP.cpp index c1feab5ca3..32c6ffb472 100644 --- a/source/Core/BSP/MHP30/BSP.cpp +++ b/source/Core/BSP/MHP30/BSP.cpp @@ -471,3 +471,7 @@ void setStatusLED(const enum StatusLED state) { setBuzzer(false); } } +uint64_t getDeviceID() { + // + return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32); +} \ No newline at end of file diff --git a/source/Core/BSP/Miniware/BSP.cpp b/source/Core/BSP/Miniware/BSP.cpp index d40a7e170c..2e86af224e 100644 --- a/source/Core/BSP/Miniware/BSP.cpp +++ b/source/Core/BSP/Miniware/BSP.cpp @@ -282,5 +282,9 @@ bool isTipDisconnected() { return tipTemp > tipDisconnectedThres; } -void setStatusLED(const enum StatusLED state) {} -uint8_t preStartChecks() { return 0; } \ No newline at end of file +void setStatusLED(const enum StatusLED state) {} +uint8_t preStartChecks() { return 0; } +uint64_t getDeviceID() { + // + return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32); +} diff --git a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h index 2bb753ce62..2cd99b274f 100644 --- a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h +++ b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h @@ -310,6 +310,9 @@ void HAL_ResumeTick(void); uint32_t HAL_GetHalVersion(void); uint32_t HAL_GetREVID(void); uint32_t HAL_GetDEVID(void); +uint32_t HAL_GetUIDw0(void); +uint32_t HAL_GetUIDw1(void); +uint32_t HAL_GetUIDw2(void); void HAL_DBGMCU_EnableDBGSleepMode(void); void HAL_DBGMCU_DisableDBGSleepMode(void); void HAL_DBGMCU_EnableDBGStopMode(void); diff --git a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c index 4e8304d17e..cb32ffdf1c 100644 --- a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c +++ b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c @@ -513,6 +513,24 @@ void HAL_GetUID(uint32_t *UID) { UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); } +/** + * @brief Returns first word of the unique device identifier (UID based on 96 bits) + * @retval Device identifier + */ +uint32_t HAL_GetUIDw0(void) { return (READ_REG(*((uint32_t *)UID_BASE))); } + +/** + * @brief Returns second word of the unique device identifier (UID based on 96 bits) + * @retval Device identifier + */ +uint32_t HAL_GetUIDw1(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 4U)))); } + +/** + * @brief Returns third word of the unique device identifier (UID based on 96 bits) + * @retval Device identifier + */ +uint32_t HAL_GetUIDw2(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 8U)))); } + /** * @} */ diff --git a/source/Core/BSP/Pine64/BSP.cpp b/source/Core/BSP/Pine64/BSP.cpp index 2c7de076fc..3b8df2eb00 100644 --- a/source/Core/BSP/Pine64/BSP.cpp +++ b/source/Core/BSP/Pine64/BSP.cpp @@ -91,4 +91,5 @@ bool isTipDisconnected() { void setStatusLED(const enum StatusLED state) {} -uint8_t preStartChecks() { return 0; } \ No newline at end of file +uint8_t preStartChecks() { return 0; } +uint64_t getDeviceID() { return dbg_id_get(); } diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 260af60747..ab436e0e78 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -423,6 +423,13 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) { } } } +void OLED::drawHex(uint32_t x, FontStyle fontStyle) { + // print number to hex + for (uint_fast8_t i = 0; i < 8; i++) { + uint16_t value = (x >> (4 * (7 - i))) & 0b1111; + drawChar(value + 2, fontStyle); + } +} // maximum places is 5 void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) { char buffer[7] = {0}; diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index ee322815f5..0d6f790c55 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -89,6 +89,7 @@ class OLED { // Draws a checkbox static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); } static void debugNumber(int32_t val, FontStyle fontStyle); + static void drawHex(uint32_t x, FontStyle fontStyle); static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset @@ -104,8 +105,8 @@ class OLED { private: static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location static void setFramebuffer(uint8_t *buffer); - static uint8_t * firstStripPtr; // Pointers to the strips to allow for buffer having extra content - static uint8_t * secondStripPtr; // Pointers to the strips + static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content + static uint8_t *secondStripPtr; // Pointers to the strips static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM) static bool initDone; static DisplayState displayState; diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index be7ee8641f..d0a863fc2e 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -691,46 +691,34 @@ void showDebugMenu(void) { case 0: // Just prints date break; case 1: - // High water mark for GUI - OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL); - break; - case 2: - // High water mark for the Movement task - OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL); - break; - case 3: - // High water mark for the PID task - OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL); - break; - case 4: // system up time stamp OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL); break; - case 5: + case 2: // Movement time stamp OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL); break; - case 6: + case 3: // Raw Tip { OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); } break; - case 7: + case 4: // Temp in C OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL); break; - case 8: + case 5: // Handle Temp OLED::printNumber(getHandleTemperature(0), 6, FontStyle::SMALL); break; - case 9: + case 6: // Voltage input printVoltage(); break; - case 10: + case 7: // Print ACC type OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL); break; - case 11: + case 8: // Power negotiation status { int sourceNumber = 0; @@ -766,12 +754,32 @@ void showDebugMenu(void) { OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL); } break; - case 12: + case 9: + // Print device ID Numbers + { + uint64_t id = getDeviceID(); + OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL); + OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL); + } + break; + case 10: // Max deg C limit OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL); break; -#ifdef HALL_SENSOR + case 11: + // High water mark for GUI + OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL); + break; + case 12: + // High water mark for the Movement task + OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL); + break; case 13: + // High water mark for the PID task + OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL); + break; +#ifdef HALL_SENSOR + case 14: // Print raw hall effect value if availabe, none if hall effect disabled. { int16_t hallEffectStrength = getRawHallEffect(); @@ -781,6 +789,7 @@ void showDebugMenu(void) { } break; #endif + default: break; } @@ -792,9 +801,9 @@ void showDebugMenu(void) { else if (b == BUTTON_F_SHORT) { screen++; #ifdef HALL_SENSOR - screen = screen % 14; + screen = screen % 15; #else - screen = screen % 13; + screen = screen % 14; #endif } GUIDelay(); diff --git a/source/Makefile b/source/Makefile index 0de50fbfc7..0d7a78a4fa 100644 --- a/source/Makefile +++ b/source/Makefile @@ -1,5 +1,5 @@ ifndef model -model:=TS100 +model:=Pinecil endif ALL_MINIWARE_MODELS=TS100 TS80 TS80P @@ -161,7 +161,7 @@ bootldr_size=0x0 CPUFLAGS= -march=rv32imac \ -mabi=ilp32 \ -mcmodel=medany -fsigned-char -fno-builtin -nostartfiles -DEV_LDFLAGS=-nostartfiles --specs=patch.specs +DEV_LDFLAGS=-nostartfiles DEV_AFLAGS= DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP DEV_CFLAGS= @@ -192,10 +192,10 @@ $(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \ $(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp') # code optimisation ------------------------------------------------------------ -OPTIM=-Os -flto -finline-small-functions -fshort-wchar -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common +OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common # global defines --------------------------------------------------------------- -GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U +GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar DEBUG=-g3 ifdef swd_enable diff --git a/source/patch.specs b/source/patch.specs deleted file mode 100644 index 312b1d49ef..0000000000 --- a/source/patch.specs +++ /dev/null @@ -1,2 +0,0 @@ -*link: -%(nano_link) %:replace-outfile(-lm_nano -lm) \ No newline at end of file From 1fe3210263351d204b82f1713d98c5e095477fb3 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Fri, 24 Jun 2022 10:33:23 +1000 Subject: [PATCH 06/11] Fix startup current pulse on some devices Always force power to 0 if <= to handle vin not yet stable at boot --- source/Core/Src/power.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Src/power.cpp b/source/Core/Src/power.cpp index e7037882b5..2fcc120b71 100644 --- a/source/Core/Src/power.cpp +++ b/source/Core/Src/power.cpp @@ -62,7 +62,7 @@ uint32_t availableW10(uint8_t sample) { } uint8_t X10WattsToPWM(int32_t x10Watts, uint8_t sample) { // Scale input x10Watts to the pwm range available - if (x10Watts < 0) { + if (x10Watts <= 0) { // keep the battery voltage updating the filter getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), sample); return 0; From 6c3666e29721a02ce2e5c903a977f8558640b6e5 Mon Sep 17 00:00:00 2001 From: d-rez Date: Fri, 24 Jun 2022 19:49:24 +1000 Subject: [PATCH 07/11] Update translation_PL.json (#1320) Corrected the definition of QCMaxVoltage which was previously mentioning power and wattage rather than QC voltage as it should --- Translations/translation_PL.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Translations/translation_PL.json b/Translations/translation_PL.json index 1ab7c5328d..de3734304e 100644 --- a/Translations/translation_PL.json +++ b/Translations/translation_PL.json @@ -132,8 +132,8 @@ "desc": "Szybkość przewijania tekstu" }, "QCMaxVoltage": { - "text2": ["Moc", "w W"], - "desc": "Moc używanego zasilacza w (W)" + "text2": ["QC", "napięcie"], + "desc": "Maksymalne napięcie, które lutownica będzie próbowała wynegocjować z ładowarką Quick Charge (V)" }, "PDNegTimeout": { "text2": ["Limit czasu", "PD"], From 0a69f5c9633032b0ca6e07450656c8351c00610e Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Wed, 29 Jun 2022 09:20:09 +1000 Subject: [PATCH 08/11] Adding features table (#1318) Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index e8b1bbdf63..c41f7b9871 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,15 @@ This project is considered feature complete for use as a soldering iron, _so ple _This firmware does **NOT** support the USB port while running for changing settings. This is done through the onscreen menu only. Logos are edited using the tool or python script and uploaded in DFU mode._ + +| Device | DC Supported | QC Supported | PD Supported | Reccomended | +|--------: |:------------: |:------------: |:------------: |:-----------: | +| MHP30 | N | N | Y | Y | +| Pinecil | Y | Y | Y | Y | +| TS100 | Y | N | N | N | +| TS80 | N | Y | N | N | +| TS80P | N | Y | Y | Y | + ## Getting Started To get started with IronOS firmware, please jump to [Getting Started Guide](Documentation/GettingStarted.md). From 81d679e468b0f68ad9da7c0df0818a7e221cfdb0 Mon Sep 17 00:00:00 2001 From: HanaO00 <17810985+HanaO00@users.noreply.github.com> Date: Fri, 1 Jul 2022 01:21:14 +0200 Subject: [PATCH 09/11] Update translation_FR.json (#1322) --- Translations/translation_FR.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Translations/translation_FR.json b/Translations/translation_FR.json index 37c7d0e38e..310bd703a6 100644 --- a/Translations/translation_FR.json +++ b/Translations/translation_FR.json @@ -80,8 +80,8 @@ "desc": "Délai avant mise en veille (s=secondes | m=minutes)" }, "ShutdownTimeout": { - "text2": ["Délai", "extinction"], - "desc": "Délai avant extinction (m=minutes)" + "text2": ["Délai", "arrêt"], + "desc": "Délai avant l'arrêt du fer à souder (m=minutes)" }, "MotionSensitivity": { "text2": ["Sensibilité", "au mouvement"], @@ -136,7 +136,7 @@ "desc": "Tension maximale désirée avec une alimentation QC" }, "PDNegTimeout": { - "text2": ["Délai", "expiration PD"], + "text2": ["Délai", "expir. PD"], "desc": "Délai de la negociation PD par étapes de 100ms pour la compatiblité avec certains chargeurs QC" }, "PowerLimit": { @@ -156,17 +156,17 @@ "desc": "Incrément de changement de température sur appui long" }, "PowerPulsePower": { - "text2": ["Puissance des", "impulsions"], + "text2": ["Puissance", "impulsions"], "desc": "Puissance des impulsions pour éviter la mise en veille des batteries (watts)" }, - "LockingMode": { - "text2": ["Verrouiller", "les boutons"], - "desc": "Pendant la soudure, appuyer sur les deux boutons pour les verrouiller (D=désactivé | B=boost seulement | V=verr. total)" - }, "HallEffSensitivity": { "text2": ["Sensibilité", "capteur effet hall"], "desc": "Sensibilité du capteur à effet Hall pour la mise en veille (0=désactivé | 1=peu sensible | ... | 9=très sensible)" }, + "LockingMode": { + "text2": ["Verrouiller", "les boutons"], + "desc": "Pendant la soudure, appuyer sur les deux boutons pour les verrouiller (D=désactivé | B=boost seulement | V=verr. total)" + }, "MinVolCell": { "text2": ["Tension", "minimale"], "desc": "Tension minimale autorisée par cellule (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)" @@ -193,15 +193,15 @@ }, "Brightness": { "text2": ["Luminosité", "de l'écran"], - "desc": "Ajuster le contraste/luminosité de l'écran OLED" + "desc": "Ajuster la luminosité de l'écran OLED" }, "ColourInversion": { "text2": ["Inverser", "les couleurs"], "desc": "Inverser les couleurs de l'écran OLED" }, "LOGOTime": { - "text2": ["Boot logo", "duration"], - "desc": "Sets the duration for the boot logo (s=seconds)" + "text2": ["Durée logo", "au démarrage"], + "desc": "Définit la durée d'affichage du logo au démarrage (s=secondes)" } } } From b5cb42740e4dfbf93ce5d6b6412a191667bc7ceb Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Sun, 3 Jul 2022 11:59:12 +1000 Subject: [PATCH 10/11] Update version.h --- source/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/version.h b/source/version.h index 2d4e10b1e4..54f6b508f0 100644 --- a/source/version.h +++ b/source/version.h @@ -4,4 +4,4 @@ * i.e.: BUILD_VERSION = 'Rel. v2.08' --> Will generated to: 'v2.08.1a2b3c4' */ -#define BUILD_VERSION "v2.18" +#define BUILD_VERSION "v2.19" From 8db0bbf4a5d6b48c995861d9bbbf4765968da525 Mon Sep 17 00:00:00 2001 From: discip <53649486+discip@users.noreply.github.com> Date: Wed, 6 Jul 2022 05:23:06 +0200 Subject: [PATCH 11/11] more obvious feature list (#1325) --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c41f7b9871..b319730d1a 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ _This firmware does **NOT** support the USB port while running for changing sett | Device | DC Supported | QC Supported | PD Supported | Reccomended | |--------: |:------------: |:------------: |:------------: |:-----------: | -| MHP30 | N | N | Y | Y | -| Pinecil | Y | Y | Y | Y | -| TS100 | Y | N | N | N | -| TS80 | N | Y | N | N | -| TS80P | N | Y | Y | Y | +| MHP30 | ❌ | ❌ | ✔️ | ✔️ | +| Pinecil | ✔️ | ✔️ | ✔️ | ✔️ | +| TS100 | ✔️ | ❌ | ❌ | ❌ | +| TS80 | ❌ | ✔️ | ❌ | ❌ | +| TS80P | ❌ | ✔️ | ✔️ | ✔️ | ## Getting Started