mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 01:09:51 +03:00
added function to return raw int16 value
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user