/*
- * Copyright (C) 2010-2012 jeanfi@gmail.com
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
#include "cpu.h"
#endif
-
-struct psensor *psensor_create(char *id, char *name,
- unsigned int type, int values_max_length)
+struct psensor *psensor_create(char *id,
+ char *name,
+ char *chip,
+ unsigned int type,
+ int values_max_length)
{
struct psensor *psensor
= (struct psensor *)malloc(sizeof(struct psensor));
psensor->id = id;
psensor->name = name;
+ psensor->chip = chip;
psensor->enabled = 1;
psensor->min = UNKNOWN_DBL_VALUE;
psensor->max = UNKNOWN_DBL_VALUE;
psensor->color = NULL;
+ psensor->appindicator_enabled = 0;
+
return psensor;
}
free(sensor->name);
free(sensor->id);
+ if (sensor->chip)
+ free(sensor->chip);
+
if (sensor->color)
free(sensor->color);
s = sensors;
while (*s) {
- if ((*s)->type == type)
+ if ((*s)->type & type)
return 1;
s++;
}
unit = psensor_type_to_unit_str(type, use_celcius);
+ if (is_temp_type(type) && !use_celcius)
+ value = celcius_to_fahrenheit(value);
+
sprintf(str, "%.0f%s", value, unit);
return str;
struct psensor **get_all_sensors(int use_libatasmart, int values_max_length)
{
- struct psensor **psensors = NULL;
+ struct psensor **psensors;
struct psensor **tmp_psensors;
psensors = lmsensor_psensor_list_add(NULL, values_max_length);
const char *psensor_type_to_str(unsigned int type)
{
- if ((type & SENSOR_TYPE_NVIDIA_TEMP) == SENSOR_TYPE_NVIDIA_TEMP)
- return "NVidia GPU Temperature";
+ if (type & SENSOR_TYPE_NVCTRL)
+ return "NVidia GPU";
- if ((type & SENSOR_TYPE_AMD_TEMP) == SENSOR_TYPE_AMD_TEMP)
- return "AMD GPU Temperature";
-
- if ((type & SENSOR_TYPE_AMD_FAN) == SENSOR_TYPE_AMD_FAN)
- return "AMD GPU Fan Speed";
+ if (type & SENSOR_TYPE_ATIADL) {
+ if (type & SENSOR_TYPE_TEMP)
+ return "AMD GPU Temperature";
+ else if (type & SENSOR_TYPE_RPM)
+ return "AMD GPU Fan Speed";
+ else /* type & SENSOR_TYPE_USAGE */
+ return "AMD GPU Usage";
+ }
if ((type & SENSOR_TYPE_HDD_TEMP) == SENSOR_TYPE_HDD_TEMP)
return "HDD Temperature";
- if (type & SENSOR_TYPE_CPU_USAGE)
+ if ((type & SENSOR_TYPE_CPU_USAGE) == SENSOR_TYPE_CPU_USAGE)
return "CPU Usage";
if (type & SENSOR_TYPE_TEMP)
if (type & SENSOR_TYPE_FAN)
return "Fan";
+ if (type & SENSOR_TYPE_CPU)
+ return "CPU";
+
if (type & SENSOR_TYPE_REMOTE)
return "Remote";
- return "N/A"; /* should not be possible */
+ return "N/A";
}
cpu_psensor_list_update(sensors);
#endif
- if (psensor_list_contains_type(sensors, SENSOR_TYPE_HDD_TEMP_HDDTEMP))
+ if (psensor_list_contains_type(sensors, SENSOR_TYPE_HDDTEMP))
hddtemp_psensor_list_update(sensors);
#ifdef HAVE_ATASMART
- if (psensor_list_contains_type(sensors,
- SENSOR_TYPE_HDD_TEMP_ATASMART))
+ if (psensor_list_contains_type(sensors, SENSOR_TYPE_ATASMART))
hdd_psensor_list_update(sensors);
#endif
}
{
lmsensor_cleanup();
}
+
+struct psensor **psensor_list_copy(struct psensor **sensors)
+{
+ struct psensor **result;
+ int n, i;
+
+ n = psensor_list_size(sensors);
+ result = malloc((n+1) * sizeof(struct psensor *));
+ for (i = 0; i < n; i++)
+ result[i] = sensors[i];
+ result[n] = NULL;
+
+ return result;
+}
+