diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 07dd0d8bf..e56b67128 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -79,18 +79,6 @@ extern float homing_feedrate[]; extern bool axis_relative_modes[]; -inline void kill() -{ - disable_heater(); - - disable_x(); - disable_y(); - disable_z(); - disable_e(); - - if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT); - Serial.println("!! Printer halted. kill() called !!"); - while(1); // Wait for reset -} +void kill(); #endif diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 6a6fb80f4..1c79af6ca 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -1278,3 +1278,18 @@ void manage_inactivity(byte debug) { check_axes_activity(); } +void kill() +{ + disable_heater(); + + disable_x(); + disable_y(); + disable_z(); + disable_e(); + + if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT); + Serial.println("!! Printer halted. kill() called !!"); + while(1); // Wait for reset +} + + diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 0c5a2e4ce..14530ca3f 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -36,6 +36,7 @@ #include "ultralcd.h" #include "streaming.h" #include "temperature.h" +#include "watchdog.h" int target_raw[3] = {0, 0, 0}; @@ -350,6 +351,28 @@ void setWatch() } +void disable_heater() +{ + #if TEMP_0_PIN > -1 + target_raw[0]=0; + #if HEATER_0_PIN > -1 + WRITE(HEATER_0_PIN,LOW); + #endif + #endif + #if TEMP_1_PIN > -1 + target_raw[1]=0; + #if HEATER_1_PIN > -1 + WRITE(HEATER_1_PIN,LOW); + #endif + #endif + #if TEMP_2_PIN > -1 + target_raw[2]=0; + #if HEATER_2_PIN > -1 + WRITE(HEATER_2_PIN,LOW); + #endif + #endif +} + // Timer 0 is shared with millies ISR(TIMER0_COMPB_vect) { diff --git a/Marlin/temperature.h b/Marlin/temperature.h index fcc8edb9e..44d54db14 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -42,7 +42,7 @@ extern int target_raw[3]; extern int current_raw[3]; extern float Kp,Ki,Kd,Kc; #ifdef PIDTEMP - float pid_setpoint = 0.0; + extern float pid_setpoint ; #endif #ifdef WATCHPERIOD extern int watch_raw[3] ; @@ -81,38 +81,9 @@ inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];}; inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];}; -inline void disable_heater() -{ - #if TEMP_0_PIN > -1 - target_raw[0]=0; - #if HEATER_0_PIN > -1 - WRITE(HEATER_0_PIN,LOW); - #endif - #endif - #if TEMP_1_PIN > -1 - target_raw[1]=0; - #if HEATER_1_PIN > -1 - WRITE(HEATER_1_PIN,LOW); - #endif - #endif - #if TEMP_2_PIN > -1 - target_raw[2]=0; - #if HEATER_2_PIN > -1 - WRITE(HEATER_2_PIN,LOW); - #endif - #endif -} -void setWatch() { - if(isHeatingHotend0()) - { - watchmillis = max(1,millis()); - watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0]; - } - else - { - watchmillis = 0; - } -} +void disable_heater(); +void setWatch(); + #ifdef HEATER_0_USES_THERMISTOR #define HEATERSOURCE 1 #endif diff --git a/Marlin/watchdog.h b/Marlin/watchdog.h index 2577bc138..7dd31f9f7 100644 --- a/Marlin/watchdog.h +++ b/Marlin/watchdog.h @@ -1,10 +1,13 @@ #ifndef __WATCHDOGH #define __WATCHDOGH -#ifdef +#include "Configuration.h" +//#ifdef USE_WATCHDOG + /// intialise watch dog with a 1 sec interrupt time void wd_init(); /// pad the dog/reset watchdog. MUST be called at least every second after the first wd_init or avr will go into emergency procedures.. void wd_reset(); +//#endif #endif diff --git a/Marlin/watchdog.cpp b/Marlin/watchdog.pde similarity index 98% rename from Marlin/watchdog.cpp rename to Marlin/watchdog.pde index 0adf9cc7d..4c677e79e 100644 --- a/Marlin/watchdog.cpp +++ b/Marlin/watchdog.pde @@ -1,5 +1,5 @@ #ifdef USE_WATCHDOG - +#include "watchdog.h" #include #include diff --git a/watchdog.cpp b/watchdog.cpp deleted file mode 100644 index 0adf9cc7d..000000000 --- a/watchdog.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifdef USE_WATCHDOG - -#include -#include - -volatile uint8_t timeout_seconds=0; - -void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560 - -//Watchdog timer interrupt, called if main program blocks >1sec -ISR(WDT_vect) -{ - if(timeout_seconds++ >= WATCHDOG_TIMEOUT) - { - - #ifdef RESET_MANUAL - LCD_MESSAGE("Please Reset!"); - ECHOLN("echo_: Something is wrong, please turn off the printer."); - #else - LCD_MESSAGE("Timeout, resetting!"); - #endif - //disable watchdog, it will survife reboot. - WDTCSR |= (1<