more config stuff

This commit is contained in:
Wolfgang Hottgenroth
2014-11-17 20:08:49 +01:00
parent c5a21fd827
commit 5b30486f5b
6 changed files with 39 additions and 14 deletions

View File

@ -10,9 +10,13 @@
// #include "Streaming.h"
#include "ads1210.h"
#include "fatal.h"
#include "Config.h"
const uint8_t CONFIG_CAL_OFFSET = 0;
const uint8_t CONFIG_CAL_FACTOR = 2;
void ADS1210::enableCS() const {
digitalWrite(m_csPin, LOW);
@ -80,7 +84,7 @@ void ADS1210::exec() {
u = (((float)value) / ((float)vMax)) * U_REF;
rRaw = ((((float)vMax) / ((float)value)) - 1.0) * R_REF;
r = (rRaw + m_calOffset) * m_calFactor;
r = (rRaw + calOffset) * calFactor;
}
}
@ -108,6 +112,8 @@ void ADS1210::begin(uint8_t csPin, uint8_t drdyPin, bool initializeConfig, int e
if (initializeConfig) {
// set default values
Config::setFloat(m_eepromAddr + CONFIG_CAL_OFFSET, 0.0);
Config::setFloat(m_eepromAddr + CONFIG_CAL_FACTOR, 1.0)
}
// initialization of SPI
@ -138,8 +144,8 @@ void ADS1210::begin(uint8_t csPin, uint8_t drdyPin, bool initializeConfig, int e
waitForDRdy();
// Serial << "done." << endl;
m_calOffset = 0.0;
m_calFactor = 1.0;
calOffset = Config::getFloat(m_eepromAddr + CONFIG_CAL_OFFSET);
calFactor = Config::getFloat(m_eepromAddr + CONFIG_CAL_FACTOR);
}