sensord: Use the same colors for daily and weekly charts.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5070 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2007-12-11 21:48:34 +00:00
1 parent 4f8196934c
commit e257a45fed
2 files changed
+26 -1

No files matched your search

+1
View File
@@ -9,6 +9,7 @@ SVN
Deal gracefully with read-only pwm_enable files
Warn about outputs found in automatic mode
sensord: Fix rrd support (#2276)
Use the same colors for daily and weekly charts
sensors-detect: Drop PCA9540 detection
3.0.0 (2007-11-24)
+25 -1
View File
@@ -294,12 +294,36 @@ rrdCGI_DEF
return 0;
}
/* Compute an arbitrary color based on the sensor label. This is preferred
over a random value because this guarantees that daily and weekly charts
will use the same colors. */
static int
rrdCGI_color
(const char *label) {
unsigned long color = 0, brightness;
const char *c;
for (c = label; *c; c++) {
color = (color << 6) + (color >> (*c & 7));
color ^= (*c) * 0x401;
}
color &= 0xffffff;
/* Adjust very light colors */
brightness = (color & 0xff) + ((color >> 8) & 0xff) + (color >> 16);
if (brightness > 672)
color &= 0x7f7f7f;
/* Adjust very dark colors */
else if (brightness < 96)
color |= 0x808080;
return color;
}
static int
rrdCGI_LINE
(void *_data, const char *rawLabel, const char *label, const FeatureDescriptor *feature) {
struct gr *data = (struct gr *) _data;
if (!feature || (feature->rrd && (feature->type == data->type)))
printf ("\n\tLINE2:%s#%.6x:\"%s\"", rawLabel, (int) random () & 0xffffff, label);
printf ("\n\tLINE2:%s#%.6x:\"%s\"", rawLabel, rrdCGI_color(label), label);
return 0;
}