fixed --wdir option.
[psensor.git] / src / lib / psensor.c
index 1973c53..ac6a5a5 100644 (file)
@@ -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)
+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
@@ -437,10 +449,14 @@ const char *psensor_type_to_str(unsigned int type)
 }
 
 
-const char *psensor_type_to_unit_str(unsigned int type)
+const char *psensor_type_to_unit_str(unsigned int type, int use_celcius)
 {
-       if (type & SENSOR_TYPE_TEMP)
-               return _("C");
+       if (type & SENSOR_TYPE_TEMP) {
+               if (use_celcius)
+                       return _("C");
+               else
+                       return _("F");
+       }
 
        if (type & SENSOR_TYPE_FAN)
                return _("RPM");
@@ -469,6 +485,18 @@ void psensor_list_update_measures(struct psensor **sensors)
 #endif
 }
 
+void psensor_log_measures(struct psensor **sensors)
+{
+       if (log_level == LOG_DEBUG)
+               while (*sensors) {
+                       log_debug("Measure: %s %.2f",
+                                  (*sensors)->name,
+                                  psensor_get_current_value(*sensors));
+
+                       sensors++;
+               }
+}
+
 void psensor_init()
 {
        lmsensor_init();