postponed kill() message with softReset

This commit is contained in:
Alex Voinea 2023-03-30 13:50:32 +02:00
parent 82343184e7
commit f388d8abb6
No known key found for this signature in database
GPG Key ID: 37EDFD565CB33BAD
6 changed files with 45 additions and 48 deletions

View File

@ -234,7 +234,7 @@ void FlushSerialRequestResend();
void ClearToSend();
void update_currents();
void kill(const char *full_screen_message = NULL, unsigned char id = 0);
void kill(const char *full_screen_message = NULL);
void finishAndDisableSteppers();
void UnconditionalStop(); // Stop heaters, motion and clear current print status

View File

@ -1037,6 +1037,17 @@ static void fw_crash_init()
eeprom_update_byte((uint8_t*)EEPROM_FW_CRASH_FLAG, 0xFF);
}
static void fw_kill_init() {
PGM_P kill_msg = (PGM_P)eeprom_init_default_word((uint16_t*)EEPROM_KILL_MESSAGE, 0);
if (kill_msg) {
// clear pending message event
eeprom_write_word((uint16_t*)EEPROM_KILL_MESSAGE, 0);
// display the kill message
lcd_show_fullscreen_message_and_wait_P(kill_msg);
}
}
static void xflash_err_msg()
{
@ -1577,6 +1588,9 @@ void setup()
// report crash failures
fw_crash_init();
// report kill() events
fw_kill_init();
#ifdef UVLO_SUPPORT
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != 0) { //previous print was terminated by UVLO
/*
@ -5970,7 +5984,7 @@ Sigma_Exit:
It is processed much earlier as to bypass the cmdqueue.
*/
case 112:
kill(MSG_M112_KILL, 3);
kill(MSG_M112_KILL);
break;
/*!
@ -9378,7 +9392,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
if(previous_millis_cmd.expired(max_inactive_time))
if(max_inactive_time)
kill(_n("Inactivity Shutdown"), 4);
kill(PSTR("Inactivity Shutdown"));
if(stepper_inactive_time) {
if(previous_millis_cmd.expired(stepper_inactive_time))
{
@ -9419,7 +9433,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
// ----------------------------------------------------------------
if ( killCount >= KILL_DELAY)
{
kill(NULL, 5);
kill();
}
#endif
@ -9465,49 +9479,30 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
host_keepalive();
}
void kill(const char *full_screen_message, unsigned char id)
{
printf_P(_N("KILL: %d\n"), id);
//return;
cli(); // Stop interrupts
disable_heater();
void kill(const char *full_screen_message) {
cli(); // Stop interrupts
disable_heater();
disable_x();
// SERIAL_ECHOLNPGM("kill - disable Y");
disable_y();
poweroff_z();
disable_e0();
disable_e1();
disable_e2();
disable_x();
disable_y();
poweroff_z();
disable_e0();
disable_e1();
disable_e2();
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
pinMode(PS_ON_PIN,INPUT);
#endif
SERIAL_ERROR_START;
SERIAL_ERRORLNRPGM(_n("Printer halted. kill() called!"));////MSG_ERR_KILLED
if (full_screen_message != NULL) {
SERIAL_ERRORLNRPGM(full_screen_message);
lcd_display_message_fullscreen_P(full_screen_message);
} else {
LCD_ALERTMESSAGERPGM(_n("KILLED. "));////MSG_KILLED
}
SERIAL_ERROR_START;
SERIAL_ERRORLNRPGM(PSTR("Printer halted. kill() called!"));
// FMC small patch to update the LCD before ending
sei(); // enable interrupts
for ( int i=5; i--; lcd_update(0))
{
_delay(200);
}
cli(); // disable interrupts
suicide();
while(1)
{
#ifdef WATCHDOG
wdt_reset();
#endif //WATCHDOG
/* Intentionally left empty */
} // Wait for reset
if (full_screen_message != NULL) {
SERIAL_ERRORLNRPGM(full_screen_message);
} else {
full_screen_message = PSTR("KILLED.");
}
// update eeprom with the correct kill message to be shown on startup
eeprom_write_word((uint16_t*)EEPROM_KILL_MESSAGE, (uint16_t)full_screen_message);
softReset();
}
void UnconditionalStop()

View File

@ -402,7 +402,7 @@ void CardReader::openFileReadFilteredGcode(const char* name, bool replace_curren
// SERIAL_ERROR_START;
// SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
// SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
kill(ofKill, 1);
kill(ofKill);
return;
}
@ -469,7 +469,7 @@ void CardReader::openFileWrite(const char* name)
// SERIAL_ERROR_START;
// SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
// SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
kill(ofKill, 1);
kill(ofKill);
return;
}

View File

@ -455,7 +455,7 @@ void get_command()
// Handle KILL early, even when Stopped
if(strcmp_P(cmd_start, PSTR("M112")) == 0)
kill(MSG_M112_KILL, 2);
kill(MSG_M112_KILL);
// Bypass Stopped for some commands
bool allow_when_stopped = false;

View File

@ -596,6 +596,8 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
#define EEPROM_TEMP_MODEL_L (EEPROM_TEMP_MODEL_D-2) //uint16_t
#define EEPROM_TEMP_MODEL_VER (EEPROM_TEMP_MODEL_L-1) //uint8_t
#define EEPROM_KILL_MESSAGE (EEPROM_TEMP_MODEL_VER-2) //PGM_P
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
#define EEPROM_LAST_ITEM EEPROM_TEMP_MODEL_VER
// !!!!!

View File

@ -598,7 +598,7 @@ static float analog2temp(int raw, uint8_t e) {
SERIAL_ERROR_START;
SERIAL_ERROR((int)e);
SERIAL_ERRORLNPGM(" - Invalid extruder number !");
kill(NULL, 6);
kill();
return 0.0;
}
#ifdef HEATER_0_USES_MAX6675