Isolate sensor unit for easier post treatment

This commit is contained in:
Luc 2020-08-27 19:25:42 +02:00
parent 9be683efc3
commit a035516a20
4 changed files with 14 additions and 8 deletions

View File

@ -78,8 +78,9 @@ const char * AnalogSensorDevice::GetModelString(uint8_t i)
const char * AnalogSensorDevice::GetData()
{
static String s;
s = String(SENSOR_CONVERTER(analogRead(ESP3D_SENSOR_PIN)));
s += SENSOR__UNIT;
s = String(SENSOR_CONVERTER(analogRead(ESP3D_SENSOR_PIN))) + "[";
s += SENSOR__UNIT;
s +="]";
return s.c_str();
}

View File

@ -167,11 +167,12 @@ const char * BMX280SensorDevice::GetData()
temperature = toFahrenheit(temperature);
}
s= String(temperature,1);
s+= "[";
s+= SENSOR__UNIT;
s+= " " +String(pressure,1);
s+= "Pa";
s+= "] " +String(pressure,1);
s+= "[Pa]";
if (bmx280_device->isBME280()) {
s+=" " + String(humidity,1) + "%";
s+=" " + String(humidity,1) + "[%]";
}
} else {
s="DISCONNECTED";

View File

@ -134,8 +134,9 @@ const char * DHTSensorDevice::GetData()
}
if ( String(humidity,1)!="nan") {
s= String(temperature,1);
s+= SENSOR__UNIT;
s+=" " + String(humidity,1) + "%";
s+= "[";
s+= SENSOR__UNIT+
s+="] " + String(humidity,1) + "[%]";
} else {
s="DISCONNECTED";
log_esp3d("No valid data");

View File

@ -45,7 +45,10 @@ public:
{
return 0;
}
virtual uint8_t GetModel(uint8_t i=0){ return 0;}
virtual uint8_t GetModel(uint8_t i=0)
{
return 0;
}
virtual const char *GetModelString(uint8_t i=0)
{
return "None";