From adf86b3461b55e64084bf40513fecfcda009750e Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 9 Sep 2024 20:32:35 +1000 Subject: [PATCH] Start linking in manual tip resistance --- Env.yml | 1 - source/Core/BSP/Miniware/BSP.cpp | 13 ++++- source/Core/BSP/Pinecil/BSP.cpp | 8 ++- source/Core/BSP/Pinecilv2/BSP.cpp | 6 ++- source/Core/BSP/Pinecilv2/configuration.h | 2 + source/Core/BSP/Sequre/BSP.cpp | 6 ++- source/Core/Inc/Settings.h | 7 +-- source/Core/Src/Settings.cpp | 61 ++++++++++++++++++++++- source/Makefile | 2 +- 9 files changed, 94 insertions(+), 12 deletions(-) diff --git a/Env.yml b/Env.yml index 695cd122..16db291d 100644 --- a/Env.yml +++ b/Env.yml @@ -1,4 +1,3 @@ -version: "3" name: "ironos" services: builder: diff --git a/source/Core/BSP/Miniware/BSP.cpp b/source/Core/BSP/Miniware/BSP.cpp index d823263c..a78c74e5 100644 --- a/source/Core/BSP/Miniware/BSP.cpp +++ b/source/Core/BSP/Miniware/BSP.cpp @@ -382,9 +382,18 @@ uint8_t getTipResistanceX10() { #ifdef TIP_RESISTANCE_SENSE_Pin // Return tip resistance in x10 ohms // We can measure this using the op-amp - return lastTipResistance; + uint8_t user_selected_tip = getUserSelectedTipResistance(); + if (user_selected_tip == 0) { + return lastTipResistance; // Auto mode + } + return user_selected_tip; + #else - return TIP_RESISTANCE; + uint8_t user_selected_tip = getUserSelectedTipResistance(); + if (user_selected_tip == 0) { + return TIP_RESISTANCE; // Auto mode + } + return user_selected_tip; #endif } #ifdef TIP_RESISTANCE_SENSE_Pin diff --git a/source/Core/BSP/Pinecil/BSP.cpp b/source/Core/BSP/Pinecil/BSP.cpp index 56e96810..b3c86d6c 100644 --- a/source/Core/BSP/Pinecil/BSP.cpp +++ b/source/Core/BSP/Pinecil/BSP.cpp @@ -93,7 +93,13 @@ void setBuzzer(bool on) {} uint8_t preStartChecks() { return 1; } uint64_t getDeviceID() { return dbg_id_get(); } -uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } +uint8_t getTipResistanceX10() { + uint8_t user_selected_tip = getUserSelectedTipResistance(); + if (user_selected_tip == 0) { + return TIP_RESISTANCE; // Auto mode + } + return user_selected_tip; +} bool isTipShorted() { return false; } uint8_t preStartChecksDone() { return 1; } diff --git a/source/Core/BSP/Pinecilv2/BSP.cpp b/source/Core/BSP/Pinecilv2/BSP.cpp index e019407e..d86c650d 100644 --- a/source/Core/BSP/Pinecilv2/BSP.cpp +++ b/source/Core/BSP/Pinecilv2/BSP.cpp @@ -152,7 +152,11 @@ uint8_t tipResistanceReadingSlot = 0; uint8_t getTipResistanceX10() { // Return tip resistance in x10 ohms // We can measure this using the op-amp - return lastTipResistance; + uint8_t user_selected_tip = getUserSelectedTipResistance(); + if (user_selected_tip == 0) { + return lastTipResistance; // Auto mode + } + return user_selected_tip; } uint16_t getTipThermalMass() { return 120; } diff --git a/source/Core/BSP/Pinecilv2/configuration.h b/source/Core/BSP/Pinecilv2/configuration.h index 2d807931..bc24391a 100644 --- a/source/Core/BSP/Pinecilv2/configuration.h +++ b/source/Core/BSP/Pinecilv2/configuration.h @@ -155,6 +155,8 @@ #define POW_EPR 1 #define ENABLE_QC2 1 #define MAG_SLEEP_SUPPORT 1 +#define AUTO_TIP_SELECTION 1 // Can auto-select the tip +#define TIPTYPE_T12 1 // Can manually pick a T12 tip #define DEVICE_HAS_VALIDATION_SUPPORT #define OLED_96x16 1 #define TEMP_NTC diff --git a/source/Core/BSP/Sequre/BSP.cpp b/source/Core/BSP/Sequre/BSP.cpp index 16d6dfd6..a169ec60 100644 --- a/source/Core/BSP/Sequre/BSP.cpp +++ b/source/Core/BSP/Sequre/BSP.cpp @@ -262,7 +262,11 @@ uint8_t getTipResistanceX10() { return TIP_RESISTANCE + ((TIP_RESISTANCE * scaler) / 100000); #else - return TIP_RESISTANCE; + uint8_t user_selected_tip = getUserSelectedTipResistance(); + if (user_selected_tip == 0) { + return TIP_RESISTANCE; // Auto mode + } + return user_selected_tip; #endif } bool isTipShorted() { return false; } diff --git a/source/Core/Inc/Settings.h b/source/Core/Inc/Settings.h index 522b1919..e1865e0f 100644 --- a/source/Core/Inc/Settings.h +++ b/source/Core/Inc/Settings.h @@ -11,7 +11,7 @@ #define CORE_SETTINGS_H_ #include #include - +#include "configuration.h" #ifdef MODEL_Pinecilv2 // Required settings reset for PR #1916 #define SETTINGSVERSION (0x55AB) // This number is frozen, do not edit @@ -124,7 +124,7 @@ typedef enum { */ typedef enum { #ifdef AUTO_TIP_SELECTION - AUTO, // If the hardware supports automatic detection + TIP_TYPE_AUTO, // If the hardware supports automatic detection #endif #ifdef TIPTYPE_T12 @@ -137,11 +137,12 @@ typedef enum { // We do not know of other tuning tips (?yet?) #endif #ifdef TIPTYPE_JBC - JBC_2_5_OHM, // Small JBC tips as used in the S60 + JBC_210_2_5_OHM, // Small JBC tips as used in the S60/S60P #endif TIP_TYPE_MAX, // Max value marker } tipType_t; +uint8_t getUserSelectedTipResistance(); // Settings wide operations void saveSettings(); diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index e4b56ed9..42352864 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -304,12 +304,69 @@ const char *lookupTipName() { switch (value) { #ifdef AUTO_TIP_SELECTION - case tipType_t::AUTO: - return translatedString(Tr->USBPDModeDefault); + case tipType_t::TIP_TYPE_AUTO: + return translatedString(Tr->TipTypeAuto); + break; +#endif +#ifdef TIPTYPE_T12 + case tipType_t::T12_8_OHM: + return translatedString(Tr->TipTypeT12Long); + break; + case tipType_t::T12_6_2_OHM: + return translatedString(Tr->TipTypeT12Short); + break; + case tipType_t::T12_4_OHM: + return translatedString(Tr->TipTypeT12PTS); + break; +#endif +#ifdef TIPTYE_TS80 + case tipType_t::TS80_4_5_OHM: + return translatedString(Tr->TipTypeTS80); + break; +#endif +#ifdef TIPTYPE_JBC + case tipType_t::JBC_210_2_5_OHM: + return translatedString(Tr->TipTypeJBC); break; #endif default: return nullptr; break; } +} +// Returns the resistance for the current tip selected by the user or 0 for auto +uint8_t getUserSelectedTipResistance() { + tipType_t value = (tipType_t)getSettingValue(SettingsOptions::SolderingTipType); + + switch (value) { +#ifdef AUTO_TIP_SELECTION + case tipType_t::TIP_TYPE_AUTO: + return 0; + break; +#endif +#ifdef TIPTYPE_T12 + case tipType_t::T12_8_OHM: + return 80; + break; + case tipType_t::T12_6_2_OHM: + return 62; + break; + case tipType_t::T12_4_OHM: + return 40; + break; +#endif +#ifdef TIPTYE_TS80 + case tipType_t::TS80_4_5_OHM: + return 45; + break; +#endif +#ifdef TIPTYPE_JBC + case tipType_t::JBC_210_2_5_OHM: + return 25; + break; +#endif + default: + return 0; + break; + } } \ No newline at end of file diff --git a/source/Makefile b/source/Makefile index 0754d7c6..4ff5bec1 100644 --- a/source/Makefile +++ b/source/Makefile @@ -1,5 +1,5 @@ ifndef model -model:=Pinecil +model:=Pinecilv2 endif ALL_MINIWARE_MODELS=TS100 TS80 TS80P TS101