aboutsummaryrefslogtreecommitdiffhomepage
path: root/source/Core
diff options
context:
space:
mode:
Diffstat (limited to 'source/Core')
-rw-r--r--source/Core/BSP/BSP.h2
-rw-r--r--source/Core/BSP/MHP30/Power.cpp3
-rw-r--r--source/Core/BSP/Miniware/BSP.cpp11
-rw-r--r--source/Core/BSP/Pinecil/BSP.cpp2
-rw-r--r--source/Core/BSP/Pinecilv2/BSP.cpp11
-rw-r--r--source/Core/BSP/Sequre_S60/BSP.cpp2
-rw-r--r--source/Core/Inc/Translation.h1
-rw-r--r--source/Core/Inc/settingsGUI.hpp4
-rw-r--r--source/Core/Threads/OperatingModes/ShowStartupWarnings.cpp4
-rw-r--r--source/Core/Threads/OperatingModes/utils/OperatingModeUtilities.h24
-rw-r--r--source/Core/Threads/OperatingModes/utils/ShowWarning.cpp2
11 files changed, 43 insertions, 23 deletions
diff --git a/source/Core/BSP/BSP.h b/source/Core/BSP/BSP.h
index 3874ec53..626989fe 100644
--- a/source/Core/BSP/BSP.h
+++ b/source/Core/BSP/BSP.h
@@ -102,6 +102,8 @@ void setBuzzer(bool on);
uint8_t preStartChecks();
uint8_t preStartChecksDone();
+// Check if the tip or output mosfet is shorted (if possible)
+bool isTipShorted();
// Show the boot logo
void showBootLogo(void);
#ifdef __cplusplus
diff --git a/source/Core/BSP/MHP30/Power.cpp b/source/Core/BSP/MHP30/Power.cpp
index 827fac6c..83c95c62 100644
--- a/source/Core/BSP/MHP30/Power.cpp
+++ b/source/Core/BSP/MHP30/Power.cpp
@@ -18,4 +18,5 @@ void power_check() {
bool getIsPoweredByDCIN() { return false; }
-uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } \ No newline at end of file
+uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
+bool isTipShorted() { return false; } \ No newline at end of file
diff --git a/source/Core/BSP/Miniware/BSP.cpp b/source/Core/BSP/Miniware/BSP.cpp
index ef2e67c7..f7e2053b 100644
--- a/source/Core/BSP/Miniware/BSP.cpp
+++ b/source/Core/BSP/Miniware/BSP.cpp
@@ -285,6 +285,7 @@ void performTipResistanceSampleReading() {
tipResistanceReadingSlot++;
}
+bool tipShorted = false;
void FinishMeasureTipResistance() {
// Otherwise we now have the 4 samples;
@@ -304,6 +305,8 @@ void FinishMeasureTipResistance() {
// return; // Change nothing as probably disconnected tip
tipResistanceReadingSlot = lastTipResistance = 0;
return;
+ } else if (reading < 200) {
+ tipShorted = true;
} else if (reading < 800) {
newRes = 62;
} else {
@@ -373,7 +376,7 @@ uint64_t getDeviceID() {
uint8_t preStartChecksDone() {
#ifdef TIP_RESISTANCE_SENSE_Pin
- return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring) ? 0 : 1;
+ return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring || tipShorted) ? 0 : 1;
#else
return 1;
#endif
@@ -388,7 +391,11 @@ uint8_t getTipResistanceX10() {
return TIP_RESISTANCE;
#endif
}
-
+#ifdef TIP_RESISTANCE_SENSE_Pin
+bool isTipShorted() { return tipShorted; }
+#else
+bool isTipShorted() { return false; }
+#endif
uint8_t getTipThermalMass() {
#ifdef TIP_RESISTANCE_SENSE_Pin
if (lastTipResistance >= 80) {
diff --git a/source/Core/BSP/Pinecil/BSP.cpp b/source/Core/BSP/Pinecil/BSP.cpp
index dd8c7787..1c7a3888 100644
--- a/source/Core/BSP/Pinecil/BSP.cpp
+++ b/source/Core/BSP/Pinecil/BSP.cpp
@@ -94,7 +94,7 @@ uint8_t preStartChecks() { return 1; }
uint64_t getDeviceID() { return dbg_id_get(); }
uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
-
+bool isTipShorted() { return false; }
uint8_t preStartChecksDone() { return 1; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
diff --git a/source/Core/BSP/Pinecilv2/BSP.cpp b/source/Core/BSP/Pinecilv2/BSP.cpp
index 75255ac8..35809866 100644
--- a/source/Core/BSP/Pinecilv2/BSP.cpp
+++ b/source/Core/BSP/Pinecilv2/BSP.cpp
@@ -189,7 +189,7 @@ void performTipResistanceSampleReading() {
gpio_write(TIP_RESISTANCE_SENSE, tipResistanceReadingSlot == 0);
tipResistanceReadingSlot++;
}
-
+bool tipShorted = false;
void FinishMeasureTipResistance() {
// Otherwise we now have the 4 samples;
@@ -208,6 +208,8 @@ void FinishMeasureTipResistance() {
uint8_t newRes = 0;
if (reading > 8000) {
// return; // Change nothing as probably disconnected tip
+ } else if (reading < 500) {
+ tipShorted = true;
} else if (reading < 4000) {
newRes = 62;
} else {
@@ -217,8 +219,8 @@ void FinishMeasureTipResistance() {
}
volatile bool tipMeasurementOccuring = true;
volatile TickType_t nextTipMeasurement = 100;
-
-void performTipMeasurementStep() {
+bool isTipShorted() { return tipShorted; }
+void performTipMeasurementStep() {
// Wait 100ms for settle time
if (xTaskGetTickCount() < (nextTipMeasurement)) {
@@ -240,7 +242,8 @@ uint8_t preStartChecks() {
performTipMeasurementStep();
return preStartChecksDone();
}
-uint8_t preStartChecksDone() { return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring) ? 0 : 1; }
+// If we are still measuring the tip; or tip is shorted; prevent heating
+uint8_t preStartChecksDone() { return (lastTipResistance == 0 || tipResistanceReadingSlot < numTipResistanceReadings || tipMeasurementOccuring || tipShorted) ? 0 : 1; }
// Return hardware unique ID if possible
uint64_t getDeviceID() {
diff --git a/source/Core/BSP/Sequre_S60/BSP.cpp b/source/Core/BSP/Sequre_S60/BSP.cpp
index f0991fcc..25ad176e 100644
--- a/source/Core/BSP/Sequre_S60/BSP.cpp
+++ b/source/Core/BSP/Sequre_S60/BSP.cpp
@@ -231,7 +231,7 @@ uint64_t getDeviceID() {
}
uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
-
+bool isTipShorted() { return false; }
uint8_t preStartChecksDone() { return 1; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
diff --git a/source/Core/Inc/Translation.h b/source/Core/Inc/Translation.h
index 45632eda..f2b84ffa 100644
--- a/source/Core/Inc/Translation.h
+++ b/source/Core/Inc/Translation.h
@@ -116,6 +116,7 @@ struct TranslationIndexTable {
uint16_t UnlockingKeysString;
uint16_t WarningKeysLockedString;
uint16_t WarningThermalRunaway;
+ uint16_t WarningTipShorted;
uint16_t SettingsCalibrationWarning;
uint16_t CJCCalibrating;
diff --git a/source/Core/Inc/settingsGUI.hpp b/source/Core/Inc/settingsGUI.hpp
index f0c25297..f1d90852 100644
--- a/source/Core/Inc/settingsGUI.hpp
+++ b/source/Core/Inc/settingsGUI.hpp
@@ -8,9 +8,11 @@
#ifndef GUI_HPP_
#define GUI_HPP_
#include "BSP.h"
+#include "FreeRTOS.h"
#include "Settings.h"
#include "Translation.h"
+
#define PRESS_ACCEL_STEP (TICKS_100MS / 3)
#define PRESS_ACCEL_INTERVAL_MIN TICKS_100MS
#define PRESS_ACCEL_INTERVAL_MAX (TICKS_100MS * 3)
@@ -35,7 +37,7 @@ typedef struct {
} menuitem;
void enterSettingsMenu();
-void warnUser(const char *warning, const int timeout);
+void warnUser(const char *warning, const TickType_t timeout);
extern const menuitem rootSettingsMenu[];
#endif /* GUI_HPP_ */
diff --git a/source/Core/Threads/OperatingModes/ShowStartupWarnings.cpp b/source/Core/Threads/OperatingModes/ShowStartupWarnings.cpp
index 8c8b6dd1..62ed5d0e 100644
--- a/source/Core/Threads/OperatingModes/ShowStartupWarnings.cpp
+++ b/source/Core/Threads/OperatingModes/ShowStartupWarnings.cpp
@@ -48,5 +48,9 @@ void showWarnings(void) {
}
}
#endif /*POW_PD_EXT==1*/
+ // If tip looks to be shorted, yell at user and dont auto dismiss
+ if (isTipShorted()) {
+ warnUser(translatedString(Tr->WarningTipShorted), portMAX_DELAY);
+ }
#endif /*NO_WARN_MISSING*/
}
diff --git a/source/Core/Threads/OperatingModes/utils/OperatingModeUtilities.h b/source/Core/Threads/OperatingModes/utils/OperatingModeUtilities.h
index 4484ee0c..ab3f36f9 100644
--- a/source/Core/Threads/OperatingModes/utils/OperatingModeUtilities.h
+++ b/source/Core/Threads/OperatingModes/utils/OperatingModeUtilities.h
@@ -3,16 +3,16 @@
#include "OLED.hpp"
#include <stdbool.h>
-void GUIDelay(); //
-bool checkForUnderVoltage(void); //
-uint32_t getSleepTimeout(void); //
-bool shouldBeSleeping(bool inAutoStart); //
-bool shouldShutdown(void); //
-void gui_drawTipTemp(bool symbol, const FontStyle font); //
-void printVoltage(void); //
-void warnUser(const char *warning, const int timeout); //
-void gui_drawBatteryIcon(void); //
-bool checkForUnderVoltage(void); //
-uint16_t min(uint16_t a, uint16_t b); //
-void printCountdownUntilSleep(int sleepThres); //
+void GUIDelay(); //
+bool checkForUnderVoltage(void); //
+uint32_t getSleepTimeout(void); //
+bool shouldBeSleeping(bool inAutoStart); //
+bool shouldShutdown(void); //
+void gui_drawTipTemp(bool symbol, const FontStyle font); //
+void printVoltage(void); //
+void warnUser(const char *warning, const TickType_t timeout); //
+void gui_drawBatteryIcon(void); //
+bool checkForUnderVoltage(void); //
+uint16_t min(uint16_t a, uint16_t b); //
+void printCountdownUntilSleep(int sleepThres); //
#endif \ No newline at end of file
diff --git a/source/Core/Threads/OperatingModes/utils/ShowWarning.cpp b/source/Core/Threads/OperatingModes/utils/ShowWarning.cpp
index 58370cb7..fcd2972e 100644
--- a/source/Core/Threads/OperatingModes/utils/ShowWarning.cpp
+++ b/source/Core/Threads/OperatingModes/utils/ShowWarning.cpp
@@ -1,6 +1,6 @@
#include "Buttons.hpp"
#include "OperatingModeUtilities.h"
-void warnUser(const char *warning, const int timeout) {
+void warnUser(const char *warning, const TickType_t timeout) {
OLED::clearScreen();
OLED::printWholeScreen(warning);
OLED::refresh();