Custom max temp lookup

This commit is contained in:
Ben V. Brown
2024-05-24 20:44:50 +10:00
committed by Ben V. Brown
parent 5a75344539
commit 4b1b370da9
3 changed files with 24 additions and 0 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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
}