diff --git a/source/Core/BSP/BSP.h b/source/Core/BSP/BSP.h index 732a3adc..db9f9814 100644 --- a/source/Core/BSP/BSP.h +++ b/source/Core/BSP/BSP.h @@ -101,6 +101,8 @@ void setBuzzer(bool on); // For example, on the MHP30 this is used to figure out the resistance of the hotplate uint8_t preStartChecks(); uint8_t preStartChecksDone(); + +bool isTipShorted(); #ifdef __cplusplus } #endif 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 f1461258..fe0068be 100644 --- a/source/Core/BSP/Miniware/BSP.cpp +++ b/source/Core/BSP/Miniware/BSP.cpp @@ -284,6 +284,7 @@ void performTipResistanceSampleReading() { tipResistanceReadingSlot++; } +bool tipShorted = false; void FinishMeasureTipResistance() { // Otherwise we now have the 4 samples; @@ -303,6 +304,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 { @@ -372,7 +375,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 @@ -387,7 +390,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 bbbfbb19..ca9817f5 100644 --- a/source/Core/BSP/Pinecil/BSP.cpp +++ b/source/Core/BSP/Pinecil/BSP.cpp @@ -93,7 +93,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 d49dd653..98476e07 100644 --- a/source/Core/BSP/Pinecilv2/BSP.cpp +++ b/source/Core/BSP/Pinecilv2/BSP.cpp @@ -187,7 +187,7 @@ void performTipResistanceSampleReading() { gpio_write(TIP_RESISTANCE_SENSE, tipResistanceReadingSlot == 0); tipResistanceReadingSlot++; } - +bool tipShorted = false; void FinishMeasureTipResistance() { // Otherwise we now have the 4 samples; @@ -207,10 +207,7 @@ void FinishMeasureTipResistance() { if (reading > 8000) { // return; // Change nothing as probably disconnected tip } else if (reading < 500) { - for (;;) /* Tip shorted, wait until reset */ - { - __NOP(); - } + tipShorted = true; } else if (reading < 4000) { newRes = 62; } else { @@ -220,8 +217,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)) { @@ -243,7 +240,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 8a41d18b..7fe84f00 100644 --- a/source/Core/BSP/Sequre_S60/BSP.cpp +++ b/source/Core/BSP/Sequre_S60/BSP.cpp @@ -230,7 +230,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/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*/ }