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))