Sha256: 04273b1c514aecffd6ebaa6740332a24b999ee022ff1d673760c9111b46f58fd

Contents?: true

Size: 812 Bytes

Versions: 41

Compression:

Stored size: 812 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

41 entries across 38 versions & 1 rubygems

Version Path
ceedling-0.29.1 vendor/cmock/examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.29.0 vendor/cmock/examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.18.0 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.17.0 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.16.0 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.15.6 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.15.5 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.15.4 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.15.3 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.15.2 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.15.1 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.15.0 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.13.0 vendor/cmock/examples/src/TemperatureFilter.c
ceedling-0.13.0 examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.13.0.rc1 examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.12.2 examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.12.1 examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.12.0 examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.11.2 examples/temp_sensor/src/TemperatureFilter.c
ceedling-0.11.1 examples/temp_sensor/src/TemperatureFilter.c