thermometer stuff

This commit is contained in:
Wolfgang Hottgenroth
2014-11-17 19:17:09 +01:00
parent b426dbd570
commit 33a8a35bf8
5 changed files with 52 additions and 11 deletions

View File

@ -2,18 +2,27 @@
using namespace nsThermometer;
const float INVALID_TEMPERATURE = -300.0;
Thermometer::Thermometer() {
}
void Thermometer::begin() {
m_lastSmoothedTemperature = 0.0;
void Thermometer::begin(int eepromAddr) {
m_eepromAddr = eepromAddr;
m_lastSmoothedTemperature = INVALID_TEMPERATURE;
m_alpha = 0.1;
}
void Thermometer::exec(float r) {
temperatureRaw = (r / PT1000_R0 - 1) / PT1000_Coeff;
if (m_lastSmoothedTemperature == INVALID_TEMPERATURE) {
temperature = temperatureRaw;
} else {
temperature = m_alpha * temperatureRaw + (1 - m_alpha) * m_lastSmoothedTemperature;
}
m_lastSmoothedTemperature = temperature;
}