Sha256: 66f5248499b8a4e371b3f005be285c8e789f34fcb47066c52d2035924c365685
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
/* ========================================================================= CMock - Automatic Mock Generation for C ThrowTheSwitch.org Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT ========================================================================= */ #include "Types.h" #include "TemperatureFilter.h" #include <math.h> static bool initialized; static float temperatureInCelcius; void TemperatureFilter_Init(void) { initialized = FALSE; temperatureInCelcius = -INFINITY; } float TemperatureFilter_GetTemperatureInCelcius(void) { return temperatureInCelcius; } void TemperatureFilter_ProcessInput(float temperature) { if (!initialized) { temperatureInCelcius = temperature; initialized = TRUE; } else { if (temperature == +INFINITY || temperature == -INFINITY || temperature != temperature) { /* Check if +/- Infinity or NaN... reset to -Inf in this instance. */ initialized = FALSE; temperatureInCelcius = -INFINITY; } else { /* Otherwise apply our low-pass filter to smooth the values */ temperatureInCelcius = (temperatureInCelcius * 0.75f) + (temperature * 0.25); } } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ceedling-1.0.1 | vendor/cmock/examples/temp_sensor/src/TemperatureFilter.c |
ceedling-1.0.0 | vendor/cmock/examples/temp_sensor/src/TemperatureFilter.c |