From 042d9ddfc2a944ebc7d58900e0f18d1b0fa8483d Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Fri, 30 Nov 2012 03:26:06 +0100 Subject: [PATCH] Move temp_all_zero() to heaters_all_zero(). We need the power supply for the heaters, after all, not for the temperature sensors. Some heaters (e.g. fans) don't even have a temp sensor. --- clock.c | 3 +-- heater.c | 12 ++++++++++++ heater.h | 1 + temp.c | 11 ----------- temp.h | 2 -- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/clock.c b/clock.c index 0a5c6a1..25b20a4 100644 --- a/clock.c +++ b/clock.c @@ -8,7 +8,6 @@ #include "sersendf.h" #include "dda_queue.h" #include "watchdog.h" -#include "temp.h" #include "timer.h" #include "debug.h" #include "heater.h" @@ -24,7 +23,7 @@ */ static void clock_250ms(void) { #ifndef NO_AUTO_IDLE - if (temp_all_zero()) { + if (heaters_all_zero()) { if (psu_timeout > (30 * 4)) { power_off(); } diff --git a/heater.c b/heater.c index 55bac09..60322e2 100644 --- a/heater.c +++ b/heater.c @@ -443,6 +443,18 @@ void heater_set(heater_t index, uint8_t value) { power_on(); } +/** \brief check wether all heaters are off +*/ +uint8_t heaters_all_zero() { + uint8_t i; + + for (i = 0; i < NUM_HEATERS; i++) { + if (heaters_runtime[i].heater_output) + return 0; + } + return 255; +} + /** \brief turn off all heaters for emergency stop diff --git a/heater.h b/heater.h index 082baf3..c43c26e 100644 --- a/heater.h +++ b/heater.h @@ -21,6 +21,7 @@ void heater_save_settings(void); void heater_set(heater_t index, uint8_t value); void heater_tick(heater_t h, temp_type_t type, uint16_t current_temp, uint16_t target_temp); +uint8_t heaters_all_zero(void); uint8_t heaters_all_off(void); void pid_set_p(heater_t index, int32_t p); diff --git a/temp.c b/temp.c index 400f250..306056c 100644 --- a/temp.c +++ b/temp.c @@ -341,17 +341,6 @@ 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 static void single_temp_print(temp_sensor_t index) { diff --git a/temp.h b/temp.h index 2e185f8..68d1afe 100644 --- a/temp.h +++ b/temp.h @@ -41,8 +41,6 @@ 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 */