Browse Source

Force temperature to have 1 decimal

fastled
Xose Pérez 7 years ago
parent
commit
8a3695f5e6
2 changed files with 3 additions and 2 deletions
  1. +1
    -1
      code/espurna/config/sensors.h
  2. +2
    -1
      code/espurna/dht.ino

+ 1
- 1
code/espurna/config/sensors.h View File

@ -36,9 +36,9 @@
#define DHT_UPDATE_INTERVAL 60000 #define DHT_UPDATE_INTERVAL 60000
#endif #endif
#define DHT_TIMING 11
#define DHT_TEMPERATURE_TOPIC "temperature" #define DHT_TEMPERATURE_TOPIC "temperature"
#define DHT_HUMIDITY_TOPIC "humidity" #define DHT_HUMIDITY_TOPIC "humidity"
#define DHT_TEMPERATURE_DECIMALS 1 // Decimals for temperature values
#define HUMIDITY_NORMAL 0 #define HUMIDITY_NORMAL 0
#define HUMIDITY_COMFORTABLE 1 #define HUMIDITY_COMFORTABLE 1


+ 2
- 1
code/espurna/dht.ino View File

@ -136,7 +136,8 @@ int readDHT() {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
double getDHTTemperature(bool celsius) { double getDHTTemperature(bool celsius) {
return celsius ? _dhtTemperature : _dhtTemperature * 1.8 + 32;
double value = celsius ? _dhtTemperature : _dhtTemperature * 1.8 + 32;
return roundTo(value, DHT_TEMPERATURE_DECIMALS);
} }
double getDHTTemperature() { double getDHTTemperature() {


Loading…
Cancel
Save