mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Patch to fix rounding error with CPU values.
This commit is contained in:
parent
6477962dc9
commit
5552f4135e
@ -1,6 +1,7 @@
|
||||
2009-05-17
|
||||
* Added support for the Lua programming language
|
||||
* Added support for rending images by way of IMLIB2
|
||||
* Patch to fix rounding error with CPU values (thanks Filipe)
|
||||
|
||||
2009-05-11
|
||||
* Added arguments to hwmon for value precalculation
|
||||
|
13
src/common.c
13
src/common.c
@ -463,7 +463,8 @@ void update_stuff(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
int round_to_int(float f)
|
||||
/* Ohkie to return negative values for temperatures */
|
||||
int round_to_int_temp(float f)
|
||||
{
|
||||
if (f >= 0.0) {
|
||||
return (int) (f + 0.5);
|
||||
@ -471,3 +472,13 @@ int round_to_int(float f)
|
||||
return (int) (f - 0.5);
|
||||
}
|
||||
}
|
||||
/* Don't return negative values for cpugraph, bar, gauge, percentage.
|
||||
* Causes unreasonable numbers to show */
|
||||
unsigned int round_to_int(float f)
|
||||
{
|
||||
if (f >= 0.0) {
|
||||
return (int) (f + 0.5);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,9 @@ void format_seconds_short(char *buf, unsigned int n, long t);
|
||||
void update_x11info(void);
|
||||
#endif
|
||||
|
||||
int round_to_int(float);
|
||||
int round_to_int_temp(float);
|
||||
|
||||
unsigned int round_to_int(float);
|
||||
|
||||
extern unsigned long long need_mask;
|
||||
extern int no_buffers;
|
||||
|
@ -3534,7 +3534,7 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
|
||||
}
|
||||
OBJ(cpugraph) {
|
||||
new_graph(p, obj->a, obj->b, obj->c, obj->d, (unsigned int)
|
||||
new_graph(p, obj->a, obj->b, obj->c, obj->d,
|
||||
round_to_int(cur->cpu_usage[obj->data.cpu_index] * 100),
|
||||
100, 1, obj->showaslog);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ int temp_print(char *p, size_t p_max_size, double n, enum TEMP_UNIT input_unit)
|
||||
int out;
|
||||
size_t plen;
|
||||
|
||||
out = round_to_int(convert_temp_output(n, input_unit));
|
||||
out = round_to_int_temp(convert_temp_output(n, input_unit));
|
||||
plen = spaced_print(p, p_max_size, "%d", 3, out);
|
||||
|
||||
return !(plen >= p_max_size);
|
||||
|
Loading…
Reference in New Issue
Block a user