psensor->measures = measures_dbl_create(values_max_length);
psensor->alarm_enabled = 0;
- psensor->alarm_high_thresold = 0;
- psensor->alarm_low_thresold = 0;
+ psensor->alarm_high_threshold = 0;
+ psensor->alarm_low_threshold = 0;
psensor->cb_alarm_raised = NULL;
psensor->cb_alarm_raised_data = NULL;
psensor->color = NULL;
+ psensor->appindicator_enabled = 0;
+
return psensor;
}
char *
psensor_value_to_str(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 */
- char *str = malloc(20);
+ char *str;
+ const char *unit;
- char *unit;
+ /*
+ * should not be possible to exceed 20 characters with temp or
+ * rpm values the .x part is never displayed
+ */
+ str = malloc(20);
- if (is_temp_type(type))
- if (use_celcius) {
- unit = "°C";
- } else {
- unit = "°F";
- value = celcius_to_fahrenheit(value);
- }
- else if (type & SENSOR_TYPE_CPU_USAGE)
- unit = "%";
- else
- unit = "";
+ unit = psensor_type_to_unit_str(type, use_celcius);
sprintf(str, "%.0f%s", value, unit);
s->max = v;
if (s->alarm_enabled) {
- if (v > s->alarm_high_thresold || v < s->alarm_low_thresold) {
+ if (v > s->alarm_high_threshold || v < s->alarm_low_threshold) {
if (!s->alarm_raised && s->cb_alarm_raised)
s->cb_alarm_raised(s, s->cb_alarm_raised_data);
const char *psensor_type_to_unit_str(unsigned int type, int use_celcius)
{
- if (type & SENSOR_TYPE_TEMP) {
+ if (is_temp_type(type)) {
if (use_celcius)
return "\302\260C";
else
return "\302\260F";
- }
-
- if (type & SENSOR_TYPE_FAN)
+ } else if (is_fan_type(type)) {
return _("RPM");
-
- if (type & SENSOR_TYPE_CPU_USAGE)
+ } else if (type & SENSOR_TYPE_CPU_USAGE) {
return _("%");
-
- return _("N/A");
+ } else {
+ return _("N/A");
+ }
}
void psensor_list_update_measures(struct psensor **sensors)