1
0
forked from me/IronOS

Create isTipDisconnected function

This commit is contained in:
Ben V. Brown
2021-05-01 16:44:50 +10:00
parent 6ceac48f89
commit 7903df36e5
10 changed files with 46 additions and 19 deletions

View File

@@ -74,6 +74,8 @@ bool getIsPoweredByDCIN();
// Logs the system state to a debug interface if supported
void log_system_state(int32_t PWMWattsx10);
// Returns true if the tip is disconnected
bool isTipDisconnected();
#ifdef __cplusplus
}
#endif

View File

@@ -5,6 +5,7 @@
#include "Model_Config.h"
#include "Pins.h"
#include "Setup.h"
#include "TipThermoModel.h"
#include "Utils.h"
#include "history.hpp"
#include "main.hpp"
@@ -180,3 +181,10 @@ void BSPInit(void) {}
void reboot() { NVIC_SystemReset(); }
void delay_ms(uint16_t count) { HAL_Delay(count); }
bool isTipDisconnected() {
uint16_t tipDisconnectedThres = TipThermoModel::getTipMaxInC() - 5;
uint32_t tipTemp = TipThermoModel::getTipInC();
return tipTemp > tipDisconnectedThres;
}

View File

@@ -5,8 +5,8 @@
* Author: Ralim
*/
#include "TipThermoModel.h"
#include "configuration.h"
#include "Utils.h"
#include "configuration.h"
#ifdef TEMP_uV_LOOKUP_MHP30
const uint16_t uVtoDegC[] = {
@@ -47,5 +47,11 @@ const uint16_t uVtoDegC[] = {
const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t));
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
// As such, we need to use the ADC and some pin toggling to measure this resistor
// We want to cache the value as it takes time to measure, but we also need to re-measure when the tip is inserted / removed
// We can detect the tip being inserted / removed by using the reading of that channel, as if its reporting max (0xFFFF) then the heater is not connected
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return Utils::InterpolateLookupTable(uVtoDegC, uVtoDegCItems, tipuVDelta); }
return Utils::InterpolateLookupTable(uVtoDegC, uVtoDegCItems, tipuVDelta);
}

View File

@@ -5,6 +5,7 @@
#include "Model_Config.h"
#include "Pins.h"
#include "Setup.h"
#include "TipThermoModel.h"
#include "history.hpp"
#include "main.hpp"
#include <IRQ.h>
@@ -338,3 +339,10 @@ void BSPInit(void) { switchToFastPWM(); }
void reboot() { NVIC_SystemReset(); }
void delay_ms(uint16_t count) { HAL_Delay(count); }
bool isTipDisconnected() {
uint16_t tipDisconnectedThres = TipThermoModel::getTipMaxInC() - 5;
uint32_t tipTemp = TipThermoModel::getTipInC();
return tipTemp > tipDisconnectedThres;
}

View File

@@ -5,10 +5,8 @@
* Author: Ralim
*/
#include "TipThermoModel.h"
#include "configuration.h"
#include "Utils.h"
#include "configuration.h"
#ifdef TEMP_uV_LOOKUP_HAKKO
const uint16_t uVtoDegC[] = {

View File

@@ -4,6 +4,7 @@
#include "I2C_Wrapper.hpp"
#include "Pins.h"
#include "Setup.h"
#include "TipThermoModel.h"
#include "gd32vf103_timer.h"
#include "history.hpp"
#include "main.hpp"
@@ -120,3 +121,10 @@ void delay_ms(uint16_t count) { delay_1ms(count); }
uint32_t __get_IPSR(void) {
return 0; // To shut-up CMSIS
}
bool isTipDisconnected() {
uint16_t tipDisconnectedThres = TipThermoModel::getTipMaxInC() - 5;
uint32_t tipTemp = TipThermoModel::getTipInC();
return tipTemp > tipDisconnectedThres;
}

View File

@@ -5,9 +5,8 @@
* Author: Ralim
*/
#include "TipThermoModel.h"
#include "configuration.h"
#include "Utils.h"
#include "configuration.h"
#ifdef TEMP_uV_LOOKUP_HAKKO
const uint16_t uVtoDegC[] = {
@@ -70,5 +69,4 @@ const uint16_t uVtoDegC[] = {
const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t));
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return Utils::InterpolateLookupTable(uVtoDegC, uVtoDegCItems, tipuVDelta); }