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

View File

@@ -55,8 +55,6 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC, bool ski
uint32_t TipThermoModel::convertTipRawADCToDegC(uint16_t rawADC) { return convertuVToDegC(convertTipRawADCTouV(rawADC)); }
uint32_t TipThermoModel::convertTipRawADCToDegF(uint16_t rawADC) { return convertuVToDegF(convertTipRawADCTouV(rawADC)); }
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) { return convertCtoF(convertuVToDegC(tipuVDelta)); }
uint32_t TipThermoModel::convertCtoF(uint32_t degC) {

View File

@@ -111,8 +111,8 @@
#define OP_AMP_GAIN_STAGE_TS80 (1 + (OP_AMP_Rf_TS80 / OP_AMP_Rin_TS80))
#define OP_AMP_Rf_MHP30 268500 // 268.5 Kilo-ohms -> Measured
#define OP_AMP_Rin_MHP30 1600 // 1.6 Kilo-ohms -> Measured
#define OP_AMP_Rf_MHP30 268500 // 268.5 Kilo-ohms -> Measured
#define OP_AMP_Rin_MHP30 1600 // 1.6 Kilo-ohms -> Measured
#define OP_AMP_GAIN_STAGE_MHP30 (1 + (OP_AMP_Rf_MHP30 / OP_AMP_Rin_MHP30))
// Deriving the Voltage div:
@@ -200,6 +200,6 @@ const uint8_t tipResistance = 45; // x10 ohms, 4.5 typical for ts80 tips
#endif
#ifdef MODEL_MHP30
const uint32_t tipMass = 100; // TODO
const uint8_t tipResistance = 75; // x10 ohms, ~6 typical
const uint32_t tipMass = 100; // TODO
const uint8_t tipResistance = 75; // x10 ohms, ~6 typical
#endif

View File

@@ -840,8 +840,10 @@ void startGUITask(void const *argument __unused) {
saveSettings();
break;
case BUTTON_F_SHORT:
gui_solderingMode(0); // enter soldering mode
buttonLockout = true;
if (!isTipDisconnected()) {
gui_solderingMode(0); // enter soldering mode
buttonLockout = true;
}
break;
case BUTTON_B_SHORT:
enterSettingsMenu(); // enter the settings menu
@@ -865,12 +867,11 @@ void startGUITask(void const *argument __unused) {
if ((tipTemp < 50) && systemSettings.sensitivity && (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
OLED::setDisplayState(OLED::DisplayState::OFF);
}
uint16_t tipDisconnectedThres = TipThermoModel::getTipMaxInC() - 5;
// Clear the lcd buffer
OLED::clearScreen();
OLED::setCursor(0, 0);
if (systemSettings.detailedIDLE) {
if (tipTemp > tipDisconnectedThres) {
if (isTipDisconnected()) {
OLED::print(translatedString(Tr->TipDisconnectedString), FontStyle::SMALL);
} else {
OLED::print(translatedString(Tr->IdleTipString), FontStyle::SMALL);
@@ -903,7 +904,7 @@ void startGUITask(void const *argument __unused) {
tempOnDisplay = true;
else if (tipTemp < 45)
tempOnDisplay = false;
if (tipTemp > tipDisconnectedThres) {
if (isTipDisconnected()) {
tempOnDisplay = false;
tipDisconnectedDisplay = true;
}