blob: 02fc045061daff364d86f2fe221ee5a90877f2c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#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);
}
}
|