Skip to content

Commit

Permalink
sns: handle all of available temperature conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Jan 31, 2022
1 parent 2338f54 commit e51e259
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions code/espurna/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,13 @@ double _magnitudeProcess(const sensor_magnitude_t& magnitude, double value) {

// Process input (sensor) units and convert to the ones that magnitude specifies as output
switch (magnitude.sensor->units(magnitude.slot)) {
case sensor::Unit::Kelvin:
if (magnitude.units == sensor::Unit::Farenheit) {
value = (value * (9.0/5.0)) + 32.0;
} else if (magnitude.units == sensor::Unit::Celcius) {
value = value - 273.15;
}
break;
case sensor::Unit::Celcius:
if (magnitude.units == sensor::Unit::Farenheit) {
value = (value * 1.8) + 32.0;
Expand Down

0 comments on commit e51e259

Please sign in to comment.