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

This commit is contained in:
Michael Moon 2011-05-27 17:23:59 +10:00
parent e05e12c9e0
commit a68ae12679
3 changed files with 27 additions and 10 deletions

View File

@ -23,10 +23,12 @@
called from clock_10ms(), do not call directly called from clock_10ms(), do not call directly
*/ */
void clock_250ms() { void clock_250ms() {
#ifndef NO_AUTO_IDLE
if (temp_all_zero()) {
if (steptimeout > (30 * 4)) { if (steptimeout > (30 * 4)) {
power_off(); power_off();
} }
else if (heaters_all_off()) { else {
uint8_t save_reg = SREG; uint8_t save_reg = SREG;
cli(); cli();
CLI_SEI_BUG_MEMORY_BARRIER(); CLI_SEI_BUG_MEMORY_BARRIER();
@ -34,6 +36,8 @@ void clock_250ms() {
MEMORY_BARRIER(); MEMORY_BARRIER();
SREG = save_reg; SREG = save_reg;
} }
}
#endif
ifclock(clock_flag_1s) { ifclock(clock_flag_1s) {
if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) { if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {

11
temp.c
View File

@ -326,6 +326,17 @@ uint16_t temp_get(temp_sensor_t index) {
return temp_sensors_runtime[index].last_read_temp; 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 // extruder doesn't have sersendf_P
#ifndef EXTRUDER #ifndef EXTRUDER
/// send temperatures to host /// send temperatures to host

2
temp.h
View File

@ -41,6 +41,8 @@ uint8_t temp_achieved(void);
void temp_set(temp_sensor_t index, uint16_t temperature); void temp_set(temp_sensor_t index, uint16_t temperature);
uint16_t temp_get(temp_sensor_t index); uint16_t temp_get(temp_sensor_t index);
uint8_t temp_all_zero(void);
void temp_print(temp_sensor_t index); void temp_print(temp_sensor_t index);
#endif /* _TEMP_H */ #endif /* _TEMP_H */