more config stuff
This commit is contained in:
@ -1,9 +1,13 @@
|
||||
#include "Thermometer.h"
|
||||
#include "Config.h"
|
||||
|
||||
using namespace nsThermometer;
|
||||
|
||||
const float INVALID_TEMPERATURE = -300.0;
|
||||
|
||||
const uint8_t CONFIG_ALPHA = 0;
|
||||
|
||||
|
||||
Thermometer::Thermometer() {
|
||||
|
||||
}
|
||||
@ -14,10 +18,11 @@ void Thermometer::begin(bool initializeConfig, int eepromAddr) {
|
||||
|
||||
if (initializeConfig) {
|
||||
// set default values
|
||||
Config::setFloat(m_eepromAddr + CONFIG_ALPHA, 1.0);
|
||||
}
|
||||
|
||||
m_lastSmoothedTemperature = INVALID_TEMPERATURE;
|
||||
m_alpha = 0.1;
|
||||
alpha = Config::setFloat(m_eepromAddr + CONFIG_ALPHA);
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +32,7 @@ void Thermometer::exec(float r) {
|
||||
if (m_lastSmoothedTemperature == INVALID_TEMPERATURE) {
|
||||
temperature = temperatureRaw;
|
||||
} else {
|
||||
temperature = m_alpha * temperatureRaw + (1 - m_alpha) * m_lastSmoothedTemperature;
|
||||
temperature = alpha * temperatureRaw + (1 - alpha) * m_lastSmoothedTemperature;
|
||||
}
|
||||
m_lastSmoothedTemperature = temperature;
|
||||
}
|
||||
|
Reference in New Issue
Block a user