more config stuff
This commit is contained in:
12
ads1210.cpp
12
ads1210.cpp
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user