Sha256: fb6997e829daeefe1fa89a5febeb8aab8c9a9adfafb5739f60f786c69b57a3ea
Contents?: true
Size: 773 Bytes
Versions: 14
Compression:
Stored size: 773 Bytes
Contents
#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 == +NAN || temperature == -NAN) { initialized = FALSE; temperature = -INFINITY; } temperatureInCelcius = (temperatureInCelcius * 0.75f) + (temperature * 0.25); } }
Version data entries
14 entries across 14 versions & 1 rubygems