/*
- * Copyright (C) 2010-2013 jeanfi@gmail.com
+ * Copyright (C) 2010-2014 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
unsigned int type,
int values_max_length)
{
- struct psensor *psensor
- = (struct psensor *)malloc(sizeof(struct psensor));
+ struct psensor *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->graph_enabled = 1;
psensor->appindicator_enabled = 0;
return psensor;
return type & SENSOR_TYPE_FAN;
}
-double celcius_to_fahrenheit(double c)
+double celsius_to_fahrenheit(double c)
{
return c * (9.0/5.0) + 32;
}
-double fahrenheit_to_celcius(double f)
+double fahrenheit_to_celsius(double f)
{
return (f - 32) * (5.0/9.0);
}
char *
-psensor_value_to_str(unsigned int type, double value, int use_celcius)
+psensor_value_to_str(unsigned int type, double value, int use_celsius)
{
char *str;
const char *unit;
*/
str = malloc(20);
- unit = psensor_type_to_unit_str(type, use_celcius);
+ unit = psensor_type_to_unit_str(type, use_celsius);
- if (is_temp_type(type) && !use_celcius)
- value = celcius_to_fahrenheit(value);
+ if (is_temp_type(type) && !use_celsius)
+ value = celsius_to_fahrenheit(value);
sprintf(str, "%.0f%s", value, unit);
char *
psensor_measure_to_str(const struct measure *m,
unsigned int type,
- unsigned int use_celcius)
+ unsigned int use_celsius)
{
- return psensor_value_to_str(type, m->value, use_celcius);
+ return psensor_value_to_str(type, m->value, use_celsius);
}
void psensor_set_current_value(struct psensor *sensor, double value)
Returns the minimal value of a given 'type' (SENSOR_TYPE_TEMP or
SENSOR_TYPE_FAN)
*/
-double get_min_value(struct psensor **sensors, int type)
+static double get_min_value(struct psensor **sensors, int type)
{
double m = UNKNOWN_DBL_VALUE;
struct psensor **s = sensors;
while (*s) {
struct psensor *sensor = *s;
- if (sensor->enabled && (sensor->type & type)) {
+ if (sensor->type & type) {
int i;
double t;
while (*s) {
struct psensor *sensor = *s;
- if (sensor->enabled && (sensor->type & type)) {
+ if (sensor->type & type) {
int i;
double t;
for (i = 0; i < sensor->values_max_length; i++) {
while (*s_cur) {
struct psensor *s = *s_cur;
- if (s->enabled && (s->type & type)) {
+ if (s->graph_enabled && (s->type & type)) {
double v = psensor_get_current_value(s);
if (m == UNKNOWN_DBL_VALUE || v > m)
}
-const char *psensor_type_to_unit_str(unsigned int type, int use_celcius)
+const char *psensor_type_to_unit_str(unsigned int type, int use_celsius)
{
if (is_temp_type(type)) {
- if (use_celcius)
+ if (use_celsius)
return "\302\260C";
else
return "\302\260F";
}
char *
-psensor_current_value_to_str(const struct psensor *s, unsigned int celcius)
+psensor_current_value_to_str(const struct psensor *s, unsigned int use_celsius)
{
return psensor_value_to_str(s->type,
psensor_get_current_value(s),
- celcius);
+ use_celsius);
+}
+
+struct psensor **psensor_list_filter_graph_enabled(struct psensor **sensors)
+{
+ int n, i;
+ struct psensor **result, **cur, *s;
+
+ if (!sensors)
+ return NULL;
+
+ n = psensor_list_size(sensors);
+ result = malloc((n+1) * sizeof(struct psensor *));
+
+ for (cur = sensors, i = 0; *cur; cur++) {
+ s = *cur;
+
+ if (s->graph_enabled)
+ result[i++] = s;
+ }
+
+ result[i] = NULL;
+
+ return result;
}