Skip to content

Commit 5b6d9ea

Browse files
committed
Fix Clang
1 parent c59b15b commit 5b6d9ea

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

Adafruit_BME280.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -447,39 +447,37 @@ float Adafruit_BME280::readAltitude(float seaLevel) {
447447
return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903));
448448
}
449449

450-
/*!
451-
* Computes Heat Index based on https://byjus.com/heat-index-formula/
452-
* @param isCelcius - if true return Heat Index in degrees celcius else return
453-
* in Farenheit
454-
*/
455-
float Adafruit_BME280::readHeatIndex(bool isCelcius){
456-
float tempF = readTemperature() * 1.8 + 32;
457-
float humidity = readHumidity();
458-
float hi = 0.5 * (tempF + 61.0 + ((tempF - 68.0) * 1.2) + (humidity * 0.094));
459-
460-
if (hi > 79) {
461-
hi = -42.379 + 2.04901523 * tempF + 10.14333127 * humidity +
462-
-0.22475541 * tempF * humidity + -0.00683783 * pow(tempF, 2) +
450+
/*!
451+
* Computes Heat Index based on https://byjus.com/heat-index-formula/
452+
* @param isCelcius - if true return Heat Index in degrees celcius else return
453+
* in Farenheit
454+
*/
455+
float Adafruit_BME280::readHeatIndex(bool isCelcius) {
456+
float tempF = readTemperature() * 1.8 + 32;
457+
float humidity = readHumidity();
458+
float hi = 0.5 * (tempF + 61.0 + ((tempF - 68.0) * 1.2) + (humidity * 0.094));
459+
460+
if (hi > 79) {
461+
hi = -42.379 + 2.04901523 * tempF + 10.14333127 * humidity +
462+
-0.22475541 * tempF * humidity + -0.00683783 * pow(tempF, 2) +
463463
-0.05481717 * pow(humidity, 2) +
464464
0.00122874 * pow(tempF, 2) * humidity +
465465
0.00085282 * tempF * pow(humidity, 2) +
466466
-0.00000199 * pow(tempF, 2) * pow(humidity, 2);
467467

468+
if ((humidity < 13) && (tempF >= 80.0) && (tempF <= 112.0))
469+
hi -= ((13.0 - humidity) * 0.25) *
470+
sqrt((17.0 - abs(tempF - 95.0)) * 0.05882);
468471

469-
if ((humidity < 13) && (tempF >= 80.0) && (tempF <= 112.0))
470-
hi -= ((13.0 - humidity) * 0.25) *
471-
sqrt((17.0 - abs(tempF - 95.0)) * 0.05882);
472+
else if ((humidity > 85.0) && (tempF >= 80.0) && (tempF <= 87.0))
473+
hi += ((humidity - 85.0) * 0.1) * ((87.0 - tempF) * 0.2);
474+
}
472475

473-
else if ((humidity > 85.0) && (tempF >= 80.0) && (tempF <= 87.0))
474-
hi += ((humidity - 85.0) * 0.1) * ((87.0 - tempF) * 0.2);
475-
476-
}
477-
478-
if (isCelcius)
479-
return (hi - 32) * 0.5556; // convert back to celcius
480-
else
481-
return hi;
482-
}
476+
if (isCelcius)
477+
return (hi - 32) * 0.5556; // convert back to celcius
478+
else
479+
return hi;
480+
}
483481

484482
/*!
485483
* Calculates the pressure at sea level (in hPa) from the specified

0 commit comments

Comments
 (0)