#include <libintl.h>
#define _(str) gettext(str)
-#include <sensors/sensors.h>
-#include <sensors/error.h>
-
#include "hdd.h"
#include "psensor.h"
#include "lmsensor.h"
psensor->id = id;
psensor->name = name;
psensor->enabled = 1;
- psensor->min = UNKNOWN_VALUE;
- psensor->max = UNKNOWN_VALUE;
+ psensor->min = UNKNOWN_DBL_VALUE;
+ psensor->max = UNKNOWN_DBL_VALUE;
psensor->type = type;
psensor->values_max_length = values_max_length;
- psensor->measures = measures_create(values_max_length);
+ psensor->measures = measures_dbl_create(values_max_length);
psensor->alarm_limit = 0;
cur_size = s->values_max_length;
cur_ms = s->measures;
- new_ms = measures_create(new_size);
+ new_ms = measures_dbl_create(new_size);
if (cur_ms) {
int i;
&s->measures[1],
(s->values_max_length - 1) * sizeof(struct measure));
- s->measures[s->values_max_length - 1].value = v;
+ s->measures[s->values_max_length - 1].value.d_num = v;
s->measures[s->values_max_length - 1].time = tv;
- if (s->min == UNKNOWN_VALUE || v < s->min)
+ if (s->min == UNKNOWN_DBL_VALUE || v < s->min)
s->min = v;
- if (s->max == UNKNOWN_VALUE || v > s->max)
+ if (s->max == UNKNOWN_DBL_VALUE || v > s->max)
s->max = v;
if (s->alarm_limit && s->alarm_enabled) {
double psensor_get_current_value(struct psensor *sensor)
{
- return sensor->measures[sensor->values_max_length - 1].value;
+ return sensor->measures[sensor->values_max_length - 1].value.d_num;
}
struct measure *psensor_get_current_measure(struct psensor *sensor)
*/
double get_min_value(struct psensor **sensors, int type)
{
- double m = UNKNOWN_VALUE;
+ double m = UNKNOWN_DBL_VALUE;
struct psensor **s = sensors;
while (*s) {
double t;
for (i = 0; i < sensor->values_max_length; i++) {
- t = sensor->measures[i].value;
+ t = sensor->measures[i].value.d_num;
- if (t == UNKNOWN_VALUE)
+ if (t == UNKNOWN_DBL_VALUE)
continue;
- if (m == UNKNOWN_VALUE || t < m)
+ if (m == UNKNOWN_DBL_VALUE || t < m)
m = t;
}
}
*/
static double get_max_value(struct psensor **sensors, int type)
{
- double m = UNKNOWN_VALUE;
+ double m = UNKNOWN_DBL_VALUE;
struct psensor **s = sensors;
while (*s) {
int i;
double t;
for (i = 0; i < sensor->values_max_length; i++) {
- t = sensor->measures[i].value;
+ t = sensor->measures[i].value.d_num;
- if (t == UNKNOWN_VALUE)
+ if (t == UNKNOWN_DBL_VALUE)
continue;
- if (m == UNKNOWN_VALUE || t > m)
+ if (m == UNKNOWN_DBL_VALUE || t > m)
m = t;
}
}
double
psensor_get_max_current_value(struct psensor **sensors, unsigned int type)
{
- double m = UNKNOWN_VALUE;
+ double m = UNKNOWN_DBL_VALUE;
struct psensor **s_cur = sensors;
while (*s_cur) {
if (s->enabled && (s->type & type)) {
double v = psensor_get_current_value(s);
- if (m == UNKNOWN_VALUE || v > m)
+ if (m == UNKNOWN_DBL_VALUE || v > m)
m = v;
}
struct psensor **get_all_sensors(int values_max_length)
{
struct psensor **psensors = NULL;
- int count = 0;
- const sensors_chip_name *chip;
- int chip_nr = 0;
struct psensor **tmp_psensors;
- const sensors_feature *feature;
- struct psensor *psensor;
- int i;
-
- while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
- i = 0;
- while ((feature = sensors_get_features(chip, &i))) {
-
- if (feature->type == SENSORS_FEATURE_TEMP
- || feature->type == SENSORS_FEATURE_FAN) {
-
- psensor = lmsensor_psensor_create
- (chip, feature, values_max_length);
-
- if (psensor) {
- tmp_psensors
- = psensor_list_add(psensors,
- psensor);
- free(psensors);
-
- psensors = tmp_psensors;
-
- count++;
- }
- }
- }
- }
+ psensors = lmsensor_psensor_list_add(NULL, values_max_length);
tmp_psensors = hdd_psensor_list_add(psensors, values_max_length);
if (type & SENSOR_TYPE_NVIDIA)
return "NVidia GPU Temperature";
+ if (type & SENSOR_TYPE_AMD_TEMP)
+ return "AMD GPU Temperature";
+
+ if (type & SENSOR_TYPE_AMD_FAN)
+ return "AMD GPU Fan Speed";
+
if (type & SENSOR_TYPE_HDD_TEMP)
return "HDD Temperature";
if (psensor_list_contains_type(sensors, SENSOR_TYPE_HDD_TEMP))
hdd_psensor_list_update(sensors);
}
+
+void psensor_init()
+{
+ lmsensor_init();
+}
+
+void psensor_cleanup()
+{
+ lmsensor_cleanup();
+}