From f4a93ed99771c000cf66303a32e55fbba4a6bfd1 Mon Sep 17 00:00:00 2001
From: AnHardt <github@kitelab.de>
Date: Wed, 20 May 2015 20:53:48 +0200
Subject: [PATCH] Add a string parameter to kill()

Makes the output on the LCD adjustable.
---
 Marlin/Marlin.h        |  2 +-
 Marlin/Marlin_main.cpp | 15 +++++++--------
 Marlin/cardreader.cpp  |  2 +-
 Marlin/watchdog.cpp    |  5 +----
 4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h
index 592b4027a8..7eff6a1e68 100644
--- a/Marlin/Marlin.h
+++ b/Marlin/Marlin.h
@@ -220,7 +220,7 @@ void ok_to_send();
 #endif
 void reset_bed_level();
 void prepare_move();
-void kill();
+void kill(const char *);
 void Stop();
 
 #ifdef FILAMENT_RUNOUT_SENSOR
diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index efc14ea426..7282adeb90 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -838,7 +838,7 @@ void get_command() {
       }
 
       // If command was e-stop process now
-      if (strcmp(command, "M112") == 0) kill();
+      if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
 
       cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
       commands_in_queue += 1;
@@ -3593,7 +3593,7 @@ inline void gcode_M111() {
 /**
  * M112: Emergency Stop
  */
-inline void gcode_M112() { kill(); }
+inline void gcode_M112() { kill(PSTR(MSG_KILLED)); }
 
 #ifdef BARICUDA
 
@@ -6244,7 +6244,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
 
   millis_t ms = millis();
 
-  if (max_inactive_time && ms > previous_cmd_ms + max_inactive_time) kill();
+  if (max_inactive_time && ms > previous_cmd_ms + max_inactive_time) kill(PSTR(MSG_KILLED));
 
   if (stepper_inactive_time && ms > previous_cmd_ms + stepper_inactive_time
       && !ignore_stepper_queue && !blocks_queued())
@@ -6272,7 +6272,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
     // Exceeded threshold and we can confirm that it was not accidental
     // KILL the machine
     // ----------------------------------------------------------------
-    if (killCount >= KILL_DELAY) kill();
+    if (killCount >= KILL_DELAY) kill(PSTR(MSG_KILLED));
   #endif
 
   #if HAS_HOME
@@ -6373,11 +6373,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
   check_axes_activity();
 }
 
-void kill()
-{
+void kill(const char *lcd_msg) {
+  lcd_setalertstatuspgm(lcd_msg);
+
   cli(); // Stop interrupts
   disable_all_heaters();
-
   disable_all_steppers();
 
   #if HAS_POWER_SWITCH
@@ -6386,7 +6386,6 @@ void kill()
 
   SERIAL_ERROR_START;
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
-  LCD_ALERTMESSAGEPGM(MSG_KILLED);
   
   // FMC small patch to update the LCD before ending
   sei();   // enable interrupts
diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp
index a2a6d8eb51..95b9f353ff 100644
--- a/Marlin/cardreader.cpp
+++ b/Marlin/cardreader.cpp
@@ -219,7 +219,7 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/)
        SERIAL_ERROR_START;
        SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
        SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
-       kill();
+       kill(PSTR(MSG_KILLED));
        return;
      }
 
diff --git a/Marlin/watchdog.cpp b/Marlin/watchdog.cpp
index 8505f7efac..d9127c54f8 100644
--- a/Marlin/watchdog.cpp
+++ b/Marlin/watchdog.cpp
@@ -43,12 +43,9 @@ void watchdog_reset()
 #ifdef WATCHDOG_RESET_MANUAL
 ISR(WDT_vect)
 { 
-    //TODO: This message gets overwritten by the kill() call
-    LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
-    lcd_update();
     SERIAL_ERROR_START;
     SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
-    kill(); //kill blocks
+    kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display
     while(1); //wait for user or serial reset
 }
 #endif//RESET_MANUAL