From a2185a4154e961afd9561f6ceaeb58cd577aa69f Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 14 Oct 2012 22:52:04 +0200 Subject: [PATCH] temp.c: explicitely cast the EMWA algorithm result. Contribution by DaveX, see: http://forums.reprap.org/read.php?147,33082,160633#msg-160633 --- temp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/temp.c b/temp.c index 7f348d7..9c93175 100644 --- a/temp.c +++ b/temp.c @@ -297,9 +297,9 @@ void temp_sensor_tick() { #endif #define EWMA_SCALE 1024L #define EWMA_ALPHA ((long) (TEMP_EWMA * EWMA_SCALE)) - temp_sensors_runtime[i].last_read_temp = (EWMA_ALPHA * temp + + temp_sensors_runtime[i].last_read_temp = (uint16_t) ((EWMA_ALPHA * temp + (EWMA_SCALE-EWMA_ALPHA) * temp_sensors_runtime[i].last_read_temp - ) / EWMA_SCALE; + ) / EWMA_SCALE); } if (labs((int16_t)(temp_sensors_runtime[i].last_read_temp - temp_sensors_runtime[i].target_temp)) < (TEMP_HYSTERESIS*4)) { if (temp_sensors_runtime[i].temp_residency < (TEMP_RESIDENCY_TIME*120))