1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

voltage: outsource printing code

This commit is contained in:
Phil Sutter 2009-11-13 00:24:54 +01:00
parent b25be92273
commit c8bed3a28d
3 changed files with 21 additions and 12 deletions

View File

@ -29,7 +29,8 @@ void update_threads(void);
void update_running_processes(void); void update_running_processes(void);
void update_stuff(void); void update_stuff(void);
char get_freq(char *, size_t, const char *, int, unsigned int); char get_freq(char *, size_t, const char *, int, unsigned int);
char get_voltage(char *, size_t, const char *, int, unsigned int); /* ptarjan */ void print_voltage_mv(struct text_object *, char *, int);
void print_voltage_v(struct text_object *, char *, int);
void update_load_average(void); void update_load_average(void);
void update_top(void); void update_top(void);
void free_all_processes(void); void free_all_processes(void);

View File

@ -818,18 +818,10 @@ void generate_text_internal(char *p, int p_max_size,
} }
#if defined(__linux__) #if defined(__linux__)
OBJ(voltage_mv) { OBJ(voltage_mv) {
static int ok = 1; print_voltage_mv(obj, p, p_max_size);
if (ok) {
ok = get_voltage(p, p_max_size, "%.0f", 1,
obj->data.i);
}
} }
OBJ(voltage_v) { OBJ(voltage_v) {
static int ok = 1; print_voltage_v(obj, p, p_max_size);
if (ok) {
ok = get_voltage(p, p_max_size, "%'.3f", 1000,
obj->data.i);
}
} }
#ifdef HAVE_IWLIB #ifdef HAVE_IWLIB

View File

@ -1201,7 +1201,7 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,
* Peter Tarjan (ptarjan@citromail.hu) */ * Peter Tarjan (ptarjan@citromail.hu) */
/* return cpu voltage in mV (use divisor=1) or V (use divisor=1000) */ /* return cpu voltage in mV (use divisor=1) or V (use divisor=1000) */
char get_voltage(char *p_client_buffer, size_t client_buffer_size, static char get_voltage(char *p_client_buffer, size_t client_buffer_size,
const char *p_format, int divisor, unsigned int cpu) const char *p_format, int divisor, unsigned int cpu)
{ {
FILE *f; FILE *f;
@ -1270,6 +1270,22 @@ char get_voltage(char *p_client_buffer, size_t client_buffer_size,
return 1; return 1;
} }
void print_voltage_mv(struct text_object *obj, char *p, int p_max_size)
{
static int ok = 1;
if (ok) {
ok = get_voltage(p, p_max_size, "%.0f", 1, obj->data.i);
}
}
void print_voltage_v(struct text_object *obj, char *p, int p_max_size)
{
static int ok = 1;
if (ok) {
ok = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.i);
}
}
#define ACPI_FAN_DIR "/proc/acpi/fan/" #define ACPI_FAN_DIR "/proc/acpi/fan/"
void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)