From 86e89dbac6aaabe25d156709ea6d152601ee12bf Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 14 Oct 2012 22:50:28 +0200 Subject: [PATCH] heater.c: review on/off behaviour again. D'oh, this wasn't compiling without BANG_BANG. --- heater.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/heater.c b/heater.c index 8d1e127..008ed25 100644 --- a/heater.c +++ b/heater.c @@ -69,6 +69,12 @@ struct { uint8_t heater_output; ///< this is the PID value we eventually send to the heater } heaters_runtime[NUM_HEATERS]; +#ifdef BANG_BANG + #define HEATER_THRESHOLD ((BANG_BANG_ON + BANG_BANG_OFF) / 2) +#else + #define HEATER_THRESHOLD 8 +#endif + /// default scaled P factor, equivalent to 8.0 #define DEFAULT_P 8192 /// default scaled I factor, equivalent to 0.5 @@ -429,7 +435,7 @@ void heater_set(heater_t index, uint8_t value) { #endif } else { - if (value >= ((BANG_BANG_ON + BANG_BANG_OFF) / 2)) + if (value >= HEATER_THRESHOLD) *(heaters[index].heater_port) |= MASK(heaters[index].heater_pin); else *(heaters[index].heater_port) &= ~MASK(heaters[index].heater_pin);