Cleanup original thermal error handlers.
Remove useless repeated calls to disable heaters and turn on the fans, since this is done at a higher level. Avoid repeating messages on the serial. Do it just once. Make a critical alert sound unconditionally.
This commit is contained in:
parent
50c71924a2
commit
6751586db6
3 changed files with 92 additions and 121 deletions
|
@ -241,9 +241,10 @@ void prepare_move();
|
||||||
void kill(const char *full_screen_message = NULL, unsigned char id = 0);
|
void kill(const char *full_screen_message = NULL, unsigned char id = 0);
|
||||||
void finishAndDisableSteppers();
|
void finishAndDisableSteppers();
|
||||||
|
|
||||||
void UnconditionalStop(); // Stop heaters, motion and clear current print status
|
void UnconditionalStop(); // Stop heaters, motion and clear current print status
|
||||||
void Stop(); // Emergency stop used by overtemp functions which allows recovery
|
void ThermalStop(bool pause = false); // Emergency stop used by overtemp functions which allows
|
||||||
bool IsStopped(); // Returns true if the print has been stopped
|
// recovery (with pause=true)
|
||||||
|
bool IsStopped(); // Returns true if the print has been stopped
|
||||||
|
|
||||||
//put an ASCII command at the end of the current buffer, read from flash
|
//put an ASCII command at the end of the current buffer, read from flash
|
||||||
#define enquecommand_P(cmd) enquecommand(cmd, true)
|
#define enquecommand_P(cmd) enquecommand(cmd, true)
|
||||||
|
|
|
@ -9967,7 +9967,9 @@ void UnconditionalStop()
|
||||||
CRITICAL_SECTION_END;
|
CRITICAL_SECTION_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop: Emergency stop used by overtemp functions which allows recovery
|
// Emergency stop used by overtemp functions which allows recovery
|
||||||
|
//
|
||||||
|
// This function is called *continuously* during a thermal failure.
|
||||||
//
|
//
|
||||||
// In addition to stopping the print, this prevents subsequent G[0-3] commands to be
|
// In addition to stopping the print, this prevents subsequent G[0-3] commands to be
|
||||||
// processed via USB (using "Stopped") until the print is resumed via M999 or
|
// processed via USB (using "Stopped") until the print is resumed via M999 or
|
||||||
|
@ -9977,29 +9979,35 @@ void UnconditionalStop()
|
||||||
// will introduce either over/under extrusion on the current segment, and will not
|
// will introduce either over/under extrusion on the current segment, and will not
|
||||||
// survive a power panic. Switching Stop() to use the pause machinery instead (with
|
// survive a power panic. Switching Stop() to use the pause machinery instead (with
|
||||||
// the addition of disabling the headers) could allow true recovery in the future.
|
// the addition of disabling the headers) could allow true recovery in the future.
|
||||||
void Stop()
|
void ThermalStop(bool pause)
|
||||||
{
|
{
|
||||||
// Keep disabling heaters
|
if(Stopped == false) {
|
||||||
disable_heater();
|
Stopped = true;
|
||||||
|
if(pause && (IS_SD_PRINTING || usb_timer.running())) {
|
||||||
|
if (!isPrintPaused) {
|
||||||
|
// we cannot make a distinction for an host here, the pause must be instantaneous
|
||||||
|
lcd_pause_print();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// We got a hard thermal error and/or there is no print going on. Just stop.
|
||||||
|
lcd_print_stop();
|
||||||
|
}
|
||||||
|
Stopped_gcode_LastN = gcode_LastN; // Save last g_code for "restart"
|
||||||
|
|
||||||
// Call the regular stop function if that's the first time during a new print
|
// Eventually report the stopped status (though this is usually overridden by a
|
||||||
if(Stopped == false) {
|
// higher-priority alert status message)
|
||||||
Stopped = true;
|
SERIAL_ERROR_START;
|
||||||
lcd_print_stop();
|
SERIAL_ERRORLNRPGM(MSG_ERR_STOPPED);
|
||||||
Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart
|
LCD_MESSAGERPGM(_T(MSG_STOPPED));
|
||||||
|
|
||||||
// Eventually report the stopped status (though this is usually overridden by a
|
Sound_MakeCustom(1000,0,true);
|
||||||
// higher-priority alert status message)
|
}
|
||||||
SERIAL_ERROR_START;
|
|
||||||
SERIAL_ERRORLNRPGM(MSG_ERR_STOPPED);
|
|
||||||
LCD_MESSAGERPGM(_T(MSG_STOPPED));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return to the status screen to stop any pending menu action which could have been
|
// Return to the status screen to stop any pending menu action which could have been
|
||||||
// started by the user while stuck in the Stopped state. This also ensures the NEW
|
// started by the user while stuck in the Stopped state. This also ensures the NEW
|
||||||
// error is immediately shown.
|
// error is immediately shown.
|
||||||
if (menu_menu != lcd_status_screen)
|
if (menu_menu != lcd_status_screen)
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsStopped() { return Stopped; };
|
bool IsStopped() { return Stopped; };
|
||||||
|
|
|
@ -842,7 +842,7 @@ void soft_pwm_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0)
|
#if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0)
|
||||||
void temp_runaway_check(uint8_t _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed)
|
static void temp_runaway_check(uint8_t _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed)
|
||||||
{
|
{
|
||||||
float __delta;
|
float __delta;
|
||||||
float __hysteresis = 0;
|
float __hysteresis = 0;
|
||||||
|
@ -851,7 +851,6 @@ void temp_runaway_check(uint8_t _heater_id, float _target_temperature, float _cu
|
||||||
static float __preheat_start[2] = { 0,0}; //currently just bed and one extruder
|
static float __preheat_start[2] = { 0,0}; //currently just bed and one extruder
|
||||||
static uint8_t __preheat_counter[2] = { 0,0};
|
static uint8_t __preheat_counter[2] = { 0,0};
|
||||||
static uint8_t __preheat_errors[2] = { 0,0};
|
static uint8_t __preheat_errors[2] = { 0,0};
|
||||||
|
|
||||||
|
|
||||||
if (_millis() - temp_runaway_timer[_heater_id] > 2000)
|
if (_millis() - temp_runaway_timer[_heater_id] > 2000)
|
||||||
{
|
{
|
||||||
|
@ -974,32 +973,32 @@ void temp_runaway_check(uint8_t _heater_id, float _target_temperature, float _cu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_runaway_stop(bool isPreheat, bool isBed)
|
static void temp_runaway_stop(bool isPreheat, bool isBed)
|
||||||
{
|
{
|
||||||
disable_heater();
|
if(IsStopped() == false) {
|
||||||
Sound_MakeCustom(200,0,true);
|
if (isPreheat) {
|
||||||
|
lcd_setalertstatuspgm(isBed? PSTR("BED PREHEAT ERROR") : PSTR("PREHEAT ERROR"), LCD_STATUS_CRITICAL);
|
||||||
if (isPreheat)
|
SERIAL_ERROR_START;
|
||||||
{
|
if (isBed) {
|
||||||
lcd_setalertstatuspgm(isBed? PSTR("BED PREHEAT ERROR") : PSTR("PREHEAT ERROR"), LCD_STATUS_CRITICAL);
|
SERIAL_ERRORLNPGM(" THERMAL RUNAWAY (PREHEAT HEATBED)");
|
||||||
SERIAL_ERROR_START;
|
} else {
|
||||||
isBed ? SERIAL_ERRORLNPGM(" THERMAL RUNAWAY (PREHEAT HEATBED)") : SERIAL_ERRORLNPGM(" THERMAL RUNAWAY (PREHEAT HOTEND)");
|
SERIAL_ERRORLNPGM(" THERMAL RUNAWAY (PREHEAT HOTEND)");
|
||||||
|
}
|
||||||
hotendFanSetFullSpeed();
|
} else {
|
||||||
}
|
lcd_setalertstatuspgm(isBed? PSTR("BED THERMAL RUNAWAY") : PSTR("THERMAL RUNAWAY"), LCD_STATUS_CRITICAL);
|
||||||
else
|
SERIAL_ERROR_START;
|
||||||
{
|
if (isBed) {
|
||||||
lcd_setalertstatuspgm(isBed? PSTR("BED THERMAL RUNAWAY") : PSTR("THERMAL RUNAWAY"), LCD_STATUS_CRITICAL);
|
SERIAL_ERRORLNPGM(" HEATBED THERMAL RUNAWAY");
|
||||||
SERIAL_ERROR_START;
|
} else {
|
||||||
isBed ? SERIAL_ERRORLNPGM(" HEATBED THERMAL RUNAWAY") : SERIAL_ERRORLNPGM(" HOTEND THERMAL RUNAWAY");
|
SERIAL_ERRORLNPGM(" HOTEND THERMAL RUNAWAY");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Stop();
|
if (farm_mode) {
|
||||||
|
prusa_statistics(0);
|
||||||
if (farm_mode) {
|
prusa_statistics(isPreheat? 91 : 90);
|
||||||
prusa_statistics(0);
|
}
|
||||||
prusa_statistics(isPreheat? 91 : 90);
|
|
||||||
}
|
}
|
||||||
|
ThermalStop();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1011,12 +1010,12 @@ enum { LCDALERT_NONE = 0, LCDALERT_HEATERMINTEMP, LCDALERT_BEDMINTEMP, LCDALERT_
|
||||||
|
|
||||||
//! remember the last alert message sent to the LCD
|
//! remember the last alert message sent to the LCD
|
||||||
//! to prevent flicker and improve speed
|
//! to prevent flicker and improve speed
|
||||||
uint8_t last_alert_sent_to_lcd = LCDALERT_NONE;
|
static uint8_t last_alert_sent_to_lcd = LCDALERT_NONE;
|
||||||
|
|
||||||
|
|
||||||
//! update the current temperature error message
|
//! update the current temperature error message
|
||||||
//! @param type short error abbreviation (PROGMEM)
|
//! @param type short error abbreviation (PROGMEM)
|
||||||
void temp_update_messagepgm(const char* PROGMEM type)
|
static void temp_update_messagepgm(const char* PROGMEM type)
|
||||||
{
|
{
|
||||||
char msg[LCD_WIDTH];
|
char msg[LCD_WIDTH];
|
||||||
strcpy_P(msg, PSTR("Err: "));
|
strcpy_P(msg, PSTR("Err: "));
|
||||||
|
@ -1027,7 +1026,7 @@ void temp_update_messagepgm(const char* PROGMEM type)
|
||||||
//! signal a temperature error on both the lcd and serial
|
//! signal a temperature error on both the lcd and serial
|
||||||
//! @param type short error abbreviation (PROGMEM)
|
//! @param type short error abbreviation (PROGMEM)
|
||||||
//! @param e optional extruder index for hotend errors
|
//! @param e optional extruder index for hotend errors
|
||||||
void temp_error_messagepgm(const char* PROGMEM type, uint8_t e = EXTRUDERS)
|
static void temp_error_messagepgm(const char* PROGMEM type, uint8_t e = EXTRUDERS)
|
||||||
{
|
{
|
||||||
temp_update_messagepgm(type);
|
temp_update_messagepgm(type);
|
||||||
|
|
||||||
|
@ -1044,60 +1043,38 @@ void temp_error_messagepgm(const char* PROGMEM type, uint8_t e = EXTRUDERS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void max_temp_error(uint8_t e) {
|
static void max_temp_error(uint8_t e) {
|
||||||
disable_heater();
|
if(IsStopped() == false) {
|
||||||
if(IsStopped() == false) {
|
temp_error_messagepgm(PSTR("MAXTEMP"), e);
|
||||||
temp_error_messagepgm(PSTR("MAXTEMP"), e);
|
if (farm_mode) prusa_statistics(93);
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
||||||
Stop();
|
ThermalStop();
|
||||||
#endif
|
|
||||||
|
|
||||||
hotendFanSetFullSpeed();
|
|
||||||
if (farm_mode) { prusa_statistics(93); }
|
|
||||||
}
|
|
||||||
|
|
||||||
void min_temp_error(uint8_t e) {
|
|
||||||
#ifdef DEBUG_DISABLE_MINTEMP
|
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
disable_heater();
|
|
||||||
//if (current_temperature_ambient < MINTEMP_MINAMBIENT) return;
|
|
||||||
static const char err[] PROGMEM = "MINTEMP";
|
|
||||||
if(IsStopped() == false) {
|
|
||||||
temp_error_messagepgm(err, e);
|
|
||||||
last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP;
|
|
||||||
} else if( last_alert_sent_to_lcd != LCDALERT_HEATERMINTEMP ){ // only update, if the lcd message is to be changed (i.e. not the same as last time)
|
|
||||||
// we are already stopped due to some error, only update the status message without flickering
|
|
||||||
temp_update_messagepgm(err);
|
|
||||||
last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP;
|
|
||||||
}
|
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
|
||||||
// if( last_alert_sent_to_lcd != LCDALERT_HEATERMINTEMP ){
|
|
||||||
// last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP;
|
|
||||||
// lcd_print_stop();
|
|
||||||
// }
|
|
||||||
Stop();
|
|
||||||
#endif
|
|
||||||
if (farm_mode) { prusa_statistics(92); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bed_max_temp_error(void) {
|
static void min_temp_error(uint8_t e) {
|
||||||
disable_heater();
|
static const char err[] PROGMEM = "MINTEMP";
|
||||||
if(IsStopped() == false) {
|
if(IsStopped() == false) {
|
||||||
temp_error_messagepgm(PSTR("MAXTEMP BED"));
|
temp_error_messagepgm(err, e);
|
||||||
}
|
last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP;
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
if (farm_mode) prusa_statistics(92);
|
||||||
Stop();
|
} else if( last_alert_sent_to_lcd != LCDALERT_HEATERMINTEMP ){ // only update, if the lcd message is to be changed (i.e. not the same as last time)
|
||||||
#endif
|
// we are already stopped due to some error, only update the status message without flickering
|
||||||
|
temp_update_messagepgm(err);
|
||||||
|
last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP;
|
||||||
|
}
|
||||||
|
ThermalStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bed_min_temp_error(void) {
|
static void bed_max_temp_error(void) {
|
||||||
#ifdef DEBUG_DISABLE_MINTEMP
|
if(IsStopped() == false) {
|
||||||
return;
|
temp_error_messagepgm(PSTR("MAXTEMP BED"));
|
||||||
#endif
|
}
|
||||||
disable_heater();
|
ThermalStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bed_min_temp_error(void) {
|
||||||
static const char err[] PROGMEM = "MINTEMP BED";
|
static const char err[] PROGMEM = "MINTEMP BED";
|
||||||
if(IsStopped() == false) {
|
if(IsStopped() == false) {
|
||||||
temp_error_messagepgm(err);
|
temp_error_messagepgm(err);
|
||||||
|
@ -1107,34 +1084,23 @@ void bed_min_temp_error(void) {
|
||||||
temp_update_messagepgm(err);
|
temp_update_messagepgm(err);
|
||||||
last_alert_sent_to_lcd = LCDALERT_BEDMINTEMP;
|
last_alert_sent_to_lcd = LCDALERT_BEDMINTEMP;
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
ThermalStop();
|
||||||
Stop();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef AMBIENT_THERMISTOR
|
#ifdef AMBIENT_THERMISTOR
|
||||||
void ambient_max_temp_error(void) {
|
static void ambient_max_temp_error(void) {
|
||||||
disable_heater();
|
|
||||||
if(IsStopped() == false) {
|
if(IsStopped() == false) {
|
||||||
temp_error_messagepgm(PSTR("MAXTEMP AMB"));
|
temp_error_messagepgm(PSTR("MAXTEMP AMB"));
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
ThermalStop();
|
||||||
Stop();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ambient_min_temp_error(void) {
|
static void ambient_min_temp_error(void) {
|
||||||
#ifdef DEBUG_DISABLE_MINTEMP
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
disable_heater();
|
|
||||||
if(IsStopped() == false) {
|
if(IsStopped() == false) {
|
||||||
temp_error_messagepgm(PSTR("MINTEMP AMB"));
|
temp_error_messagepgm(PSTR("MINTEMP AMB"));
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
ThermalStop();
|
||||||
Stop();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1713,10 +1679,6 @@ void check_min_temp_ambient()
|
||||||
|
|
||||||
void handle_temp_error()
|
void handle_temp_error()
|
||||||
{
|
{
|
||||||
// TODO: Stop and the various *_error() functions need an overhaul!
|
|
||||||
// The heaters are kept disabled already at a higher level, making almost
|
|
||||||
// all the code inside the invidual handlers useless!
|
|
||||||
|
|
||||||
// relay to the original handler
|
// relay to the original handler
|
||||||
switch((TempErrorType)temp_error_state.type) {
|
switch((TempErrorType)temp_error_state.type) {
|
||||||
case TempErrorType::min:
|
case TempErrorType::min:
|
||||||
|
|
Loading…
Add table
Reference in a new issue