From a68ae12679470168bba560ce91f5358f0eba09a6 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Fri, 27 May 2011 17:23:59 +1000 Subject: [PATCH] add NO_AUTO_IDLE option to prevent powercuts after inactivity, add temp_all_zero so power isn't cut if heater remains off for a while but has a non-zero set temperature --- clock.c | 24 ++++++++++++++---------- temp.c | 11 +++++++++++ temp.h | 2 ++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/clock.c b/clock.c index c83af71..80ee617 100644 --- a/clock.c +++ b/clock.c @@ -23,17 +23,21 @@ called from clock_10ms(), do not call directly */ void clock_250ms() { - if (steptimeout > (30 * 4)) { - power_off(); - } - else if (heaters_all_off()) { - uint8_t save_reg = SREG; - cli(); - CLI_SEI_BUG_MEMORY_BARRIER(); - steptimeout++; - MEMORY_BARRIER(); - SREG = save_reg; + #ifndef NO_AUTO_IDLE + if (temp_all_zero()) { + if (steptimeout > (30 * 4)) { + power_off(); + } + else { + uint8_t save_reg = SREG; + cli(); + CLI_SEI_BUG_MEMORY_BARRIER(); + steptimeout++; + MEMORY_BARRIER(); + SREG = save_reg; + } } + #endif ifclock(clock_flag_1s) { if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) { diff --git a/temp.c b/temp.c index df42697..b32b91b 100644 --- a/temp.c +++ b/temp.c @@ -326,6 +326,17 @@ uint16_t temp_get(temp_sensor_t index) { return temp_sensors_runtime[index].last_read_temp; } +uint8_t temp_all_zero() { + uint8_t i; + for (i = 0; i < NUM_TEMP_SENSORS; i++) { + if (temp_sensors[i].heater < NUM_HEATERS) { + if (temp_sensors_runtime[i].target_temp) + return 0; + } + } + return 255; +} + // extruder doesn't have sersendf_P #ifndef EXTRUDER /// send temperatures to host diff --git a/temp.h b/temp.h index 68d1afe..2e185f8 100644 --- a/temp.h +++ b/temp.h @@ -41,6 +41,8 @@ uint8_t temp_achieved(void); void temp_set(temp_sensor_t index, uint16_t temperature); uint16_t temp_get(temp_sensor_t index); +uint8_t temp_all_zero(void); + void temp_print(temp_sensor_t index); #endif /* _TEMP_H */