diff --git a/source/Core/BSP/BSP_Power.h b/source/Core/BSP/BSP_Power.h index 348dc7a7..d37106f1 100644 --- a/source/Core/BSP/BSP_Power.h +++ b/source/Core/BSP/BSP_Power.h @@ -8,6 +8,8 @@ #ifndef BSP_POWER_H_ #define BSP_POWER_H_ +#include "Types.h" + #ifdef __cplusplus extern "C" { #endif @@ -22,6 +24,8 @@ uint8_t getTipResistanceX10(); uint16_t getTipThermalMass(); uint16_t getTipInertia(); +TemperatureType_t getCustomTipMaxInC(); + #ifdef __cplusplus } #endif diff --git a/source/Core/BSP/Pinecilv2/BSP.cpp b/source/Core/BSP/Pinecilv2/BSP.cpp index 2e80e8c3..e019407e 100644 --- a/source/Core/BSP/Pinecilv2/BSP.cpp +++ b/source/Core/BSP/Pinecilv2/BSP.cpp @@ -9,12 +9,15 @@ #include "TipThermoModel.h" #include "USBPD.h" #include "Utils.h" +#include "bl702_adc.h" #include "configuration.h" #include "crc32.h" #include "hal_flash.h" #include "history.hpp" #include "main.hpp" +extern ADC_Gain_Coeff_Type adcGainCoeffCal; + // These control the period's of time used for the PWM const uint16_t powerPWM = 255; uint8_t holdoffTicks = 25; // This is the tick delay before temp measure starts (i.e. time for op-amp recovery) @@ -274,3 +277,16 @@ void showBootLogo(void) { BootLogo::handleShowingLogo(scratch); } + +TemperatureType_t getCustomTipMaxInC() { + // have to lookup the max temp while being aware of the coe scaling value + float max_reading = ADC_MAX_READING - 1.0; + + if (adcGainCoeffCal.adcGainCoeffEnable) { + max_reading /= adcGainCoeffCal.coe; + } + + TemperatureType_t maximumTipTemp = TipThermoModel::convertTipRawADCToDegC(max_reading); + maximumTipTemp += getHandleTemperature(0) / 10; // Add handle offset + return maximumTipTemp - 1; +} \ No newline at end of file diff --git a/source/Core/Drivers/TipThermoModel.cpp b/source/Core/Drivers/TipThermoModel.cpp index 29edc08d..f52f4733 100644 --- a/source/Core/Drivers/TipThermoModel.cpp +++ b/source/Core/Drivers/TipThermoModel.cpp @@ -89,7 +89,11 @@ TemperatureType_t TipThermoModel::getTipInF(bool sampleNow) { } TemperatureType_t TipThermoModel::getTipMaxInC() { +#ifdef CUSTOM_MAX_TEMP_C + return getCustomTipMaxInC(); +#else TemperatureType_t maximumTipTemp = TipThermoModel::convertTipRawADCToDegC(ADC_MAX_READING - 1); maximumTipTemp += getHandleTemperature(0) / 10; // Add handle offset return maximumTipTemp - 1; +#endif }