diff options
author | Ben V. Brown <[email protected]> | 2021-05-01 16:44:50 +1000 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2021-05-01 16:44:50 +1000 |
commit | 7903df36e57befa0d600ab5c66fca4249db774b6 (patch) | |
tree | 17b52826b39d0d6b67286fccaa3964aea1a4345a /source/Core/BSP | |
parent | 6ceac48f897d014e6449b7da82fc13854d0f3cff (diff) | |
download | IronOS-7903df36e57befa0d600ab5c66fca4249db774b6.tar.gz IronOS-7903df36e57befa0d600ab5c66fca4249db774b6.zip |
Create isTipDisconnected function
Diffstat (limited to 'source/Core/BSP')
-rw-r--r-- | source/Core/BSP/BSP.h | 2 | ||||
-rw-r--r-- | source/Core/BSP/MHP30/BSP.cpp | 8 | ||||
-rw-r--r-- | source/Core/BSP/MHP30/ThermoModel.cpp | 10 | ||||
-rw-r--r-- | source/Core/BSP/Miniware/BSP.cpp | 8 | ||||
-rw-r--r-- | source/Core/BSP/Miniware/ThermoModel.cpp | 4 | ||||
-rw-r--r-- | source/Core/BSP/Pine64/BSP.cpp | 8 | ||||
-rw-r--r-- | source/Core/BSP/Pine64/ThermoModel.cpp | 4 |
7 files changed, 36 insertions, 8 deletions
diff --git a/source/Core/BSP/BSP.h b/source/Core/BSP/BSP.h index 08ead36a..1ed0507c 100644 --- a/source/Core/BSP/BSP.h +++ b/source/Core/BSP/BSP.h @@ -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
diff --git a/source/Core/BSP/MHP30/BSP.cpp b/source/Core/BSP/MHP30/BSP.cpp index 7b09ed3e..7abfccb7 100644 --- a/source/Core/BSP/MHP30/BSP.cpp +++ b/source/Core/BSP/MHP30/BSP.cpp @@ -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;
+}
diff --git a/source/Core/BSP/MHP30/ThermoModel.cpp b/source/Core/BSP/MHP30/ThermoModel.cpp index 887f32c9..d7f5b643 100644 --- a/source/Core/BSP/MHP30/ThermoModel.cpp +++ b/source/Core/BSP/MHP30/ThermoModel.cpp @@ -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);
+}
diff --git a/source/Core/BSP/Miniware/BSP.cpp b/source/Core/BSP/Miniware/BSP.cpp index a40c9000..2de98bf2 100644 --- a/source/Core/BSP/Miniware/BSP.cpp +++ b/source/Core/BSP/Miniware/BSP.cpp @@ -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;
+}
diff --git a/source/Core/BSP/Miniware/ThermoModel.cpp b/source/Core/BSP/Miniware/ThermoModel.cpp index ea54927f..ae74d49c 100644 --- a/source/Core/BSP/Miniware/ThermoModel.cpp +++ b/source/Core/BSP/Miniware/ThermoModel.cpp @@ -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[] = {
diff --git a/source/Core/BSP/Pine64/BSP.cpp b/source/Core/BSP/Pine64/BSP.cpp index e29abea2..70cc04f1 100644 --- a/source/Core/BSP/Pine64/BSP.cpp +++ b/source/Core/BSP/Pine64/BSP.cpp @@ -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;
+}
diff --git a/source/Core/BSP/Pine64/ThermoModel.cpp b/source/Core/BSP/Pine64/ThermoModel.cpp index efdfc207..a8efdcb0 100644 --- a/source/Core/BSP/Pine64/ThermoModel.cpp +++ b/source/Core/BSP/Pine64/ThermoModel.cpp @@ -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); }
|