From 5519054f50c2e0e532f8a541f156ef350aaecc9c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 9 Jul 2019 21:35:07 -0500 Subject: [PATCH] Improve BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE (#13740) --- Marlin/src/module/temperature.cpp | 60 +++++++++++++------- Marlin/src/pins/pins_BEAST.h | 4 +- Marlin/src/pins/pins_BIGTREE_SKR_MINI_E3.h | 4 +- Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h | 4 +- Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h | 4 +- Marlin/src/pins/pins_CHITU3D.h | 4 +- Marlin/src/pins/pins_FYSETC_AIO_II.h | 4 +- Marlin/src/pins/pins_FYSETC_CHEETAH.h | 4 +- Marlin/src/pins/pins_GEN7_12.h | 2 +- Marlin/src/pins/pins_GTM32_PRO_VB.h | 2 +- Marlin/src/pins/pins_SETHI.h | 2 +- Marlin/src/pins/pins_STM32F1R.h | 4 +- Marlin/src/pins/pins_STM32F4.h | 4 +- Marlin/src/pins/pins_STM3R_MINI.h | 4 +- Marlin/src/pins/pins_THE_BORG.h | 4 +- 15 files changed, 65 insertions(+), 45 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f98f76c8d8..43efb79333 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -746,9 +746,28 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) { // // Temperature Error Handlers // + +inline void loud_kill(PGM_P const lcd_msg) { + Running = false; + #if HAS_BUZZER && PIN_EXISTS(BEEPER) + for (uint8_t i = 20; i--;) { + WRITE(BEEPER_PIN, HIGH); delay(25); + WRITE(BEEPER_PIN, LOW); delay(80); + } + WRITE(BEEPER_PIN, HIGH); + #endif + kill(lcd_msg); +} + void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg, PGM_P const lcd_msg) { - static bool killed = false; - if (IsRunning()) { + + static uint8_t killed = 0; + + if (IsRunning() + #if BOGUS_TEMPERATURE_GRACE_PERIOD + && killed == 2 + #endif + ) { SERIAL_ERROR_START(); serialprintPGM(serial_msg); SERIAL_ECHOPGM(MSG_STOPPED_HEATER); @@ -760,27 +779,28 @@ void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg, SERIAL_EOL(); } - #if DISABLED(BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE) - if (!killed) { - Running = false; - killed = true; + disable_all_heaters(); // always disable (even for bogus temp) - disable_all_heaters(); - - #if HAS_BUZZER && PIN_EXISTS(BEEPER) - for (uint8_t i = 20; i--;) { - WRITE(BEEPER_PIN, HIGH); delay(25); - WRITE(BEEPER_PIN, LOW); delay(80); - } - WRITE(BEEPER_PIN, HIGH); - #endif - - kill(lcd_msg); + #if BOGUS_TEMPERATURE_GRACE_PERIOD + const millis_t ms = millis(); + static millis_t expire_ms; + switch (killed) { + case 0: + expire_ms = ms + BOGUS_TEMPERATURE_GRACE_PERIOD; + ++killed; + break; + case 1: + if (ELAPSED(ms, expire_ms)) ++killed; + break; + case 2: + loud_kill(lcd_msg); + ++killed; + break; } - else - disable_all_heaters(); // paranoia - #else + #elif defined(BOGUS_TEMPERATURE_GRACE_PERIOD) UNUSED(killed); + #else + if (!killed) { killed = 1; loud_kill(lcd_msg); } #endif } diff --git a/Marlin/src/pins/pins_BEAST.h b/Marlin/src/pins/pins_BEAST.h index efbc732e5f..adb19f527f 100644 --- a/Marlin/src/pins/pins_BEAST.h +++ b/Marlin/src/pins/pins_BEAST.h @@ -35,8 +35,8 @@ // Enable I2C_EEPROM for testing #define I2C_EEPROM -// Ignore temp readings during develpment. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Steppers diff --git a/Marlin/src/pins/pins_BIGTREE_SKR_MINI_E3.h b/Marlin/src/pins/pins_BIGTREE_SKR_MINI_E3.h index 34f686ef68..a5a68dac9f 100644 --- a/Marlin/src/pins/pins_BIGTREE_SKR_MINI_E3.h +++ b/Marlin/src/pins/pins_BIGTREE_SKR_MINI_E3.h @@ -31,8 +31,8 @@ // Release PB3/PB4 (E0 STP/DIR) from JTAG pins #define DISABLE_JTAG -// Ignore temp readings during develpment. -//#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Servos diff --git a/Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h b/Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h index 19c7b4b67b..6475bd7a36 100644 --- a/Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h @@ -32,8 +32,8 @@ //#define DISABLE_DEBUG #define DISABLE_JTAG -// Ignore temp readings during develpment. -//#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches diff --git a/Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h b/Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h index ef9fe23e7d..79275006ee 100644 --- a/Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h +++ b/Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h @@ -29,8 +29,8 @@ #define BOARD_NAME "BIGTREE SKR V1.3" #endif -// Ignore temp readings during develpment. -//#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Servos diff --git a/Marlin/src/pins/pins_CHITU3D.h b/Marlin/src/pins/pins_CHITU3D.h index 3fa5338c19..5eb4518eff 100644 --- a/Marlin/src/pins/pins_CHITU3D.h +++ b/Marlin/src/pins/pins_CHITU3D.h @@ -35,8 +35,8 @@ // Enable I2C_EEPROM for testing //#define I2C_EEPROM -// Ignore temp readings during develpment. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Steppers diff --git a/Marlin/src/pins/pins_FYSETC_AIO_II.h b/Marlin/src/pins/pins_FYSETC_AIO_II.h index 49879ba50d..b63e419f35 100644 --- a/Marlin/src/pins/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/pins_FYSETC_AIO_II.h @@ -30,8 +30,8 @@ #define pins_v2_20190128 // geo-f:add for new pins define -// Ignore temp readings during develpment. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches diff --git a/Marlin/src/pins/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/pins_FYSETC_CHEETAH.h index 6562a1bb8d..b7d85bd8d7 100644 --- a/Marlin/src/pins/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/pins_FYSETC_CHEETAH.h @@ -30,8 +30,8 @@ #define BOARD_NAME "FYSETC Cheetah" #define BOARD_WEBSITE_URL "https://fysetc.com" -// Ignore temp readings during develpment. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Servos diff --git a/Marlin/src/pins/pins_GEN7_12.h b/Marlin/src/pins/pins_GEN7_12.h index 2b9411feb3..0c33104718 100644 --- a/Marlin/src/pins/pins_GEN7_12.h +++ b/Marlin/src/pins/pins_GEN7_12.h @@ -130,7 +130,7 @@ // All these generations of Gen7 supply thermistor power // via PS_ON, so ignore bad thermistor readings -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #define DEBUG_PIN 0 diff --git a/Marlin/src/pins/pins_GTM32_PRO_VB.h b/Marlin/src/pins/pins_GTM32_PRO_VB.h index 1a641ca3ba..c2f5cbc5ea 100644 --- a/Marlin/src/pins/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/pins_GTM32_PRO_VB.h @@ -49,7 +49,7 @@ //#define DISABLE_JTAGSWD // Ignore temp readings during development. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // Enable EEPROM Emulation for this board as it doesn't have EEPROM #define FLASH_EEPROM_EMULATION diff --git a/Marlin/src/pins/pins_SETHI.h b/Marlin/src/pins/pins_SETHI.h index 049526a8f1..23b985fbac 100644 --- a/Marlin/src/pins/pins_SETHI.h +++ b/Marlin/src/pins/pins_SETHI.h @@ -115,7 +115,7 @@ // All these generations of Gen7 supply thermistor power // via PS_ON, so ignore bad thermistor readings -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // our pin for debugging. #define DEBUG_PIN 0 diff --git a/Marlin/src/pins/pins_STM32F1R.h b/Marlin/src/pins/pins_STM32F1R.h index e202862d3d..4d4283e169 100644 --- a/Marlin/src/pins/pins_STM32F1R.h +++ b/Marlin/src/pins/pins_STM32F1R.h @@ -32,8 +32,8 @@ #define BOARD_NAME "Misc. STM32F1R" #define DEFAULT_MACHINE_NAME "STM32F103RET6" -// Ignore temp readings during develpment. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches diff --git a/Marlin/src/pins/pins_STM32F4.h b/Marlin/src/pins/pins_STM32F4.h index 20f98454da..75c78d0de9 100644 --- a/Marlin/src/pins/pins_STM32F4.h +++ b/Marlin/src/pins/pins_STM32F4.h @@ -32,8 +32,8 @@ #define E2END 0xFFF // 4KB -// Ignore temp readings during develpment. -//#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #if HOTENDS > 2 || E_STEPPERS > 2 #error "STM32F4 supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/pins_STM3R_MINI.h b/Marlin/src/pins/pins_STM3R_MINI.h index 08f2a3a5dd..40fc121298 100644 --- a/Marlin/src/pins/pins_STM3R_MINI.h +++ b/Marlin/src/pins/pins_STM3R_MINI.h @@ -35,8 +35,8 @@ // Enable I2C_EEPROM for testing #define I2C_EEPROM -// Ignore temp readings during develpment. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 // // Limit Switches diff --git a/Marlin/src/pins/pins_THE_BORG.h b/Marlin/src/pins/pins_THE_BORG.h index afefc788a8..364179bc02 100644 --- a/Marlin/src/pins/pins_THE_BORG.h +++ b/Marlin/src/pins/pins_THE_BORG.h @@ -30,8 +30,8 @@ #define E2END 0xFFF // EEPROM end address -// Ignore temp readings during develpment. -#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #if HOTENDS > 3 || E_STEPPERS > 3 #error "The-Borg supports up to 3 hotends / E-steppers."