diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index ddb758a12..28ebf9f11 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -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 diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 155c6fd2b..a124c9be0 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1037,6 +1037,19 @@ static void fw_crash_init() eeprom_update_byte((uint8_t*)EEPROM_FW_CRASH_FLAG, 0xFF); } +#define KILL_PENDING_FLAG 0x42 + +static void fw_kill_init() { + if (eeprom_read_byte((uint8_t*)EEPROM_KILL_PENDING_FLAG) == KILL_PENDING_FLAG) { + // clear pending message event + eeprom_write_byte((uint8_t*)EEPROM_KILL_PENDING_FLAG, EEPROM_EMPTY_VALUE); + + // display the kill message + PGM_P kill_msg = (PGM_P)eeprom_read_word((uint16_t*)EEPROM_KILL_MESSAGE); + lcd_show_fullscreen_message_and_wait_P(kill_msg); + } +} + static void xflash_err_msg() { @@ -1344,6 +1357,9 @@ void setup() if (!xflash_success) xflash_err_msg(); + // report kill() events + fw_kill_init(); + #ifdef FILAMENT_SENSOR fsensor.init(); #endif //FILAMENT_SENSOR @@ -5970,7 +5986,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 +9394,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 +9435,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s // ---------------------------------------------------------------- if ( killCount >= KILL_DELAY) { - kill(NULL, 5); + kill(); } #endif @@ -9465,49 +9481,31 @@ 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); + eeprom_write_byte((uint8_t*)EEPROM_KILL_PENDING_FLAG, KILL_PENDING_FLAG); + + softReset(); } void UnconditionalStop() diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 8b902b703..3f437af1f 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -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; } diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 76962dffc..6d31ab9c7 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -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; diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index ae9185eb1..e54984d53 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -357,10 +357,13 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 20h 32 | ^ | Free bit | ^ | ^ | ^ | ^ | ^ | 40h 64 | ^ | Free bit | ^ | ^ | ^ | ^ | ^ | 80h 128 | ^ | Unknown | ^ | ^ -| 0x0CA5 3237 | float | EEPROM_TEMP_MODEL_U | ??? | ff ff ff ffh | Temp model linear temperature coefficient (W/K/W) | Temp model | D3 Ax0ca5 C4 -| 0x0CA1 3233 | float | EEPROM_TEMP_MODEL_V | ??? | ff ff ff ffh | Temp model linear temperature intercept (W/W) | Temp model | D3 Ax0ca1 C4 -| 0x0C9D 3229 | float | EEPROM_TEMP_MODEL_D | ??? | ff ff ff ffh | Temp model sim. 1st order IIR filter factor | Temp model | D3 Ax0c9d C4 -| 0x0C99 3225 | uint16 | EEPROM_TEMP_MODEL_L | 0-2160 | ff ffh | Temp model sim. response lag (ms) | Temp model | D3 Ax0c99 C2 +| 0x0CA2 3234 | float | EEPROM_TEMP_MODEL_U | ??? | ff ff ff ffh | Temp model linear temperature coefficient (W/K/W) | Temp model | D3 Ax0ca2 C4 +| 0x0C9E 3230 | float | EEPROM_TEMP_MODEL_V | ??? | ff ff ff ffh | Temp model linear temperature intercept (W/W) | Temp model | D3 Ax0c9e C4 +| 0x0C9A 3226 | float | EEPROM_TEMP_MODEL_D | ??? | ff ff ff ffh | Temp model sim. 1st order IIR filter factor | Temp model | D3 Ax0c9a C4 +| 0x0C98 3224 | uint16 | EEPROM_TEMP_MODEL_L | 0-2160 | ff ffh | Temp model sim. response lag (ms) | Temp model | D3 Ax0c98 C2 +| 0x0C97 3223 | uint8 | EEPROM_TEMP_MODEL_VER | 0-255 | ffh | Temp model Version | Temp model | D3 Ax0c97 C1 +| 0x0C95 3221 | PGM_P | EEPROM_KILL_MESSAGE | 0-65535 | ff ffh | Kill message PGM pointer | kill() | D3 Ax0c95 C2 +| 0x0C94 3220 | uint8 | EEPROM_KILL_PENDING_FLAG | 42h, ffh | ffh | Kill pending flag (0x42 magic value) | kill() | D3 Ax0c94 C1 |Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: @@ -596,8 +599,11 @@ 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 +#define EEPROM_KILL_PENDING_FLAG (EEPROM_KILL_MESSAGE-1) //uint8 + //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 +#define EEPROM_LAST_ITEM EEPROM_KILL_PENDING_FLAG // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index c5ef0d5b7..5dab747bd 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -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