X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fpsensor.c;h=138b19f3a1b9a59099e93dca198a59fa0ad48d2b;hb=e57d7f801ae20f02e0cb28107a89b31fa51de1c1;hp=1973c53438fa56c6fb4c1621f8759f6997fa3469;hpb=c61f97ec1945a6555d4503acc6826e4be7c75536;p=psensor.git 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