added function to return raw int16 value

This commit is contained in:
proddy
2019-03-23 11:06:46 +01:00
parent b5ae847048
commit af5a71b7c6
2 changed files with 7 additions and 3 deletions

View File

@@ -134,7 +134,6 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
return buffer; return buffer;
} }
/* /*
* Read sensor values * Read sensor values
* *
@@ -152,7 +151,7 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
DS18B20 & DS1822: store for crc DS18B20 & DS1822: store for crc
byte 8: SCRATCHPAD_CRC byte 8: SCRATCHPAD_CRC
*/ */
double DS18::getValue(unsigned char index) { int16_t DS18::getRawValue(unsigned char index) {
if (index >= _count) if (index >= _count)
return 0; return 0;
@@ -179,8 +178,12 @@ double DS18::getValue(unsigned char index) {
// 12 bit res, 750 ms // 12 bit res, 750 ms
} }
double value = (float)raw / 16.0; return raw;
}
// return real value as a double
double DS18::getValue(unsigned char index) {
double value = (float)getRawValue(index) / 16.0;
return value; return value;
} }

View File

@@ -40,6 +40,7 @@ class DS18 {
void loop(); void loop();
char * getDeviceString(char * s, unsigned char index); char * getDeviceString(char * s, unsigned char index);
double getValue(unsigned char index); double getValue(unsigned char index);
int16_t getRawValue(unsigned char index); // raw values, needs / 16
protected: protected:
bool validateID(unsigned char id); bool validateID(unsigned char id);