Update usermod bme280 rounding
Apply rounding per usermod settings
This commit is contained in:
parent
9d574397bc
commit
866296fefd
@ -278,30 +278,30 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline float getTemperatureC() {
|
inline float getTemperatureC() {
|
||||||
#ifdef Celsius
|
#ifdef Celsius
|
||||||
return (float)sensorTemperature;
|
return (float)roundf(sensorTemperature * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals);
|
||||||
#else
|
#else
|
||||||
return (float)sensorTemperature * 1.8f + 32;
|
return (float)roundf(sensorTemperature * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals) * 1.8f + 32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
inline float getTemperatureF() {
|
inline float getTemperatureF() {
|
||||||
#ifdef Celsius
|
#ifdef Celsius
|
||||||
return ((float)sensorTemperature -32) * 0.56f;
|
return ((float)roundf(sensorTemperature * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals) -32) * 0.56f;
|
||||||
#else
|
#else
|
||||||
return (float)sensorTemperature;
|
return (float)roundf(sensorTemperature * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
inline float getHumidity() {
|
inline float getHumidity() {
|
||||||
return (float)sensorHumidity;
|
return (float)roundf(sensorHumidity * pow(10, HumidityDecimals));
|
||||||
}
|
}
|
||||||
inline float getPressure() {
|
inline float getPressure() {
|
||||||
return (float)sensorPressure;
|
return (float)roundf(sensorPressure * pow(10, PressureDecimals));
|
||||||
}
|
}
|
||||||
inline float getDewPoint() {
|
inline float getDewPoint() {
|
||||||
return (float)sensorDewPoint;
|
return (float)roundf(sensorDewPoint * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals);
|
||||||
}
|
}
|
||||||
inline float getHeatIndex() {
|
inline float getHeatIndex() {
|
||||||
return (float)sensorHeatIndex;
|
return (float)roundf(sensorHeatIndex * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish Sensor Information to Info Page
|
// Publish Sensor Information to Info Page
|
||||||
@ -321,10 +321,10 @@ public:
|
|||||||
|
|
||||||
JsonArray temperature_json = user.createNestedArray("Temperature");
|
JsonArray temperature_json = user.createNestedArray("Temperature");
|
||||||
JsonArray pressure_json = user.createNestedArray("Pressure");
|
JsonArray pressure_json = user.createNestedArray("Pressure");
|
||||||
temperature_json.add(sensorTemperature);
|
temperature_json.add(roundf(sensorTemperature * pow(10, TemperatureDecimals)));
|
||||||
temperature_json.add(F("°C"));
|
temperature_json.add(F("°C"));
|
||||||
pressure_json.add(sensorPressure);
|
pressure_json.add(roundf(sensorPressure * pow(10, PressureDecimals)));
|
||||||
pressure_json.add(F("°C"));
|
pressure_json.add(F("hPa"));
|
||||||
}
|
}
|
||||||
else if (sensorType==1) //BME280
|
else if (sensorType==1) //BME280
|
||||||
{
|
{
|
||||||
@ -333,29 +333,28 @@ public:
|
|||||||
JsonArray pressure_json = user.createNestedArray("Pressure");
|
JsonArray pressure_json = user.createNestedArray("Pressure");
|
||||||
JsonArray heatindex_json = user.createNestedArray("Heat Index");
|
JsonArray heatindex_json = user.createNestedArray("Heat Index");
|
||||||
JsonArray dewpoint_json = user.createNestedArray("Dew Point");
|
JsonArray dewpoint_json = user.createNestedArray("Dew Point");
|
||||||
temperature_json.add(sensorTemperature);
|
temperature_json.add(roundf(sensorTemperature * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals));
|
||||||
#ifdef Celsius
|
#ifdef Celsius
|
||||||
temperature_json.add(F("°C"));
|
temperature_json.add(F("°C"));
|
||||||
#else
|
#else
|
||||||
temperature_json.add(F("°F"));
|
temperature_json.add(F("°F"));
|
||||||
#endif
|
#endif
|
||||||
humidity_json.add(sensorHumidity);
|
humidity_json.add(roundf(sensorHumidity * pow(10, HumidityDecimals)));
|
||||||
humidity_json.add(F("%"));
|
humidity_json.add(F("%"));
|
||||||
pressure_json.add(sensorPressure);
|
pressure_json.add(roundf(sensorPressure * pow(10, PressureDecimals)));
|
||||||
pressure_json.add(F("hPa"));
|
pressure_json.add(F("hPa"));
|
||||||
heatindex_json.add(sensorHeatIndex);
|
heatindex_json.add(roundf(sensorHeatIndex * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals));
|
||||||
#ifdef Celsius
|
#ifdef Celsius
|
||||||
heatindex_json.add(F("°C"));
|
heatindex_json.add(F("°C"));
|
||||||
#else
|
#else
|
||||||
heatindex_json.add(F("°F"));
|
heatindex_json.add(F("°F"));
|
||||||
#endif
|
#endif
|
||||||
dewpoint_json.add(sensorDewPoint);
|
dewpoint_json.add(roundf(sensorDewPoint * pow(10, TemperatureDecimals)) / pow(10, TemperatureDecimals));
|
||||||
#ifdef Celsius
|
#ifdef Celsius
|
||||||
dewpoint_json.add(F("°C"));
|
dewpoint_json.add(F("°C"));
|
||||||
#else
|
#else
|
||||||
dewpoint_json.add(F("°F"));
|
dewpoint_json.add(F("°F"));
|
||||||
#endif
|
#endif
|
||||||
dewpoint_json.add(F("°C"));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user