Apply style to all client files.
This commit is contained in:
@@ -139,14 +139,14 @@ battery_screen(int rep, int display, int *flags_ptr)
|
|||||||
(acstat == LCDP_AC_ON && battstat == LCDP_BATT_ABSENT) ? "AC" : "Batt",
|
(acstat == LCDP_AC_ON && battstat == LCDP_BATT_ABSENT) ? "AC" : "Batt",
|
||||||
tmp, get_hostname());
|
tmp, get_hostname());
|
||||||
|
|
||||||
if (lcd_hgt >= 4) { // 4-line version of the screen
|
if (lcd_hgt >= 4) { /* 4-line version of the screen */
|
||||||
sock_printf(sock, "widget_set B one 1 2 {AC: %s}\n", ac_status(acstat));
|
sock_printf(sock, "widget_set B one 1 2 {AC: %s}\n", ac_status(acstat));
|
||||||
sock_printf(sock, "widget_set B two 1 3 {Batt: %s}\n", battery_status(battstat));
|
sock_printf(sock, "widget_set B two 1 3 {Batt: %s}\n", battery_status(battstat));
|
||||||
if (percent > 0)
|
if (percent > 0)
|
||||||
sock_printf(sock, "widget_set B gauge 2 4 %d\n",
|
sock_printf(sock, "widget_set B gauge 2 4 %d\n",
|
||||||
(percent * gauge_wid * lcd_cellwid) / 100);
|
(percent * gauge_wid * lcd_cellwid) / 100);
|
||||||
}
|
}
|
||||||
else { // two-line version of the screen
|
else { /* two-line version of the screen */
|
||||||
sock_printf(sock, "widget_set B one 1 2 {%sBatt: %s}\n",
|
sock_printf(sock, "widget_set B one 1 2 {%sBatt: %s}\n",
|
||||||
(acstat == LCDP_AC_ON) ? "AC, " : "",
|
(acstat == LCDP_AC_ON) ? "AC, " : "",
|
||||||
battery_status(battstat));
|
battery_status(battstat));
|
||||||
|
|||||||
+29
-26
@@ -97,16 +97,17 @@ time_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_send_string(sock, "widget_add T two string\n");
|
sock_send_string(sock, "widget_add T two string\n");
|
||||||
sock_send_string(sock, "widget_add T three string\n");
|
sock_send_string(sock, "widget_add T three string\n");
|
||||||
|
|
||||||
// write title bar: OS name, OS version, hostname
|
/* write title bar: OS name, OS version, hostname */
|
||||||
sock_printf(sock, "widget_set T title {%s %s: %s}\n",
|
sock_printf(sock, "widget_set T title {%s %s: %s}\n",
|
||||||
get_sysname(), get_sysrelease(), get_hostname());
|
get_sysname(), get_sysrelease(), get_hostname());
|
||||||
} else {
|
}
|
||||||
// write title bar: hostname
|
else {
|
||||||
|
/* write title bar: hostname */
|
||||||
sock_printf(sock, "widget_set T title {TIME: %s}\n", get_hostname());
|
sock_printf(sock, "widget_set T title {TIME: %s}\n", get_hostname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggle colon display
|
/* toggle colon display */
|
||||||
heartbeat ^= 1;
|
heartbeat ^= 1;
|
||||||
|
|
||||||
time(&thetime);
|
time(&thetime);
|
||||||
@@ -119,11 +120,11 @@ time_screen(int rep, int display, int *flags_ptr)
|
|||||||
tickTime(now, heartbeat);
|
tickTime(now, heartbeat);
|
||||||
|
|
||||||
if (lcd_hgt >= 4) {
|
if (lcd_hgt >= 4) {
|
||||||
char tmp[40]; // should be large enough
|
char tmp[40]; /* should be large enough */
|
||||||
|
|
||||||
machine_get_uptime(&uptime, &idle);
|
machine_get_uptime(&uptime, &idle);
|
||||||
|
|
||||||
// display the uptime...
|
/* display the uptime... */
|
||||||
days = (int) uptime / 86400;
|
days = (int) uptime / 86400;
|
||||||
hour = ((int) uptime % 86400) / 3600;
|
hour = ((int) uptime % 86400) / 3600;
|
||||||
min = ((int) uptime % 3600) / 60;
|
min = ((int) uptime % 3600) / 60;
|
||||||
@@ -139,18 +140,18 @@ time_screen(int rep, int display, int *flags_ptr)
|
|||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set T one %i 2 {%s}\n", xoffs, tmp);
|
sock_printf(sock, "widget_set T one %i 2 {%s}\n", xoffs, tmp);
|
||||||
|
|
||||||
// display the date
|
/* display the date */
|
||||||
xoffs = (lcd_wid > strlen(today)) ? ((lcd_wid - strlen(today)) / 2) + 1 : 1;
|
xoffs = (lcd_wid > strlen(today)) ? ((lcd_wid - strlen(today)) / 2) + 1 : 1;
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set T two %i 3 {%s}\n", xoffs, today);
|
sock_printf(sock, "widget_set T two %i 3 {%s}\n", xoffs, today);
|
||||||
|
|
||||||
// display the time & idle time...
|
/* display the time & idle time... */
|
||||||
sprintf(tmp, "%s %3i%% idle", now, (int) idle);
|
sprintf(tmp, "%s %3i%% idle", now, (int) idle);
|
||||||
xoffs = (lcd_wid > strlen(tmp)) ? ((lcd_wid - strlen(tmp)) / 2) + 1 : 1;
|
xoffs = (lcd_wid > strlen(tmp)) ? ((lcd_wid - strlen(tmp)) / 2) + 1 : 1;
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set T three %i 4 {%s}\n", xoffs, tmp);
|
sock_printf(sock, "widget_set T three %i 4 {%s}\n", xoffs, tmp);
|
||||||
}
|
}
|
||||||
else { // 2 line version of the screen
|
else { /* 2 line version of the screen */
|
||||||
xoffs = (lcd_wid > (strlen(today) + strlen(now) + 1))
|
xoffs = (lcd_wid > (strlen(today) + strlen(now) + 1))
|
||||||
? ((lcd_wid - ((strlen(today) + strlen(now) + 1))) / 2) + 1 : 1;
|
? ((lcd_wid - ((strlen(today) + strlen(now) + 1))) / 2) + 1 : 1;
|
||||||
if (display)
|
if (display)
|
||||||
@@ -158,7 +159,7 @@ time_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End time_screen()
|
} /* End time_screen() */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,7 +194,7 @@ clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
struct tm *rtime;
|
struct tm *rtime;
|
||||||
|
|
||||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
char tmp[257]; // should be large enough for host name
|
char tmp[257]; /* should be large enough for host name */
|
||||||
|
|
||||||
*flags_ptr |= INITIALIZED;
|
*flags_ptr |= INITIALIZED;
|
||||||
|
|
||||||
@@ -214,12 +215,13 @@ clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
sprintf(tmp, "%s", get_hostname());
|
sprintf(tmp, "%s", get_hostname());
|
||||||
xoffs = (lcd_wid > strlen(tmp)) ? (((lcd_wid - strlen(tmp)) / 2) + 1) : 1;
|
xoffs = (lcd_wid > strlen(tmp)) ? (((lcd_wid - strlen(tmp)) / 2) + 1) : 1;
|
||||||
sock_printf(sock, "widget_set O one %i 2 {%s}\n", xoffs, tmp);
|
sock_printf(sock, "widget_set O one %i 2 {%s}\n", xoffs, tmp);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sock_printf(sock, "widget_set O title {TIME: %s}\n", get_hostname());
|
sock_printf(sock, "widget_set O title {TIME: %s}\n", get_hostname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggle colon display
|
/* toggle colon display */
|
||||||
heartbeat ^= 1;
|
heartbeat ^= 1;
|
||||||
|
|
||||||
time(&thetime);
|
time(&thetime);
|
||||||
@@ -231,7 +233,7 @@ clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
*now = '\0';
|
*now = '\0';
|
||||||
tickTime(now, heartbeat);
|
tickTime(now, heartbeat);
|
||||||
|
|
||||||
if (lcd_hgt >= 4) { // 4-line version of the screen
|
if (lcd_hgt >= 4) { /* 4-line version of the screen */
|
||||||
xoffs = (lcd_wid > strlen(today)) ? ((lcd_wid - strlen(today)) / 2) + 1 : 1;
|
xoffs = (lcd_wid > strlen(today)) ? ((lcd_wid - strlen(today)) / 2) + 1 : 1;
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set O two %i 3 {%s}\n", xoffs, today);
|
sock_printf(sock, "widget_set O two %i 3 {%s}\n", xoffs, today);
|
||||||
@@ -240,7 +242,7 @@ clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set O three %i 4 {%s}\n", xoffs, now);
|
sock_printf(sock, "widget_set O three %i 4 {%s}\n", xoffs, now);
|
||||||
}
|
}
|
||||||
else { // 2-line version of the screen
|
else { /* 2-line version of the screen */
|
||||||
xoffs = (lcd_wid > (strlen(today) + strlen(now) + 1))
|
xoffs = (lcd_wid > (strlen(today) + strlen(now) + 1))
|
||||||
? ((lcd_wid - ((strlen(today) + strlen(now) + 1))) / 2) + 1 : 1;
|
? ((lcd_wid - ((strlen(today) + strlen(now) + 1))) / 2) + 1 : 1;
|
||||||
if (display)
|
if (display)
|
||||||
@@ -248,7 +250,7 @@ clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End clock_screen()
|
} /* End clock_screen() */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -277,7 +279,7 @@ uptime_screen(int rep, int display, int *flags_ptr)
|
|||||||
int days, hour, min, sec;
|
int days, hour, min, sec;
|
||||||
double uptime, idle;
|
double uptime, idle;
|
||||||
static int heartbeat = 0;
|
static int heartbeat = 0;
|
||||||
char tmp[257]; // should be large enough for host name
|
char tmp[257]; /* should be large enough for host name */
|
||||||
|
|
||||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
*flags_ptr |= INITIALIZED;
|
*flags_ptr |= INITIALIZED;
|
||||||
@@ -299,7 +301,8 @@ uptime_screen(int rep, int display, int *flags_ptr)
|
|||||||
sprintf(tmp, "%s %s", get_sysname(), get_sysrelease());
|
sprintf(tmp, "%s %s", get_sysname(), get_sysrelease());
|
||||||
xoffs = (lcd_wid > strlen(tmp)) ? (((lcd_wid - strlen(tmp)) / 2) + 1) : 1;
|
xoffs = (lcd_wid > strlen(tmp)) ? (((lcd_wid - strlen(tmp)) / 2) + 1) : 1;
|
||||||
sock_printf(sock, "widget_set U three %i 4 {%s}\n", xoffs, tmp);
|
sock_printf(sock, "widget_set U three %i 4 {%s}\n", xoffs, tmp);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sock_send_string(sock, "widget_add U one string\n");
|
sock_send_string(sock, "widget_add U one string\n");
|
||||||
|
|
||||||
sock_printf(sock, "widget_set U title {%s %s: %s}\n",
|
sock_printf(sock, "widget_set U title {%s %s: %s}\n",
|
||||||
@@ -307,7 +310,7 @@ uptime_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggle colon display
|
/* toggle colon display */
|
||||||
heartbeat ^= 1;
|
heartbeat ^= 1;
|
||||||
|
|
||||||
machine_get_uptime(&uptime, &idle);
|
machine_get_uptime(&uptime, &idle);
|
||||||
@@ -330,7 +333,7 @@ uptime_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End uptime_screen()
|
} /* End uptime_screen() */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,7 +369,7 @@ big_clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
int digits = (lcd_wid >= 20) ? 6 : 4;
|
int digits = (lcd_wid >= 20) ? 6 : 4;
|
||||||
int xoffs = (lcd_wid + 1 - (pos[digits - 1] + 2)) / 2;
|
int xoffs = (lcd_wid + 1 - (pos[digits - 1] + 2)) / 2;
|
||||||
|
|
||||||
// toggle colon display
|
/* toggle colon display */
|
||||||
heartbeat ^= 1;
|
heartbeat ^= 1;
|
||||||
|
|
||||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
@@ -403,19 +406,19 @@ big_clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heartbeat) { // 10 means: colon
|
if (heartbeat) { /* 10 means: colon */
|
||||||
sock_printf(sock, "widget_set K c0 %d 10\n", xoffs + 7);
|
sock_printf(sock, "widget_set K c0 %d 10\n", xoffs + 7);
|
||||||
if (digits > 4)
|
if (digits > 4)
|
||||||
sock_printf(sock, "widget_set K c1 %d 10\n", xoffs + 14);
|
sock_printf(sock, "widget_set K c1 %d 10\n", xoffs + 14);
|
||||||
}
|
}
|
||||||
else { // kludge: use illegal number to clear colon display
|
else { /* kludge: use illegal number to clear colon display */
|
||||||
sock_printf(sock, "widget_set K c0 %d 11\n", xoffs + 7);
|
sock_printf(sock, "widget_set K c0 %d 11\n", xoffs + 7);
|
||||||
if (digits > 4)
|
if (digits > 4)
|
||||||
sock_printf(sock, "widget_set K c1 %d 11\n", xoffs + 14);
|
sock_printf(sock, "widget_set K c1 %d 11\n", xoffs + 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End big_clock_screen()
|
} /* End big_clock_screen() */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,7 +450,7 @@ mini_clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
static int heartbeat = 0;
|
static int heartbeat = 0;
|
||||||
int xoffs;
|
int xoffs;
|
||||||
|
|
||||||
// toggle colon display
|
/* toggle colon display */
|
||||||
heartbeat ^= 1;
|
heartbeat ^= 1;
|
||||||
|
|
||||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
@@ -472,7 +475,7 @@ mini_clock_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_printf(sock, "widget_set N one %d %d {%s}\n", xoffs, (lcd_hgt / 2), now);
|
sock_printf(sock, "widget_set N one %d %d {%s}\n", xoffs, (lcd_hgt / 2), now);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End mini_clock_screen()
|
} /* End mini_clock_screen() */
|
||||||
|
|
||||||
|
|
||||||
/** Helper function: toggle between ':' and ' ' in time strings.
|
/** Helper function: toggle between ':' and ' ' in time strings.
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
#ifndef CHRONO_H
|
|
||||||
#define CHRONO_H
|
|
||||||
|
|
||||||
int clock_screen(int rep, int display, int *flags_ptr);
|
|
||||||
int uptime_screen(int rep, int display, int *flags_ptr);
|
|
||||||
int time_screen(int rep, int display, int *flags_ptr);
|
|
||||||
int big_clock_screen(int rep, int display, int *flags_ptr);
|
|
||||||
int mini_clock_screen(int rep, int display, int *flags_ptr);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
+19
-30
@@ -52,14 +52,14 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
{
|
{
|
||||||
#undef CPU_BUF_SIZE
|
#undef CPU_BUF_SIZE
|
||||||
#define CPU_BUF_SIZE 4
|
#define CPU_BUF_SIZE 4
|
||||||
static double cpu[CPU_BUF_SIZE + 1][5]; // last buffer is scratch
|
static double cpu[CPU_BUF_SIZE + 1][5]; /* last buffer is scratch */
|
||||||
static int gauge_wid = 0;
|
static int gauge_wid = 0;
|
||||||
static int usni_wid = 0;
|
static int usni_wid = 0;
|
||||||
|
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
double value;
|
double value;
|
||||||
load_type load;
|
load_type load;
|
||||||
char tmp[25]; // should be large enough
|
char tmp[25]; /* should be large enough */
|
||||||
|
|
||||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
*flags_ptr |= INITIALIZED;
|
*flags_ptr |= INITIALIZED;
|
||||||
@@ -67,7 +67,7 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_send_string(sock, "screen_add C\n");
|
sock_send_string(sock, "screen_add C\n");
|
||||||
sock_printf(sock, "screen_set C -name {CPU Use: %s}\n", get_hostname());
|
sock_printf(sock, "screen_set C -name {CPU Use: %s}\n", get_hostname());
|
||||||
if (lcd_hgt >= 4) {
|
if (lcd_hgt >= 4) {
|
||||||
gauge_wid = lcd_wid - 6; // room between 0%...100%
|
gauge_wid = lcd_wid - 6; /* room between 0%...100% */
|
||||||
|
|
||||||
sock_send_string(sock, "widget_add C title title\n");
|
sock_send_string(sock, "widget_add C title title\n");
|
||||||
sock_send_string(sock, "widget_set C title {CPU LOAD}\n");
|
sock_send_string(sock, "widget_set C title {CPU LOAD}\n");
|
||||||
@@ -87,8 +87,8 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_send_string(sock, "widget_set C bar 3 4 0\n");
|
sock_send_string(sock, "widget_set C bar 3 4 0\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
usni_wid = (lcd_wid - 4) / 4; // 4 gauges + 1 letter for each
|
usni_wid = (lcd_wid - 4) / 4; /* 4 gauges + 1 letter for each */
|
||||||
gauge_wid = lcd_wid - 12; // room between [...]
|
gauge_wid = lcd_wid - 12; /* room between [...] */
|
||||||
|
|
||||||
sock_send_string(sock, "widget_add C cpu string\n");
|
sock_send_string(sock, "widget_add C cpu string\n");
|
||||||
sock_printf(sock, "widget_set C cpu 1 1 {CPU [%*s]}\n", gauge_wid, "");
|
sock_printf(sock, "widget_set C cpu 1 1 {CPU [%*s]}\n", gauge_wid, "");
|
||||||
@@ -110,12 +110,12 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
machine_get_load(&load);
|
machine_get_load(&load);
|
||||||
|
|
||||||
// Shift values over by one
|
/* Shift values over by one */
|
||||||
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
||||||
for (j = 0; j < 5; j++)
|
for (j = 0; j < 5; j++)
|
||||||
cpu[i][j] = cpu[i + 1][j];
|
cpu[i][j] = cpu[i + 1][j];
|
||||||
|
|
||||||
// Read new data
|
/* Read new data */
|
||||||
if (load.total > 0L) {
|
if (load.total > 0L) {
|
||||||
cpu[CPU_BUF_SIZE - 1][0] = 100.0 * ((double) load.user / (double) load.total);
|
cpu[CPU_BUF_SIZE - 1][0] = 100.0 * ((double) load.user / (double) load.total);
|
||||||
cpu[CPU_BUF_SIZE - 1][1] = 100.0 * ((double) load.system / (double) load.total);
|
cpu[CPU_BUF_SIZE - 1][1] = 100.0 * ((double) load.system / (double) load.total);
|
||||||
@@ -131,17 +131,7 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
|
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Average values for final result */
|
||||||
// Only clear on first display...
|
|
||||||
if (!rep) {
|
|
||||||
// Make all the same, if this is the first time...
|
|
||||||
for (i=0; i < CPU_BUF_SIZE-1; i++)
|
|
||||||
for (j=0; j < 5; j++)
|
|
||||||
cpu[i][j] = cpu[CPU_BUF_SIZE-1][j];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Average values for final result
|
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
value = 0.0;
|
value = 0.0;
|
||||||
for (j = 0; j < CPU_BUF_SIZE; j++)
|
for (j = 0; j < CPU_BUF_SIZE; j++)
|
||||||
@@ -153,7 +143,7 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
if (!display)
|
if (!display)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (lcd_hgt >= 4) { // 4-line display
|
if (lcd_hgt >= 4) { /* 4-line display */
|
||||||
sprintf_percent(tmp, cpu[CPU_BUF_SIZE][4]);
|
sprintf_percent(tmp, cpu[CPU_BUF_SIZE][4]);
|
||||||
sock_printf(sock, "widget_set C title {CPU %5s: %s}\n", tmp, get_hostname());
|
sock_printf(sock, "widget_set C title {CPU %5s: %s}\n", tmp, get_hostname());
|
||||||
|
|
||||||
@@ -172,7 +162,7 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
n = (int) ((cpu[CPU_BUF_SIZE][4] * lcd_cellwid * gauge_wid) / 100.0);
|
n = (int) ((cpu[CPU_BUF_SIZE][4] * lcd_cellwid * gauge_wid) / 100.0);
|
||||||
sock_printf(sock, "widget_set C bar 3 4 %d\n", n);
|
sock_printf(sock, "widget_set C bar 3 4 %d\n", n);
|
||||||
}
|
}
|
||||||
else { // 2-line display
|
else { /* 2-line display */
|
||||||
sprintf_percent(tmp, cpu[CPU_BUF_SIZE][4]);
|
sprintf_percent(tmp, cpu[CPU_BUF_SIZE][4]);
|
||||||
sock_printf(sock, "widget_set C cpu%% %d 1 {%5s}\n", lcd_wid - 5, tmp);
|
sock_printf(sock, "widget_set C cpu%% %d 1 {%5s}\n", lcd_wid - 5, tmp);
|
||||||
|
|
||||||
@@ -193,7 +183,7 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
} // End cpu_screen()
|
} /* End cpu_screen() */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -252,31 +242,31 @@ cpu_graph_screen(int rep, int display, int *flags_ptr)
|
|||||||
cpu_past[i - 1] = 0;
|
cpu_past[i - 1] = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear out CPU averaging array
|
/* Clear out CPU averaging array */
|
||||||
for (i = 0; i < CPU_BUF_SIZE; i++)
|
for (i = 0; i < CPU_BUF_SIZE; i++)
|
||||||
cpu[i] = 0.;
|
cpu[i] = 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift values over by one
|
/* Shift values over by one */
|
||||||
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
||||||
cpu[i] = cpu[i + 1];
|
cpu[i] = cpu[i + 1];
|
||||||
|
|
||||||
// Read and save new data
|
/* Read and save new data */
|
||||||
machine_get_load(&load);
|
machine_get_load(&load);
|
||||||
cpu[CPU_BUF_SIZE-1] = (load.total > 0L)
|
cpu[CPU_BUF_SIZE-1] = (load.total > 0L)
|
||||||
? ((double) load.user + (double) load.system + (double) load.nice) / (double) load.total
|
? ((double) load.user + (double) load.system + (double) load.nice) / (double) load.total
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
// Average values for final result
|
/* Average values for final result */
|
||||||
value = 0.0;
|
value = 0.0;
|
||||||
for (i = 0; i < CPU_BUF_SIZE; i++)
|
for (i = 0; i < CPU_BUF_SIZE; i++)
|
||||||
value += cpu[i];
|
value += cpu[i];
|
||||||
value /= CPU_BUF_SIZE;
|
value /= CPU_BUF_SIZE;
|
||||||
|
|
||||||
// Scale result to available height (leave 1st line free when height > 2)
|
/* Scale result to available height (leave 1st line free when height > 2) */
|
||||||
n = (int) (value * lcd_cellhgt * gauge_hgt);
|
n = (int) (value * lcd_cellhgt * gauge_hgt);
|
||||||
|
|
||||||
// Shift and update display the graph
|
/* Shift and update display the graph */
|
||||||
for (i = 0; i < lcd_wid - 1; i++) {
|
for (i = 0; i < lcd_wid - 1; i++) {
|
||||||
cpu_past[i] = cpu_past[i + 1];
|
cpu_past[i] = cpu_past[i + 1];
|
||||||
|
|
||||||
@@ -286,12 +276,11 @@ cpu_graph_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the newest entry and display it
|
/* Save the newest entry and display it */
|
||||||
cpu_past[lcd_wid - 1] = n;
|
cpu_past[lcd_wid - 1] = n;
|
||||||
if (display) {
|
if (display) {
|
||||||
sock_printf(sock, "widget_set G bar%d %d %d %d\n", lcd_wid, lcd_wid, lcd_hgt, n);
|
sock_printf(sock, "widget_set G bar%d %d %d %d\n", lcd_wid, lcd_wid, lcd_hgt, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
} // End cpu_graph_screen()
|
} /* End cpu_graph_screen() */
|
||||||
|
|
||||||
|
|||||||
+13
-22
@@ -19,21 +19,12 @@
|
|||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (C) 2000 J Robert Ray
|
* Copyright (C) 2000 J Robert Ray
|
||||||
* Copyright (C) 2006,7 Peter Marschall
|
* Copyright (C) 2006,2007 Peter Marschall
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This file is part of lcdproc, the lcdproc client.
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This file is released under the GNU General Public License.
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* Refer to the COPYING file distributed with this package.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -65,20 +56,20 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
|||||||
#undef CPU_BUF_SIZE
|
#undef CPU_BUF_SIZE
|
||||||
#define CPU_BUF_SIZE 4
|
#define CPU_BUF_SIZE 4
|
||||||
int z;
|
int z;
|
||||||
static float cpu[MAX_CPUS][CPU_BUF_SIZE + 1]; // last buffer is scratch
|
static float cpu[MAX_CPUS][CPU_BUF_SIZE + 1]; /* last buffer is scratch */
|
||||||
load_type load[MAX_CPUS];
|
load_type load[MAX_CPUS];
|
||||||
int num_cpus = MAX_CPUS;
|
int num_cpus = MAX_CPUS;
|
||||||
int bar_size;
|
int bar_size;
|
||||||
int lines_used;
|
int lines_used;
|
||||||
|
|
||||||
// get SMP load - inform about max #CPUs allowed
|
/* get SMP load - inform about max #CPUs allowed */
|
||||||
machine_get_smpload(load, &num_cpus);
|
machine_get_smpload(load, &num_cpus);
|
||||||
|
|
||||||
// restrict num_cpus to max. twice the display height
|
/* restrict num_cpus to max. twice the display height */
|
||||||
if (num_cpus > 2 * lcd_hgt)
|
if (num_cpus > 2 * lcd_hgt)
|
||||||
num_cpus = 2 * lcd_hgt;
|
num_cpus = 2 * lcd_hgt;
|
||||||
|
|
||||||
// 2 CPUs per line if more CPUs than lines
|
/* 2 CPUs per line if more CPUs than lines */
|
||||||
bar_size = (num_cpus > lcd_hgt) ? (lcd_wid / 2 - 6) : (lcd_wid - 6);
|
bar_size = (num_cpus > lcd_hgt) ? (lcd_wid / 2 - 6) : (lcd_wid - 6);
|
||||||
lines_used = (num_cpus > lcd_hgt) ? (num_cpus + 1) / 2 : num_cpus;
|
lines_used = (num_cpus > lcd_hgt) ? (num_cpus + 1) / 2 : num_cpus;
|
||||||
|
|
||||||
@@ -87,7 +78,7 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
sock_send_string(sock, "screen_add P\n");
|
sock_send_string(sock, "screen_add P\n");
|
||||||
|
|
||||||
// print title if he have room for it
|
/* print title if he have room for it */
|
||||||
if (lines_used < lcd_hgt) {
|
if (lines_used < lcd_hgt) {
|
||||||
sock_send_string(sock, "widget_add P title title\n");
|
sock_send_string(sock, "widget_add P title title\n");
|
||||||
sock_printf(sock, "widget_set P title {SMP CPU %s}\n", get_hostname());
|
sock_printf(sock, "widget_set P title {SMP CPU %s}\n", get_hostname());
|
||||||
@@ -119,16 +110,16 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
|||||||
float value = 0.0;
|
float value = 0.0;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
// Shift values over by one
|
/* Shift values over by one */
|
||||||
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
||||||
cpu[z][i] = cpu[z][i + 1];
|
cpu[z][i] = cpu[z][i + 1];
|
||||||
|
|
||||||
// Read new data
|
/* Read new data */
|
||||||
cpu[z][CPU_BUF_SIZE-1] = (load[z].total > 0L)
|
cpu[z][CPU_BUF_SIZE-1] = (load[z].total > 0L)
|
||||||
? (((float) load[z].user + (float) load[z].system + (float) load[z].nice) / (float) load[z].total) * 100.0
|
? (((float) load[z].user + (float) load[z].system + (float) load[z].nice) / (float) load[z].total) * 100.0
|
||||||
: 0.0;
|
: 0.0;
|
||||||
|
|
||||||
// Average values for final result
|
/* Average values for final result */
|
||||||
for (i = 0; i < CPU_BUF_SIZE; i++) {
|
for (i = 0; i < CPU_BUF_SIZE; i++) {
|
||||||
value += cpu[z][i];
|
value += cpu[z][i];
|
||||||
}
|
}
|
||||||
@@ -139,4 +130,4 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End cpu_screen()
|
}
|
||||||
|
|||||||
+12
-11
@@ -56,7 +56,7 @@ disk_screen(int rep, int display, int *flags_ptr)
|
|||||||
static mounts_type mnt[256];
|
static mounts_type mnt[256];
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
||||||
// Holds info to display (avoid recalculating it)
|
/* Holds info to display (avoid recalculating it) */
|
||||||
struct disp {
|
struct disp {
|
||||||
char dev[16];
|
char dev[16];
|
||||||
char cap[8];
|
char cap[8];
|
||||||
@@ -87,12 +87,11 @@ disk_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_send_string(sock, "widget_set D err1 5 2 { Reading }\n");
|
sock_send_string(sock, "widget_set D err1 5 2 { Reading }\n");
|
||||||
sock_send_string(sock, "widget_set D err2 5 3 {Filesystems}\n");
|
sock_send_string(sock, "widget_set D err2 5 3 {Filesystems}\n");
|
||||||
}
|
}
|
||||||
// Grab disk stats on first display, and fill "table".
|
|
||||||
// Get rid of old, unmounted filesystems...
|
|
||||||
|
|
||||||
|
/* Get rid of old, unmounted filesystems... */
|
||||||
machine_get_fs(mnt, &count);
|
machine_get_fs(mnt, &count);
|
||||||
|
|
||||||
// Fill the display structure...
|
/* Fill the display structure... */
|
||||||
if (count) {
|
if (count) {
|
||||||
sock_send_string(sock, "widget_set D err1 0 0 .\n");
|
sock_send_string(sock, "widget_set D err1 0 0 .\n");
|
||||||
sock_send_string(sock, "widget_set D err2 0 0 .\n");
|
sock_send_string(sock, "widget_set D err2 0 0 .\n");
|
||||||
@@ -118,32 +117,34 @@ disk_screen(int rep, int display, int *flags_ptr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display stuff... (show for two seconds, then scroll once per
|
/*
|
||||||
// second, then hold at the end for two seconds)
|
* Display stuff... (show for two seconds, then scroll once per
|
||||||
|
* second, then hold at the end for two seconds)
|
||||||
|
*/
|
||||||
sock_printf(sock, "widget_set D f 1 2 %i %i %i %i v 12\n", lcd_wid, lcd_hgt, lcd_wid, count);
|
sock_printf(sock, "widget_set D f 1 2 %i %i %i %i v 12\n", lcd_wid, lcd_hgt, lcd_wid, count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
char tmp[lcd_wid+1]; // should be large enough
|
char tmp[lcd_wid + 1]; /* should be large enough */
|
||||||
|
|
||||||
if (table[i].dev[0] == '\0')
|
if (table[i].dev[0] == '\0')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i >= num_disks) { // Make sure we have enough lines...
|
if (i >= num_disks) { /* Make sure we have enough lines... */
|
||||||
sock_printf(sock, "widget_add D s%i string -in f\n", i);
|
sock_printf(sock, "widget_add D s%i string -in f\n", i);
|
||||||
sock_printf(sock, "widget_add D h%i hbar -in f\n", i);
|
sock_printf(sock, "widget_add D h%i hbar -in f\n", i);
|
||||||
}
|
}
|
||||||
if (lcd_wid >= 20) { // 20+x columns
|
if (lcd_wid >= 20) { /* 20+x columns */
|
||||||
sprintf(tmp, "%-*s %6s E%*sF", dev_wid, table[i].dev, table[i].cap, gauge_wid, "");
|
sprintf(tmp, "%-*s %6s E%*sF", dev_wid, table[i].dev, table[i].cap, gauge_wid, "");
|
||||||
sock_printf(sock, "widget_set D s%i 1 %i {%s}\n", i, i + 1, tmp);
|
sock_printf(sock, "widget_set D s%i 1 %i {%s}\n", i, i + 1, tmp);
|
||||||
sock_printf(sock, "widget_set D h%i %i %i %i\n", i, 10 + dev_wid, i + 1, table[i].full);
|
sock_printf(sock, "widget_set D h%i %i %i %i\n", i, 10 + dev_wid, i + 1, table[i].full);
|
||||||
}
|
}
|
||||||
else { // < 20 columns
|
else { /* < 20 columns */
|
||||||
sprintf(tmp, "%-*s E%*sF", dev_wid, table[i].dev, gauge_wid, "");
|
sprintf(tmp, "%-*s E%*sF", dev_wid, table[i].dev, gauge_wid, "");
|
||||||
sock_printf(sock, "widget_set D s%i 1 %i {%s}\n", i, i + 1, tmp);
|
sock_printf(sock, "widget_set D s%i 1 %i {%s}\n", i, i + 1, tmp);
|
||||||
sock_printf(sock, "widget_set D h%i %i %i %i\n", i, 3 + dev_wid, i + 1, table[i].full);
|
sock_printf(sock, "widget_set D h%i %i %i %i\n", i, 3 + dev_wid, i + 1, table[i].full);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now remove extra widgets...
|
/* Now remove extra widgets... */
|
||||||
for (; i < num_disks; i++) {
|
for (; i < num_disks; i++) {
|
||||||
sock_printf(sock, "widget_del D s%i\n", i);
|
sock_printf(sock, "widget_del D s%i\n", i);
|
||||||
sock_printf(sock, "widget_del D h%i\n", i);
|
sock_printf(sock, "widget_del D h%i\n", i);
|
||||||
|
|||||||
+17
-34
@@ -1,28 +1,15 @@
|
|||||||
/** \file clients/lcdproc/eyebox.c
|
/** \file clients/lcdproc/eyebox.c
|
||||||
This is the LCDproc client module for EyeboxOne devices
|
* This is the LCDproc client module for EyeboxOne devices
|
||||||
|
*
|
||||||
This allows to use leds, one as a free CPU meter, and one
|
* This allows to use leds, one as a free CPU meter, and one as a free RAM
|
||||||
as a free RAM meter.
|
* meter.
|
||||||
|
|
||||||
All this is in BETA version, take it as a demo...
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
Copyright (C) 2006 Cedric TESSIER (aka NeZetiC) http://www.nezetic.info
|
* Copyright (C) 2006 Cedric TESSIER (aka NeZetiC) http://www.nezetic.info
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or modify
|
* This file is released under the GNU General Public License.
|
||||||
it under the terms of the GNU General Public License as published by
|
* Refer to the COPYING file distributed with this package.
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -50,7 +37,7 @@ eyebox_screen(char display, int init)
|
|||||||
#define CPU_BUF_SIZE 4
|
#define CPU_BUF_SIZE 4
|
||||||
int i, j;
|
int i, j;
|
||||||
double value;
|
double value;
|
||||||
static double cpu[CPU_BUF_SIZE + 1][5]; // last buffer is scratch
|
static double cpu[CPU_BUF_SIZE + 1][5]; /* last buffer is scratch */
|
||||||
meminfo_type mem[2];
|
meminfo_type mem[2];
|
||||||
load_type load;
|
load_type load;
|
||||||
|
|
||||||
@@ -58,18 +45,18 @@ eyebox_screen(char display, int init)
|
|||||||
sock_printf(sock, "widget_add %c eyebo_cpu string\n", display);
|
sock_printf(sock, "widget_add %c eyebo_cpu string\n", display);
|
||||||
sock_printf(sock, "widget_add %c eyebo_mem string\n", display);
|
sock_printf(sock, "widget_add %c eyebo_mem string\n", display);
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
machine_get_load(&load);
|
machine_get_load(&load);
|
||||||
machine_get_meminfo(mem);
|
machine_get_meminfo(mem);
|
||||||
|
|
||||||
// Shift values over by one
|
/* Shift values over by one */
|
||||||
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
||||||
for (j = 0; j < 5; j++)
|
for (j = 0; j < 5; j++)
|
||||||
cpu[i][j] = cpu[i + 1][j];
|
cpu[i][j] = cpu[i + 1][j];
|
||||||
|
|
||||||
// Read new data
|
/* Read new data */
|
||||||
if (load.total > 0L) {
|
if (load.total > 0L) {
|
||||||
cpu[CPU_BUF_SIZE - 1][0] = 100.0 * ((double) load.user / (double) load.total);
|
cpu[CPU_BUF_SIZE - 1][0] = 100.0 * ((double) load.user / (double) load.total);
|
||||||
cpu[CPU_BUF_SIZE - 1][1] = 100.0 * ((double) load.system / (double) load.total);
|
cpu[CPU_BUF_SIZE - 1][1] = 100.0 * ((double) load.system / (double) load.total);
|
||||||
@@ -85,7 +72,7 @@ eyebox_screen(char display, int init)
|
|||||||
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
|
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Average values for final result
|
/* Average values for final result */
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
value = 0.0;
|
value = 0.0;
|
||||||
for (j = 0; j < CPU_BUF_SIZE; j++)
|
for (j = 0; j < CPU_BUF_SIZE; j++)
|
||||||
@@ -94,34 +81,30 @@ eyebox_screen(char display, int init)
|
|||||||
cpu[CPU_BUF_SIZE][i] = value;
|
cpu[CPU_BUF_SIZE][i] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*-
|
||||||
* /xBab = Use Bar
|
* /xBab = Use Bar
|
||||||
* a = Bar ID
|
* a = Bar ID
|
||||||
* b = Level
|
* b = Level
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sock_printf(sock, "widget_set %c eyebo_cpu 1 2 {/xB%d%d}\n",
|
sock_printf(sock, "widget_set %c eyebo_cpu 1 2 {/xB%d%d}\n",
|
||||||
display, 2,(int)(cpu[CPU_BUF_SIZE][4]/10));
|
display, 2,(int)(cpu[CPU_BUF_SIZE][4]/10));
|
||||||
|
|
||||||
/*
|
/*-
|
||||||
* /xBab = Use Bas
|
* /xBab = Use Bas
|
||||||
* a = Bar ID
|
* a = Bar ID
|
||||||
* b = Level
|
* b = Level
|
||||||
*/
|
*/
|
||||||
|
|
||||||
value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
||||||
/ (double) mem[0].total;
|
/ (double) mem[0].total;
|
||||||
sock_printf(sock, "widget_set %c eyebo_mem 1 3 {/xB%d%d}\n", display, 1, (int) (value * 10));
|
sock_printf(sock, "widget_set %c eyebo_mem 1 3 {/xB%d%d}\n", display, 1, (int) (value * 10));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End mem_screen()
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eyebox_clear(void)
|
eyebox_clear(void)
|
||||||
{
|
{
|
||||||
/*
|
/* Clear LEDs before exit */
|
||||||
* Clear LEDs before exit
|
|
||||||
*/
|
|
||||||
sock_send_string(sock, "screen_add OFF\n");
|
sock_send_string(sock, "screen_add OFF\n");
|
||||||
sock_send_string(sock, "screen_set OFF -priority alert -name {EyeBO}\n");
|
sock_send_string(sock, "screen_set OFF -priority alert -name {EyeBO}\n");
|
||||||
sock_send_string(sock, "widget_add OFF title title\n");
|
sock_send_string(sock, "widget_add OFF title title\n");
|
||||||
|
|||||||
+65
-81
@@ -3,24 +3,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
Copyright (C) 2002 Luis Llorente Campo <luisllorente@luisllorente.com>
|
* Copyright (C) 2002 Luis Llorente Campo <luisllorente@luisllorente.com>
|
||||||
Multiinterface Extension by Stephan Skrodzki <skrodzki@stevekist.de>
|
*
|
||||||
Adaptions to lcdproc by Andrew Foss with fixes by M. Dolze
|
* Multi-interface extension by Stephan Skrodzki <skrodzki@stevekist.de>
|
||||||
Cleanup, reorganization by Peter Marschall
|
* Adaptions to lcdproc by Andrew Foss with fixes by M. Dolze
|
||||||
|
* Cleanup, reorganization by Peter Marschall
|
||||||
This program is free software; you can redistribute it and/or modify
|
*
|
||||||
it under the terms of the GNU General Public License as published by
|
* This file is released under the GNU General Public License.
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
* Refer to the COPYING file distributed with this package.
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -59,7 +49,6 @@ iface_process_configfile(void)
|
|||||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||||
|
|
||||||
/* Read config settings */
|
/* Read config settings */
|
||||||
|
|
||||||
for (iface_count = 0; iface_count < MAX_INTERFACES; iface_count++) {
|
for (iface_count = 0; iface_count < MAX_INTERFACES; iface_count++) {
|
||||||
char iface_label[12];
|
char iface_label[12];
|
||||||
|
|
||||||
@@ -75,7 +64,10 @@ iface_process_configfile(void)
|
|||||||
sprintf(iface_label, "Alias%i", iface_count);
|
sprintf(iface_label, "Alias%i", iface_count);
|
||||||
iface[iface_count].alias = strdup(config_get_string("Iface", iface_label, 0, iface[iface_count].name));
|
iface[iface_count].alias = strdup(config_get_string("Iface", iface_label, 0, iface[iface_count].name));
|
||||||
if (iface[iface_count].alias == NULL)
|
if (iface[iface_count].alias == NULL)
|
||||||
// make alia the same as the interface name in case strdup() failed
|
/*
|
||||||
|
* make alias the same as the interface name in case #
|
||||||
|
* strdup() failed
|
||||||
|
*/
|
||||||
iface[iface_count].alias = iface[iface_count].name;
|
iface[iface_count].alias = iface[iface_count].name;
|
||||||
debug(RPT_DEBUG, "Interface %i: %s alias %s",
|
debug(RPT_DEBUG, "Interface %i: %s alias %s",
|
||||||
iface_count, iface[iface_count].name, iface[iface_count].alias);
|
iface_count, iface[iface_count].name, iface[iface_count].alias);
|
||||||
@@ -126,8 +118,8 @@ iface_process_configfile(void)
|
|||||||
int
|
int
|
||||||
iface_screen(int rep, int display, int *flags_ptr)
|
iface_screen(int rep, int display, int *flags_ptr)
|
||||||
{
|
{
|
||||||
/* ALF TODO need to make this actual time since last run */
|
/* interval since last update */
|
||||||
unsigned int interval = difftime(time(NULL), iface[0].last_online); /* interval since last update */
|
unsigned int interval = difftime(time(NULL), iface[0].last_online);
|
||||||
int iface_nmbr;
|
int iface_nmbr;
|
||||||
|
|
||||||
if (!interval)
|
if (!interval)
|
||||||
@@ -178,8 +170,7 @@ iface_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} /* End iface_screen() */
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,20 +181,13 @@ initialize_speed_screen(void)
|
|||||||
{
|
{
|
||||||
int iface_nmbr; /* interface number */
|
int iface_nmbr; /* interface number */
|
||||||
|
|
||||||
/* Add screen */
|
|
||||||
sock_send_string(sock, "screen_add I\n");
|
sock_send_string(sock, "screen_add I\n");
|
||||||
|
|
||||||
/* Set screen name */
|
|
||||||
sock_send_string(sock, "screen_set I name {Load}\n");
|
sock_send_string(sock, "screen_set I name {Load}\n");
|
||||||
|
|
||||||
/* Add title to screen */
|
|
||||||
sock_send_string(sock, "widget_add I title title\n");
|
sock_send_string(sock, "widget_add I title title\n");
|
||||||
|
|
||||||
if ((iface_count == 1) && (lcd_hgt >= 4 )) { /* Single interface mode */
|
/* Single interface mode */
|
||||||
/* Set title */
|
if ((iface_count == 1) && (lcd_hgt >= 4 )) {
|
||||||
sock_printf(sock, "widget_set I title {Net Load: %s}\n", iface[0].alias);
|
sock_printf(sock, "widget_set I title {Net Load: %s}\n", iface[0].alias);
|
||||||
|
|
||||||
/* Add and set download, upload and total string widgets */
|
|
||||||
sock_send_string(sock, "widget_add I dl string\n");
|
sock_send_string(sock, "widget_add I dl string\n");
|
||||||
sock_send_string(sock, "widget_set I dl 1 2 {DL:}\n");
|
sock_send_string(sock, "widget_set I dl 1 2 {DL:}\n");
|
||||||
sock_send_string(sock, "widget_add I ul string\n");
|
sock_send_string(sock, "widget_add I ul string\n");
|
||||||
@@ -211,7 +195,8 @@ initialize_speed_screen(void)
|
|||||||
sock_send_string(sock, "widget_add I total string\n");
|
sock_send_string(sock, "widget_add I total string\n");
|
||||||
sock_send_string(sock, "widget_set I total 1 4 {Total:}\n");
|
sock_send_string(sock, "widget_set I total 1 4 {Total:}\n");
|
||||||
}
|
}
|
||||||
else { /* multi-interfaces mode: one line per interface */
|
/* multi-interfaces mode: one line per interface */
|
||||||
|
else {
|
||||||
/* Set title */
|
/* Set title */
|
||||||
if (strstr(unit_label, "B")) {
|
if (strstr(unit_label, "B")) {
|
||||||
sock_printf(sock, "widget_set I title {Net Load (bytes)}\n");
|
sock_printf(sock, "widget_set I title {Net Load (bytes)}\n");
|
||||||
@@ -225,22 +210,22 @@ initialize_speed_screen(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* frame from (2, left) to (width, height) that is iface_count lines high */
|
||||||
sock_send_string (sock, "widget_add I f frame\n");
|
sock_send_string (sock, "widget_add I f frame\n");
|
||||||
|
|
||||||
// frame from (2, left) to (width, height) that is iface_count lines high
|
|
||||||
sock_printf(sock, "widget_set I f 1 2 %d %d %d %d v 16\n",
|
sock_printf(sock, "widget_set I f 1 2 %d %d %d %d v 16\n",
|
||||||
lcd_wid, lcd_hgt, lcd_wid, iface_count,
|
lcd_wid, lcd_hgt, lcd_wid, iface_count,
|
||||||
// scroll rate: 1 line every X ticks (=1/8 sec)
|
/* scroll rate: 1 line every X ticks (=1/8 sec) */
|
||||||
((lcd_hgt >= 4) ? 8 : 16));
|
((lcd_hgt >= 4) ? 8 : 16));
|
||||||
|
|
||||||
|
/* Add interfaces to frame */
|
||||||
for (iface_nmbr = 0; iface_nmbr < iface_count; iface_nmbr++) {
|
for (iface_nmbr = 0; iface_nmbr < iface_count; iface_nmbr++) {
|
||||||
sock_printf(sock, "widget_add I i%1d string -in f\n", iface_nmbr);
|
sock_printf(sock, "widget_add I i%1d string -in f\n", iface_nmbr);
|
||||||
sock_printf(sock, "widget_set I i%1d 1 %1d {%5.5s NA (never)}\n",\
|
sock_printf(sock, "widget_set I i%1d 1 %1d {%5.5s NA (never)}\n",
|
||||||
iface_nmbr, iface_nmbr+1, iface[iface_nmbr].alias);
|
iface_nmbr, iface_nmbr+1, iface[iface_nmbr].alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} /* initialize_speed_screen() */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the value (in bytes) passed as parameter according to its scale,
|
* Format the value (in bytes) passed as parameter according to its scale,
|
||||||
@@ -264,7 +249,8 @@ format_value (char *buff, double value, char *unit)
|
|||||||
/* If units are bytes, then divide by 2^10, otherwise by 10^3 */
|
/* If units are bytes, then divide by 2^10, otherwise by 10^3 */
|
||||||
mag = convert_double(&value, (strstr(unit, "B")) ? 1024 : 1000, 1.0f);
|
mag = convert_double(&value, (strstr(unit, "B")) ? 1024 : 1000, 1.0f);
|
||||||
|
|
||||||
/* Formatting rules:
|
/*-
|
||||||
|
* Formatting rules:
|
||||||
* - if original value was < 1000, output decimal value only
|
* - if original value was < 1000, output decimal value only
|
||||||
* - otherwise format with 3 precision
|
* - otherwise format with 3 precision
|
||||||
*/
|
*/
|
||||||
@@ -272,8 +258,8 @@ format_value (char *buff, double value, char *unit)
|
|||||||
sprintf(buff, "%8ld %s", (long) value, unit);
|
sprintf(buff, "%8ld %s", (long) value, unit);
|
||||||
else
|
else
|
||||||
sprintf(buff, "%7.3f %s%s", value, mag, unit);
|
sprintf(buff, "%7.3f %s%s", value, mag, unit);
|
||||||
|
}
|
||||||
|
|
||||||
} /* format_value() */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the value (in bytes) passed as parameter according to its scale,
|
* Format the value (in bytes) passed as parameter according to its scale,
|
||||||
@@ -295,7 +281,8 @@ format_value_multi_interface (char *buff, double value, char *unit)
|
|||||||
|
|
||||||
mag = convert_double(&value, (strstr(unit, "B")) ? 1024 : 1000, 1.0f);
|
mag = convert_double(&value, (strstr(unit, "B")) ? 1024 : 1000, 1.0f);
|
||||||
|
|
||||||
/* Formatting rules:
|
/*-
|
||||||
|
* Formatting rules:
|
||||||
* - if original value was < 1000, output decimal value only
|
* - if original value was < 1000, output decimal value only
|
||||||
* - with 1 precision if <10
|
* - with 1 precision if <10
|
||||||
* - decimal value with magnitude otherwise
|
* - decimal value with magnitude otherwise
|
||||||
@@ -306,8 +293,8 @@ format_value_multi_interface (char *buff, double value, char *unit)
|
|||||||
sprintf(buff, "%3.1f%s", value, mag);
|
sprintf(buff, "%3.1f%s", value, mag);
|
||||||
else
|
else
|
||||||
sprintf(buff, "%3.0f%s", value, mag);
|
sprintf(buff, "%3.0f%s", value, mag);
|
||||||
|
}
|
||||||
|
|
||||||
} /* format_value_multi_interface() */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the time in ASCII, depending on the elapsed time.
|
* Format the time in ASCII, depending on the elapsed time.
|
||||||
@@ -331,7 +318,8 @@ get_time_string (char *buff, time_t last_online)
|
|||||||
/* Transform Unix time format to UTC time format */
|
/* Transform Unix time format to UTC time format */
|
||||||
strcpy(timebuff, ctime(&last_online));
|
strcpy(timebuff, ctime(&last_online));
|
||||||
|
|
||||||
if ((act_time - last_online) > 86400 ) { /* 86400 = 24 * 60 * 60. Is it more than 24 hours? */
|
/* 86400 = 24 * 60 * 60. Is it more than 24 hours? */
|
||||||
|
if ((act_time - last_online) > 86400 ) {
|
||||||
timebuff[10] = '\0';
|
timebuff[10] = '\0';
|
||||||
sprintf(buff, "%s", &timebuff[4]);
|
sprintf(buff, "%s", &timebuff[4]);
|
||||||
return;
|
return;
|
||||||
@@ -341,7 +329,8 @@ get_time_string (char *buff, time_t last_online)
|
|||||||
sprintf(buff, "%s", &timebuff[11]);
|
sprintf(buff, "%s", &timebuff[11]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} /* get_time_string() */
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actualize values in display, calculating speeds in the defined interval
|
* Actualize values in display, calculating speeds in the defined interval
|
||||||
@@ -358,10 +347,11 @@ actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
|
|||||||
double rc_speed;
|
double rc_speed;
|
||||||
double tr_speed;
|
double tr_speed;
|
||||||
|
|
||||||
if ((iface_count == 1) && ( lcd_hgt >= 4)) { /* single interface mode */
|
/* single interface mode */
|
||||||
|
if ((iface_count == 1) && ( lcd_hgt >= 4)) {
|
||||||
if (iface->status == up) {
|
if (iface->status == up) {
|
||||||
/* Calculate Download speed */
|
/* Calculate and actualize download speed */
|
||||||
if (strstr(unit_label, "pkt")) { /* don't format this value */
|
if (strstr(unit_label, "pkt")) {
|
||||||
rc_speed = (iface->rc_pkt - iface->rc_pkt_old) / interval;
|
rc_speed = (iface->rc_pkt - iface->rc_pkt_old) / interval;
|
||||||
sprintf(speed, "%8ld %s", (long) rc_speed, unit_label);
|
sprintf(speed, "%8ld %s", (long) rc_speed, unit_label);
|
||||||
}
|
}
|
||||||
@@ -369,12 +359,10 @@ actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
|
|||||||
rc_speed = (iface->rc_byte - iface->rc_byte_old) / interval;
|
rc_speed = (iface->rc_byte - iface->rc_byte_old) / interval;
|
||||||
format_value(speed, rc_speed, unit_label);
|
format_value(speed, rc_speed, unit_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actualize Download speed */
|
|
||||||
sock_printf(sock, "widget_set I dl 1 2 {DL: %*s/s}\n", lcd_wid - 6, speed);
|
sock_printf(sock, "widget_set I dl 1 2 {DL: %*s/s}\n", lcd_wid - 6, speed);
|
||||||
|
|
||||||
/* Calculate Upload speed */
|
/* Calculate and actualize upload speed */
|
||||||
if (strstr(unit_label, "pkt")) { /* don't format this value */
|
if (strstr(unit_label, "pkt")) {
|
||||||
tr_speed = (iface->tr_pkt - iface->tr_pkt_old) / interval;
|
tr_speed = (iface->tr_pkt - iface->tr_pkt_old) / interval;
|
||||||
sprintf(speed, "%8ld %s", (long)tr_speed, unit_label);
|
sprintf(speed, "%8ld %s", (long)tr_speed, unit_label);
|
||||||
}
|
}
|
||||||
@@ -382,29 +370,26 @@ actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
|
|||||||
tr_speed = (iface->tr_byte - iface->tr_byte_old) / interval;
|
tr_speed = (iface->tr_byte - iface->tr_byte_old) / interval;
|
||||||
format_value(speed, tr_speed, unit_label);
|
format_value(speed, tr_speed, unit_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actualize Upload speed */
|
|
||||||
sock_printf(sock, "widget_set I ul 1 3 {UL: %*s/s}\n", lcd_wid - 6, speed);
|
sock_printf(sock, "widget_set I ul 1 3 {UL: %*s/s}\n", lcd_wid - 6, speed);
|
||||||
|
|
||||||
/* Calculate Total speed */
|
/* Calculate and actualize total speed */
|
||||||
if (strstr(unit_label, "pkt")) { /* don't format this value */
|
if (strstr(unit_label, "pkt")) {
|
||||||
sprintf(speed, "%7ld %s", (long)(rc_speed + tr_speed), unit_label);
|
sprintf(speed, "%7ld %s", (long)(rc_speed + tr_speed), unit_label);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
format_value(speed, rc_speed + tr_speed, unit_label);
|
format_value(speed, rc_speed + tr_speed, unit_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actualize Total speed */
|
|
||||||
sock_printf(sock, "widget_set I total 1 4 {Total: %*s/s}\n", lcd_wid - 9, speed);
|
sock_printf(sock, "widget_set I total 1 4 {Total: %*s/s}\n", lcd_wid - 9, speed);
|
||||||
}
|
}
|
||||||
else { /* Interface is down */
|
else {
|
||||||
get_time_string(speed, iface->last_online);
|
get_time_string(speed, iface->last_online);
|
||||||
sock_printf(sock, "widget_set I dl 1 2 {NA (%s)}\n", speed);
|
sock_printf(sock, "widget_set I dl 1 2 {NA (%s)}\n", speed);
|
||||||
sock_send_string(sock, "widget_set I ul 1 3 {}\n");
|
sock_send_string(sock, "widget_set I ul 1 3 {}\n");
|
||||||
sock_send_string(sock, "widget_set I total 1 4 {}\n");
|
sock_send_string(sock, "widget_set I total 1 4 {}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* multi-interfaces mode: 1 line per interface */
|
/* multi-interfaces mode: 1 line per interface */
|
||||||
|
else {
|
||||||
char speed1[20]; /* buffer to store the formated speed string */
|
char speed1[20]; /* buffer to store the formated speed string */
|
||||||
|
|
||||||
if (iface->status == up) {
|
if (iface->status == up) {
|
||||||
@@ -425,13 +410,14 @@ actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
|
|||||||
sock_printf(sock, "widget_set I i%1d 1 %1d {%4.4s ^%.4s v%.4s}\n",
|
sock_printf(sock, "widget_set I i%1d 1 %1d {%4.4s ^%.4s v%.4s}\n",
|
||||||
index, index+1, iface->alias, speed1, speed);
|
index, index+1, iface->alias, speed1, speed);
|
||||||
}
|
}
|
||||||
else { /* Interface is down */
|
else {
|
||||||
get_time_string(speed, iface->last_online);
|
get_time_string(speed, iface->last_online);
|
||||||
sock_printf(sock, "widget_set I i%1d 1 %1d {%5.5s NA (%s)}\n",
|
sock_printf(sock, "widget_set I i%1d 1 %1d {%5.5s NA (%s)}\n",
|
||||||
index, index+1, iface->alias, speed);
|
index, index+1, iface->alias, speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* actualize_speed_screen() */
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send commands to server to add transfer screen with all required widgets.
|
* Send commands to server to add transfer screen with all required widgets.
|
||||||
@@ -441,20 +427,13 @@ initialize_transfer_screen(void)
|
|||||||
{
|
{
|
||||||
int iface_nmbr; /* interface number */
|
int iface_nmbr; /* interface number */
|
||||||
|
|
||||||
/* Add screen */
|
|
||||||
sock_send_string(sock, "screen_add NT\n");
|
sock_send_string(sock, "screen_add NT\n");
|
||||||
|
|
||||||
/* Set screen name */
|
|
||||||
sock_send_string(sock, "screen_set NT name {Transfer}\n");
|
sock_send_string(sock, "screen_set NT name {Transfer}\n");
|
||||||
|
|
||||||
/* Add title to screen */
|
|
||||||
sock_send_string(sock, "widget_add NT title title\n");
|
sock_send_string(sock, "widget_add NT title title\n");
|
||||||
|
|
||||||
if ((iface_count == 1) && (lcd_hgt >= 4)) { /* single interface mode */
|
/* single interface mode */
|
||||||
/* Set title */
|
if ((iface_count == 1) && (lcd_hgt >= 4)) {
|
||||||
sock_printf(sock, "widget_set NT title {Transfer: %s}\n", iface[0].alias);
|
sock_printf(sock, "widget_set NT title {Transfer: %s}\n", iface[0].alias);
|
||||||
|
|
||||||
/* Add and set download, upload and total string widgets */
|
|
||||||
sock_send_string(sock, "widget_add NT dl string\n");
|
sock_send_string(sock, "widget_add NT dl string\n");
|
||||||
sock_send_string(sock, "widget_set NT dl 1 2 {DL:}\n");
|
sock_send_string(sock, "widget_set NT dl 1 2 {DL:}\n");
|
||||||
sock_send_string(sock, "widget_add NT ul string\n");
|
sock_send_string(sock, "widget_add NT ul string\n");
|
||||||
@@ -462,24 +441,27 @@ initialize_transfer_screen(void)
|
|||||||
sock_send_string(sock, "widget_add NT total string\n");
|
sock_send_string(sock, "widget_add NT total string\n");
|
||||||
sock_send_string(sock, "widget_set NT total 1 4 {Total:}\n");
|
sock_send_string(sock, "widget_set NT total 1 4 {Total:}\n");
|
||||||
}
|
}
|
||||||
else { /* multi-interfaces mode: one line per interface */
|
/* multi-interfaces mode: one line per interface */
|
||||||
|
else {
|
||||||
/* Set title (transfer screen is always in "bytes") */
|
/* Set title (transfer screen is always in "bytes") */
|
||||||
sock_send_string(sock, "widget_set NT title {Net Transfer (bytes)}\n");
|
sock_send_string(sock, "widget_set NT title {Net Transfer (bytes)}\n");
|
||||||
sock_send_string(sock, "widget_add NT f frame\n");
|
|
||||||
|
|
||||||
// frame from (2, left) to (width, height) that is iface_count lines high
|
/* frame from (2, left) to (width, height) that is iface_count lines high */
|
||||||
|
sock_send_string(sock, "widget_add NT f frame\n");
|
||||||
sock_printf(sock, "widget_set NT f 1 2 %d %d %d %d v 16\n",
|
sock_printf(sock, "widget_set NT f 1 2 %d %d %d %d v 16\n",
|
||||||
lcd_wid, lcd_hgt, lcd_wid, iface_count,
|
lcd_wid, lcd_hgt, lcd_wid, iface_count,
|
||||||
// scroll rate: 1 line every X ticks (=1/8 sec)
|
/* scroll rate: 1 line every X ticks (=1/8 sec) */
|
||||||
((lcd_hgt >= 4) ? 8 : 16));
|
((lcd_hgt >= 4) ? 8 : 16));
|
||||||
|
|
||||||
|
/* Add interfaces */
|
||||||
for (iface_nmbr = 0; iface_nmbr < iface_count; iface_nmbr++) {
|
for (iface_nmbr = 0; iface_nmbr < iface_count; iface_nmbr++) {
|
||||||
sock_printf(sock, "widget_add NT i%1d string -in f\n", iface_nmbr);
|
sock_printf(sock, "widget_add NT i%1d string -in f\n", iface_nmbr);
|
||||||
sock_printf(sock, "widget_set NT i%1d 1 %1d {%5.5s NA (never)}\n",
|
sock_printf(sock, "widget_set NT i%1d 1 %1d {%5.5s NA (never)}\n",
|
||||||
iface_nmbr, iface_nmbr+1, iface[iface_nmbr].alias);
|
iface_nmbr, iface_nmbr+1, iface[iface_nmbr].alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* initialize_transfer_screen() */
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actualize values in display, formatting transfer measures and sending
|
* Actualize values in display, formatting transfer measures and sending
|
||||||
@@ -492,7 +474,8 @@ actualize_transfer_screen(IfaceInfo *iface, int index)
|
|||||||
{
|
{
|
||||||
char transfer[20]; /* buffer to store the formated traffic string */
|
char transfer[20]; /* buffer to store the formated traffic string */
|
||||||
|
|
||||||
if ((iface_count == 1) && (lcd_hgt >= 4)) { /* single interface mode */
|
/* single interface mode */
|
||||||
|
if ((iface_count == 1) && (lcd_hgt >= 4)) {
|
||||||
if (iface->status == up) {
|
if (iface->status == up) {
|
||||||
/* download traffic */
|
/* download traffic */
|
||||||
format_value(transfer, iface->rc_byte, "B");
|
format_value(transfer, iface->rc_byte, "B");
|
||||||
@@ -506,14 +489,15 @@ actualize_transfer_screen(IfaceInfo *iface, int index)
|
|||||||
format_value(transfer, iface->rc_byte + iface->tr_byte, "B");
|
format_value(transfer, iface->rc_byte + iface->tr_byte, "B");
|
||||||
sock_printf(sock, "widget_set NT total 1 4 {Total: %*s}\n", lcd_wid - 7, transfer);
|
sock_printf(sock, "widget_set NT total 1 4 {Total: %*s}\n", lcd_wid - 7, transfer);
|
||||||
}
|
}
|
||||||
else { /* Interface is down */
|
else {
|
||||||
get_time_string(transfer, iface->last_online);
|
get_time_string(transfer, iface->last_online);
|
||||||
sock_printf(sock, "widget_set NT dl 1 2 {NA (%s)}\n", transfer);
|
sock_printf(sock, "widget_set NT dl 1 2 {NA (%s)}\n", transfer);
|
||||||
sock_send_string(sock, "widget_set NT ul 1 3 {}\n");
|
sock_send_string(sock, "widget_set NT ul 1 3 {}\n");
|
||||||
sock_send_string(sock, "widget_set NT total 1 4 {}\n");
|
sock_send_string(sock, "widget_set NT total 1 4 {}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* multi-interfaces mode: one line per interface */
|
/* multi-interfaces mode: one line per interface */
|
||||||
|
else {
|
||||||
char transfer1[20]; /* buffer to store the formated traffic string */
|
char transfer1[20]; /* buffer to store the formated traffic string */
|
||||||
|
|
||||||
if (iface->status == up) {
|
if (iface->status == up) {
|
||||||
@@ -526,10 +510,10 @@ actualize_transfer_screen(IfaceInfo *iface, int index)
|
|||||||
sock_printf(sock, "widget_set NT i%1d 1 %1d {%4.4s ^%.4s v%.4s}\n",
|
sock_printf(sock, "widget_set NT i%1d 1 %1d {%4.4s ^%.4s v%.4s}\n",
|
||||||
index, index+1, iface->alias, transfer1, transfer);
|
index, index+1, iface->alias, transfer1, transfer);
|
||||||
}
|
}
|
||||||
else { /* Interface is down */
|
else {
|
||||||
get_time_string(transfer, iface->last_online);
|
get_time_string(transfer, iface->last_online);
|
||||||
sock_printf(sock, "widget_set NT i%1d 1 %1d {%5.5s NA (%s)}\n",
|
sock_printf(sock, "widget_set NT i%1d 1 %1d {%5.5s NA (%s)}\n",
|
||||||
index, index+1, iface->alias, transfer);
|
index, index+1, iface->alias, transfer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* actualize_transfer_screen() */
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
#ifndef IFACE_H
|
#ifndef IFACE_H
|
||||||
#define IFACE_H
|
#define IFACE_H
|
||||||
|
|
||||||
#define MAX_INTERFACES 3 /* max number of interfaces in multi-interface mode */
|
/** max number of interfaces in multi-interface mode */
|
||||||
|
#define MAX_INTERFACES 3
|
||||||
|
|
||||||
IfaceInfo iface[MAX_INTERFACES]; /* interface info */
|
IfaceInfo iface[MAX_INTERFACES]; /* interface info */
|
||||||
|
|
||||||
|
|||||||
+13
-11
@@ -69,12 +69,12 @@ xload_screen(int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
sock_send_string(sock, "screen_add L\n");
|
sock_send_string(sock, "screen_add L\n");
|
||||||
sock_printf(sock, "screen_set L -name {Load: %s}\n", get_hostname());
|
sock_printf(sock, "screen_set L -name {Load: %s}\n", get_hostname());
|
||||||
// Add the vbars...
|
/* Add the vbars... */
|
||||||
for (i = 1; i < lcd_wid; i++) {
|
for (i = 1; i < lcd_wid; i++) {
|
||||||
sock_printf(sock, "widget_add L bar%i vbar\n", i);
|
sock_printf(sock, "widget_add L bar%i vbar\n", i);
|
||||||
sock_printf(sock, "widget_set L bar%i %i %i 0\n", i, i, lcd_hgt);
|
sock_printf(sock, "widget_set L bar%i %i %i 0\n", i, i, lcd_hgt);
|
||||||
}
|
}
|
||||||
// And add a title...
|
/* And add a title... */
|
||||||
if (lcd_hgt > 2) {
|
if (lcd_hgt > 2) {
|
||||||
sock_send_string(sock, "widget_add L title title\n");
|
sock_send_string(sock, "widget_add L title title\n");
|
||||||
sock_send_string(sock, "widget_set L title {LOAD }\n");
|
sock_send_string(sock, "widget_set L title {LOAD }\n");
|
||||||
@@ -89,19 +89,21 @@ xload_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_printf(sock, "widget_set L top %i %i 1\n", lcd_wid, (lcd_hgt + 1 - gauge_hgt));
|
sock_printf(sock, "widget_set L top %i %i 1\n", lcd_wid, (lcd_hgt + 1 - gauge_hgt));
|
||||||
}
|
}
|
||||||
|
|
||||||
// shift load history
|
/* shift load history */
|
||||||
for (i = 0; i < (lcd_wid - 2); i++)
|
for (i = 0; i < (lcd_wid - 2); i++)
|
||||||
loads[i] = loads[i + 1];
|
loads[i] = loads[i + 1];
|
||||||
|
|
||||||
// get new load value
|
/*
|
||||||
// ignore failure: the shift above makes sure we still have the prev. value
|
* get new load value, ignore failure: the shift above makes sure we
|
||||||
|
* still have the previous value
|
||||||
|
*/
|
||||||
machine_get_loadavg(&(loads[lcd_wid - 2]));
|
machine_get_loadavg(&(loads[lcd_wid - 2]));
|
||||||
|
|
||||||
// determine max. load from history
|
/* determine max. load from history */
|
||||||
for (i = 0; i < lcd_wid - 1; i++)
|
for (i = 0; i < lcd_wid - 1; i++)
|
||||||
loadmax = max(loadmax, loads[i]);
|
loadmax = max(loadmax, loads[i]);
|
||||||
|
|
||||||
// poor man's ceil()
|
/* poor man's ceil() */
|
||||||
loadtop = (int) loadmax;
|
loadtop = (int) loadmax;
|
||||||
if (loadtop < loadmax)
|
if (loadtop < loadmax)
|
||||||
loadtop++;
|
loadtop++;
|
||||||
@@ -109,7 +111,7 @@ xload_screen(int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
factor = (double) (lcd_cellhgt * gauge_hgt) / (double) loadtop;
|
factor = (double) (lcd_cellhgt * gauge_hgt) / (double) loadtop;
|
||||||
|
|
||||||
// display load
|
/* display load */
|
||||||
sock_printf(sock, "widget_set L top %i %i %i\n", lcd_wid, (lcd_hgt + 1 - gauge_hgt), loadtop);
|
sock_printf(sock, "widget_set L top %i %i %i\n", lcd_wid, (lcd_hgt + 1 - gauge_hgt), loadtop);
|
||||||
|
|
||||||
for (i = 0; i < lcd_wid - 1; i++) {
|
for (i = 0; i < lcd_wid - 1; i++) {
|
||||||
@@ -118,13 +120,13 @@ xload_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_printf(sock, "widget_set L bar%i %i %i %i\n", i + 1, i + 1, lcd_hgt, (int) x);
|
sock_printf(sock, "widget_set L bar%i %i %i %i\n", i + 1, i + 1, lcd_hgt, (int) x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// And now the title...
|
/* And now the title... */
|
||||||
if (lcd_hgt > 2)
|
if (lcd_hgt > 2)
|
||||||
sock_printf(sock, "widget_set L title {LOAD %2.2f: %s}\n", loads[lcd_wid - 2], get_hostname());
|
sock_printf(sock, "widget_set L title {LOAD %2.2f: %s}\n", loads[lcd_wid - 2], get_hostname());
|
||||||
else
|
else
|
||||||
sock_printf(sock, "widget_set L title 1 1 {%s %2.2f}\n", get_hostname(), loads[lcd_wid - 2]);
|
sock_printf(sock, "widget_set L title 1 1 {%s %2.2f}\n", get_hostname(), loads[lcd_wid - 2]);
|
||||||
|
|
||||||
// set return status depending on max & current load
|
/* set return status depending on max & current load */
|
||||||
if (lowLoad < highLoad) {
|
if (lowLoad < highLoad) {
|
||||||
status = (loadmax > lowLoad) ? BACKLIGHT_ON : BACKLIGHT_OFF;
|
status = (loadmax > lowLoad) ? BACKLIGHT_ON : BACKLIGHT_OFF;
|
||||||
if (loads[lcd_wid - 2] > highLoad)
|
if (loads[lcd_wid - 2] > highLoad)
|
||||||
@@ -132,4 +134,4 @@ xload_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
} // End xload_screen()
|
}
|
||||||
|
|||||||
+29
-31
@@ -64,8 +64,8 @@ mem_screen(int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
if (lcd_hgt >= 4) {
|
if (lcd_hgt >= 4) {
|
||||||
gauge_wid = (lcd_wid >= 18)
|
gauge_wid = (lcd_wid >= 18)
|
||||||
? (lcd_wid - 6) / 2 // room for E..F pairs and 2 spaces in between
|
? (lcd_wid - 6) / 2 /* room for E..F pairs and 2 spaces in between */
|
||||||
: (lcd_wid - 4) / 2; // leave room for the E...F pairs
|
: (lcd_wid - 4) / 2; /* leave room for the E...F pairs */
|
||||||
|
|
||||||
sock_send_string(sock, "widget_add M title title\n");
|
sock_send_string(sock, "widget_add M title title\n");
|
||||||
sock_send_string(sock, "widget_set M title { MEM}\n");
|
sock_send_string(sock, "widget_set M title { MEM}\n");
|
||||||
@@ -82,7 +82,8 @@ mem_screen(int rep, int display, int *flags_ptr)
|
|||||||
lcd_wid - gauge_wid - 1, gauge_wid, "");
|
lcd_wid - gauge_wid - 1, gauge_wid, "");
|
||||||
sock_send_string(sock, "widget_add M memused string\n");
|
sock_send_string(sock, "widget_add M memused string\n");
|
||||||
sock_send_string(sock, "widget_add M swapused string\n");
|
sock_send_string(sock, "widget_add M swapused string\n");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
gauge_wid = (lcd_wid >= 18) ? max(2, lcd_wid - 18) : 0;
|
gauge_wid = (lcd_wid >= 18) ? max(2, lcd_wid - 18) : 0;
|
||||||
gauge_offs = (lcd_wid - gauge_wid) / 2 + 2;
|
gauge_offs = (lcd_wid - gauge_wid) / 2 + 2;
|
||||||
|
|
||||||
@@ -112,55 +113,56 @@ mem_screen(int rep, int display, int *flags_ptr)
|
|||||||
machine_get_meminfo(mem);
|
machine_get_meminfo(mem);
|
||||||
|
|
||||||
if (lcd_hgt >= 4) {
|
if (lcd_hgt >= 4) {
|
||||||
char tmp[12]; // should be sufficient
|
char tmp[12]; /* should be sufficient */
|
||||||
|
|
||||||
// flip the title back and forth... (every 4 updates)
|
/* flip the title back and forth... (every 4 updates) */
|
||||||
if (which_title & 4) {
|
if (which_title & 4) {
|
||||||
sock_printf(sock, "widget_set M subtitle %i 1 {}\n", lcd_wid - 7);
|
sock_printf(sock, "widget_set M subtitle %i 1 {}\n", lcd_wid - 7);
|
||||||
sock_printf(sock, "widget_set M title {%s}\n", get_hostname());
|
sock_printf(sock, "widget_set M title {%s}\n", get_hostname());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sock_send_string(sock, "widget_set M title { MEM}\n");
|
sock_send_string(sock, "widget_set M title { MEM}\n");
|
||||||
sock_printf(sock, "widget_set M subtitle %i 1 { SWAP }\n", lcd_wid - 7);
|
sock_printf(sock, "widget_set M subtitle %i 1 { SWAP }\n", lcd_wid - 7);
|
||||||
}
|
}
|
||||||
which_title = (which_title + 1) & 7;
|
which_title = (which_title + 1) & 7;
|
||||||
|
|
||||||
// Total memory
|
/* Total memory */
|
||||||
sprintf_memory(tmp, mem[0].total * 1024.0, 1);
|
sprintf_memory(tmp, mem[0].total * 1024.0, 1);
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M memtotl 1 2 {%7s}\n", tmp);
|
sock_printf(sock, "widget_set M memtotl 1 2 {%7s}\n", tmp);
|
||||||
|
|
||||||
// Free memory (plus buffers and cache)
|
/* Free memory (plus buffers and cache) */
|
||||||
sprintf_memory(tmp, (mem[0].free + mem[0].buffers + mem[0].cache) * 1024.0, 1);
|
sprintf_memory(tmp, (mem[0].free + mem[0].buffers + mem[0].cache) * 1024.0, 1);
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M memused 1 3 {%7s}\n", tmp);
|
sock_printf(sock, "widget_set M memused 1 3 {%7s}\n", tmp);
|
||||||
|
|
||||||
// Total swap
|
/* Total swap */
|
||||||
sprintf_memory(tmp, mem[1].total * 1024.0, 1);
|
sprintf_memory(tmp, mem[1].total * 1024.0, 1);
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M swaptotl %i 2 {%7s}\n", lcd_wid - 7, tmp);
|
sock_printf(sock, "widget_set M swaptotl %i 2 {%7s}\n", lcd_wid - 7, tmp);
|
||||||
|
|
||||||
// Free swap
|
/* Free swap */
|
||||||
sprintf_memory(tmp, mem[1].free * 1024.0, 1);
|
sprintf_memory(tmp, mem[1].free * 1024.0, 1);
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M swapused %i 3 {%7s}\n", lcd_wid - 7, tmp);
|
sock_printf(sock, "widget_set M swapused %i 3 {%7s}\n", lcd_wid - 7, tmp);
|
||||||
|
|
||||||
if (gauge_wid > 0) {
|
if (gauge_wid > 0) {
|
||||||
// Free memory graph
|
/* Free memory graph */
|
||||||
if (mem[0].total > 0) {
|
if (mem[0].total > 0) {
|
||||||
double value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
double value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
||||||
/ (double) mem[0].total;
|
/ (double) mem[0].total;
|
||||||
|
|
||||||
//printf(".0f", val) only prints the integer part
|
/* printf(".0f", val) only prints the integer part */
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M memgauge 2 4 %.0f\n",
|
sock_printf(sock, "widget_set M memgauge 2 4 %.0f\n",
|
||||||
lcd_cellwid * gauge_wid * value);
|
lcd_cellwid * gauge_wid * value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free swap graph
|
/* Free swap graph */
|
||||||
if (mem[1].total > 0) {
|
if (mem[1].total > 0) {
|
||||||
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
||||||
|
|
||||||
//printf(".0f", val) only prints the integer part
|
/* printf(".0f", val) only prints the integer part */
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M swapgauge %i 4 %.0f\n",
|
sock_printf(sock, "widget_set M swapgauge %i 4 %.0f\n",
|
||||||
lcd_wid - gauge_wid, lcd_cellwid * gauge_wid * value);
|
lcd_wid - gauge_wid, lcd_cellwid * gauge_wid * value);
|
||||||
@@ -168,26 +170,26 @@ mem_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char tmp[12]; // should be sufficient
|
char tmp[12]; /* should be sufficient */
|
||||||
|
|
||||||
// Total memory
|
/* Total memory */
|
||||||
sprintf_memory(tmp, mem[0].total * 1024.0, 1);
|
sprintf_memory(tmp, mem[0].total * 1024.0, 1);
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M memtotl 3 1 {%6s}\n", tmp);
|
sock_printf(sock, "widget_set M memtotl 3 1 {%6s}\n", tmp);
|
||||||
|
|
||||||
// Total swap
|
/* Total swap */
|
||||||
sprintf_memory(tmp, mem[1].total * 1024.0, 1);
|
sprintf_memory(tmp, mem[1].total * 1024.0, 1);
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M swaptotl 3 2 {%6s}\n", tmp);
|
sock_printf(sock, "widget_set M swaptotl 3 2 {%6s}\n", tmp);
|
||||||
|
|
||||||
// Free memory graph
|
/* Free memory graph */
|
||||||
strcpy(tmp, "N/A");
|
strcpy(tmp, "N/A");
|
||||||
if (mem[0].total > 0) {
|
if (mem[0].total > 0) {
|
||||||
double value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
double value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
||||||
/ (double) mem[0].total;
|
/ (double) mem[0].total;
|
||||||
|
|
||||||
if (gauge_wid > 0) {
|
if (gauge_wid > 0) {
|
||||||
//printf(".0f", val) only prints the integer part
|
/* printf(".0f", val) only prints the integer part */
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M memgauge %i 1 %.0f\n",
|
sock_printf(sock, "widget_set M memgauge %i 1 %.0f\n",
|
||||||
gauge_offs, lcd_cellwid * gauge_wid * value);
|
gauge_offs, lcd_cellwid * gauge_wid * value);
|
||||||
@@ -198,13 +200,13 @@ mem_screen(int rep, int display, int *flags_ptr)
|
|||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M mem%% %i 1 {%5s}\n", lcd_wid - 5, tmp);
|
sock_printf(sock, "widget_set M mem%% %i 1 {%5s}\n", lcd_wid - 5, tmp);
|
||||||
|
|
||||||
// Free swap graph
|
/* Free swap graph */
|
||||||
strcpy(tmp, "N/A");
|
strcpy(tmp, "N/A");
|
||||||
if (mem[1].total > 0) {
|
if (mem[1].total > 0) {
|
||||||
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
||||||
|
|
||||||
if (gauge_wid > 0) {
|
if (gauge_wid > 0) {
|
||||||
//printf(".0f", val) only prints the integer part
|
/* printf(".0f", val) only prints the integer part */
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set M swapgauge %i 2 %.0f\n",
|
sock_printf(sock, "widget_set M swapgauge %i 2 %.0f\n",
|
||||||
gauge_offs, lcd_cellwid * gauge_wid * value);
|
gauge_offs, lcd_cellwid * gauge_wid * value);
|
||||||
@@ -217,7 +219,7 @@ mem_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // End mem_screen()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,14 +274,14 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_send_string(sock, "widget_add S title title\n");
|
sock_send_string(sock, "widget_add S title title\n");
|
||||||
sock_printf(sock, "widget_set S title {TOP MEM: %s}\n", get_hostname());
|
sock_printf(sock, "widget_set S title {TOP MEM: %s}\n", get_hostname());
|
||||||
|
|
||||||
// frame from (2nd line, left) to (last line, right)
|
/* frame from (2nd line, left) to (last line, right) */
|
||||||
sock_send_string(sock, "widget_add S f frame\n");
|
sock_send_string(sock, "widget_add S f frame\n");
|
||||||
sock_printf(sock, "widget_set S f 1 2 %i %i %i 5 v %i\n",
|
sock_printf(sock, "widget_set S f 1 2 %i %i %i 5 v %i\n",
|
||||||
lcd_wid, lcd_hgt, lcd_wid,
|
lcd_wid, lcd_hgt, lcd_wid,
|
||||||
// scroll rate: 1 line every X ticks (= 1/8 sec)
|
/* scroll rate: 1 line every X ticks (= 1/8 sec) */
|
||||||
((lcd_hgt >= 4) ? 8 : 12));
|
((lcd_hgt >= 4) ? 8 : 12));
|
||||||
|
|
||||||
// frame contents
|
/* frame contents */
|
||||||
for (i = 1; i <= 5; i++) {
|
for (i = 1; i <= 5; i++) {
|
||||||
sock_printf(sock, "widget_add S %i string -in f\n", i);
|
sock_printf(sock, "widget_add S %i string -in f\n", i);
|
||||||
}
|
}
|
||||||
@@ -294,7 +296,7 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
machine_get_procs(procs);
|
machine_get_procs(procs);
|
||||||
|
|
||||||
// Now, print some info...
|
/* Now, print some info... */
|
||||||
LL_Rewind(procs);
|
LL_Rewind(procs);
|
||||||
LL_Sort(procs, sort_procs);
|
LL_Sort(procs, sort_procs);
|
||||||
LL_Rewind(procs);
|
LL_Rewind(procs);
|
||||||
@@ -306,7 +308,6 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
sprintf_memory(mem, (double) p->totl * 1024.0, 1);
|
sprintf_memory(mem, (double) p->totl * 1024.0, 1);
|
||||||
|
|
||||||
//printf("Mem hog: %s: %s\n", p->name, mem);
|
|
||||||
if (display) {
|
if (display) {
|
||||||
if (p->number > 1)
|
if (p->number > 1)
|
||||||
sock_printf(sock, "widget_set S %i 1 %i {%i %5s %s(%i)}\n",
|
sock_printf(sock, "widget_set S %i 1 %i {%i %5s %s(%i)}\n",
|
||||||
@@ -317,8 +318,6 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//printf("Mem hog: none?\n");
|
|
||||||
//sprintf(buffer, "widget_set S %i 1 %i {}\n", i, i);
|
|
||||||
if (display)
|
if (display)
|
||||||
sock_printf(sock, "widget_set S %i 1 %i { }\n", i, i);
|
sock_printf(sock, "widget_set S %i 1 %i { }\n", i, i);
|
||||||
}
|
}
|
||||||
@@ -326,12 +325,11 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|||||||
LL_Next(procs);
|
LL_Next(procs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now clean it all up...
|
/* Now clean it all up... */
|
||||||
LL_Rewind(procs);
|
LL_Rewind(procs);
|
||||||
do {
|
do {
|
||||||
procinfo_type *p = (procinfo_type *) LL_Get(procs);
|
procinfo_type *p = (procinfo_type *) LL_Get(procs);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
//printf("Proc: %6ik %s\n", p->size, p->name);
|
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
} while (LL_Next(procs) == 0);
|
} while (LL_Next(procs) == 0);
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ int
|
|||||||
credit_screen(int rep, int display, int *flags_ptr)
|
credit_screen(int rep, int display, int *flags_ptr)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* List of persons who contributed to LCDproc.
|
* List of persons who contributed to LCDproc. Keep in sync with
|
||||||
* Keep in sync with CREDITS file (ordered by appearance)
|
* CREDITS file (ordered by appearance)
|
||||||
*/
|
*/
|
||||||
const char *contributors[] = {
|
const char *contributors[] = {
|
||||||
"William Ferrell",
|
"William Ferrell",
|
||||||
@@ -184,7 +184,8 @@ credit_screen(int rep, int display, int *flags_ptr)
|
|||||||
|
|
||||||
/* get number of contributors */
|
/* get number of contributors */
|
||||||
for (contr_num = 0; contributors[contr_num] != NULL; contr_num++)
|
for (contr_num = 0; contributors[contr_num] != NULL; contr_num++)
|
||||||
;
|
; /* NADA */
|
||||||
|
|
||||||
sock_send_string(sock, "screen_add A\n");
|
sock_send_string(sock, "screen_add A\n");
|
||||||
sock_send_string(sock, "screen_set A -name {Credits for LCDproc}\n");
|
sock_send_string(sock, "screen_set A -name {Credits for LCDproc}\n");
|
||||||
sock_send_string(sock, "widget_add A title title\n");
|
sock_send_string(sock, "widget_add A title title\n");
|
||||||
@@ -199,7 +200,7 @@ credit_screen(int rep, int display, int *flags_ptr)
|
|||||||
sock_send_string(sock, "widget_add A f frame\n");
|
sock_send_string(sock, "widget_add A f frame\n");
|
||||||
sock_printf(sock, "widget_set A f 1 %i %i %i %i %i v %i\n",
|
sock_printf(sock, "widget_set A f 1 %i %i %i %i %i v %i\n",
|
||||||
((lcd_hgt >= 4) ? 3 : 2), lcd_wid, lcd_hgt, lcd_wid, contr_num,
|
((lcd_hgt >= 4) ? 3 : 2), lcd_wid, lcd_hgt, lcd_wid, contr_num,
|
||||||
// scroll rate: 1 line every X ticks (= 1/8 sec)
|
/* scroll rate: 1 line every X ticks (= 1/8 sec) */
|
||||||
((lcd_hgt >= 4) ? 8 : 12));
|
((lcd_hgt >= 4) ? 8 : 12));
|
||||||
|
|
||||||
/* frame contents */
|
/* frame contents */
|
||||||
@@ -209,7 +210,7 @@ credit_screen(int rep, int display, int *flags_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Utility functions to print some numerical values in a nice fashion
|
* Utility functions to print some numerical values in a nice fashion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*-
|
||||||
* Copyright (C) 2005 Peter Marschall
|
* Copyright (C) 2005 Peter Marschall
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
@@ -84,8 +84,10 @@ convert_double(double *value, int base, double roundlimit)
|
|||||||
|
|
||||||
/* Get value's order of magnitude */
|
/* Get value's order of magnitude */
|
||||||
while (units[off] != NULL) {
|
while (units[off] != NULL) {
|
||||||
/* Note: the check for 1000 is to idenfity the number of
|
/*
|
||||||
* characters in the output needed, not to decide if to scale value.
|
* Note: the check for 1000 is to idenfity the number of
|
||||||
|
* characters in the output needed, not to decide if to scale
|
||||||
|
* value.
|
||||||
*/
|
*/
|
||||||
if (*value < 1000 * roundlimit)
|
if (*value < 1000 * roundlimit)
|
||||||
break;
|
break;
|
||||||
|
|||||||
+5
-17
@@ -2,25 +2,15 @@
|
|||||||
* Header file for \c util.c
|
* Header file for \c util.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*-
|
||||||
* Copyright (C) 2005 Peter Marschall
|
* Copyright (C) 2005 Peter Marschall
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This file is part of lcdproc, the lcdproc client.
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This file is released under the GNU General Public License.
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* Refer to the COPYING file distributed with this package.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef LCDPROC_UTIL_H
|
#ifndef LCDPROC_UTIL_H
|
||||||
#define LCDPROC_UTIL_H
|
#define LCDPROC_UTIL_H
|
||||||
|
|
||||||
@@ -36,6 +26,4 @@ char *sprintf_percent(char *dst, double percent);
|
|||||||
/** converts value into power-of-x representation */
|
/** converts value into power-of-x representation */
|
||||||
char *convert_double(double *value, int base, double roundlimit);
|
char *convert_double(double *value, int base, double roundlimit);
|
||||||
|
|
||||||
#endif /* LCDPROC_UTIL_H */
|
#endif
|
||||||
|
|
||||||
/* EOF */
|
|
||||||
|
|||||||
Reference in New Issue
Block a user