X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=blobdiff_plain;f=src%2Flib%2Fpsensor.c;h=138b19f3a1b9a59099e93dca198a59fa0ad48d2b;hp=1973c53438fa56c6fb4c1621f8759f6997fa3469;hb=e57d7f801ae20f02e0cb28107a89b31fa51de1c1;hpb=6735627cdee1f90e8279d3a9c143a92c960dab18 diff --git a/src/lib/psensor.c b/src/lib/psensor.c index 1973c53..138b19f 100644 --- a/src/lib/psensor.c +++ b/src/lib/psensor.c @@ -198,7 +198,14 @@ int is_fan_type(unsigned int type) return type & SENSOR_TYPE_FAN; } -char *psensor_value_to_string(unsigned int type, double value) +static double celcius_to_fahrenheit(double c) +{ + return c * (9.0/5.0) + 32; +} + +char *psensor_value_to_string(unsigned int type, + double value, + int use_celcius) { /* should not be possible to exceed 20 characters with temp or rpm values the .x part is never displayed */ @@ -207,7 +214,12 @@ char *psensor_value_to_string(unsigned int type, double value) char *unit; if (is_temp_type(type)) - unit = "C"; + if (use_celcius) { + unit = "C"; + } else { + unit = "F"; + value = celcius_to_fahrenheit(value); + } else if (type & SENSOR_TYPE_CPU_USAGE) unit = "%"; else