More formatting changes, new tags file.
This commit is contained in:
1 parent
0d703c5864
commit
6a115b4446
64 files changed
+8950
-8950
No files matched your search
+121
-121
@@ -18,47 +18,47 @@ static int get_batt_stat (int *acstat, int *battstat, int *battflag, int *percen
|
||||
static int
|
||||
get_batt_stat (int *acstat, int *battstat, int *battflag, int *percent)
|
||||
{
|
||||
char str[64];
|
||||
char str[64];
|
||||
|
||||
if (!batt_fd)
|
||||
batt_fd = open ("/proc/apm", O_RDONLY);
|
||||
if (batt_fd <= 0)
|
||||
return -1;
|
||||
if (!batt_fd)
|
||||
batt_fd = open ("/proc/apm", O_RDONLY);
|
||||
if (batt_fd <= 0)
|
||||
return -1;
|
||||
|
||||
if (lseek (batt_fd, 0, 0) != 0)
|
||||
return -1;
|
||||
if (lseek (batt_fd, 0, 0) != 0)
|
||||
return -1;
|
||||
|
||||
if (read (batt_fd, str, sizeof (str) - 1) < 0)
|
||||
return -1;
|
||||
if (read (batt_fd, str, sizeof (str) - 1) < 0)
|
||||
return -1;
|
||||
|
||||
if (3 > sscanf (str + 13, "0x%x 0x%x 0x%x %d", acstat, battstat, battflag, percent))
|
||||
return -1;
|
||||
if (3 > sscanf (str + 13, "0x%x 0x%x 0x%x %d", acstat, battstat, battflag, percent))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
batt_init ()
|
||||
{
|
||||
static int first = 1;
|
||||
static int first = 1;
|
||||
|
||||
if (first) {
|
||||
first = 0;
|
||||
sock_send_string (sock, "screen_add B\n");
|
||||
}
|
||||
if (first) {
|
||||
first = 0;
|
||||
sock_send_string (sock, "screen_add B\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
batt_close ()
|
||||
{
|
||||
if (batt_fd)
|
||||
close (batt_fd);
|
||||
batt_fd = 0;
|
||||
if (batt_fd)
|
||||
close (batt_fd);
|
||||
batt_fd = 0;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -74,116 +74,116 @@ batt_close ()
|
||||
int
|
||||
battery_screen (int rep, int display)
|
||||
{
|
||||
static int first = 1;
|
||||
static int first = 1;
|
||||
|
||||
int acstat = 0, battstat = 0, battflag = 0, percent = 0;
|
||||
int acstat = 0, battstat = 0, battflag = 0, percent = 0;
|
||||
|
||||
if (first) {
|
||||
first = 0;
|
||||
if (first) {
|
||||
first = 0;
|
||||
|
||||
sprintf (buffer, "screen_set B -name {APM stats: %s}\n", host);
|
||||
sock_send_string (sock, buffer);
|
||||
sock_send_string (sock, "widget_add B title title\n");
|
||||
sprintf (tmp, "widget_set B title {LCDPROC %s}\n", version);
|
||||
sock_send_string (sock, tmp);
|
||||
sock_send_string (sock, "widget_add B one string\n");
|
||||
if (lcd_hgt >= 4) {
|
||||
sock_send_string (sock, "widget_add B two string\n");
|
||||
sock_send_string (sock, "widget_add B three string\n");
|
||||
sock_send_string (sock, "widget_add B gauge hbar\n");
|
||||
sock_send_string (sock, "widget_set B one 1 2 {AC: Unknown}\n");
|
||||
sock_send_string (sock, "widget_set B two 1 3 {Batt: Unknown}\n");
|
||||
sock_send_string (sock, "widget_set B three 1 4 {E F}\n");
|
||||
sock_send_string (sock, "widget_set B gauge 2 4 0\n");
|
||||
}
|
||||
}
|
||||
// Only run once every 16 frames...
|
||||
//if(rep&0x0f) return 0;
|
||||
sprintf (buffer, "screen_set B -name {APM stats: %s}\n", host);
|
||||
sock_send_string (sock, buffer);
|
||||
sock_send_string (sock, "widget_add B title title\n");
|
||||
sprintf (tmp, "widget_set B title {LCDPROC %s}\n", version);
|
||||
sock_send_string (sock, tmp);
|
||||
sock_send_string (sock, "widget_add B one string\n");
|
||||
if (lcd_hgt >= 4) {
|
||||
sock_send_string (sock, "widget_add B two string\n");
|
||||
sock_send_string (sock, "widget_add B three string\n");
|
||||
sock_send_string (sock, "widget_add B gauge hbar\n");
|
||||
sock_send_string (sock, "widget_set B one 1 2 {AC: Unknown}\n");
|
||||
sock_send_string (sock, "widget_set B two 1 3 {Batt: Unknown}\n");
|
||||
sock_send_string (sock, "widget_set B three 1 4 {E F}\n");
|
||||
sock_send_string (sock, "widget_set B gauge 2 4 0\n");
|
||||
}
|
||||
}
|
||||
// Only run once every 16 frames...
|
||||
//if(rep&0x0f) return 0;
|
||||
|
||||
get_batt_stat (&acstat, &battstat, &battflag, &percent);
|
||||
get_batt_stat (&acstat, &battstat, &battflag, &percent);
|
||||
|
||||
if (percent >= 0)
|
||||
sprintf (buffer, "%i%%", percent);
|
||||
else
|
||||
sprintf (buffer, "??%%");
|
||||
sprintf (tmp, "widget_set B title {Batt: %s: %s}\n", buffer, host);
|
||||
if (percent >= 0)
|
||||
sprintf (buffer, "%i%%", percent);
|
||||
else
|
||||
sprintf (buffer, "??%%");
|
||||
sprintf (tmp, "widget_set B title {Batt: %s: %s}\n", buffer, host);
|
||||
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
|
||||
if (lcd_hgt >= 4) // 4-line version of the screen
|
||||
{
|
||||
sprintf (tmp, "widget_set B one 1 2 {");
|
||||
switch (acstat) {
|
||||
case 0:
|
||||
sprintf (tmp + strlen (tmp), "AC: Off}\n");
|
||||
break;
|
||||
case 1:
|
||||
sprintf (tmp + strlen (tmp), "AC: On}\n");
|
||||
break;
|
||||
case 2:
|
||||
sprintf (tmp + strlen (tmp), "AC: Backup}\n");
|
||||
break;
|
||||
default:
|
||||
sprintf (tmp + strlen (tmp), "AC: Unknown}\n");
|
||||
break;
|
||||
}
|
||||
if (lcd_hgt >= 4) // 4-line version of the screen
|
||||
{
|
||||
sprintf (tmp, "widget_set B one 1 2 {");
|
||||
switch (acstat) {
|
||||
case 0:
|
||||
sprintf (tmp + strlen (tmp), "AC: Off}\n");
|
||||
break;
|
||||
case 1:
|
||||
sprintf (tmp + strlen (tmp), "AC: On}\n");
|
||||
break;
|
||||
case 2:
|
||||
sprintf (tmp + strlen (tmp), "AC: Backup}\n");
|
||||
break;
|
||||
default:
|
||||
sprintf (tmp + strlen (tmp), "AC: Unknown}\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
|
||||
sprintf (tmp, "widget_set B two 1 3 {");
|
||||
if (battflag == 0xff) {
|
||||
sprintf (tmp + strlen (tmp), "Battery Stat Unknown");
|
||||
} else {
|
||||
sprintf (tmp + strlen (tmp), "Batt:");
|
||||
if (battflag & 1)
|
||||
sprintf (tmp + strlen (tmp), " High");
|
||||
if (battflag & 2)
|
||||
sprintf (tmp + strlen (tmp), " Low");
|
||||
if (battflag & 4)
|
||||
sprintf (tmp + strlen (tmp), " Critical");
|
||||
if (battflag & 8 || battstat == 3)
|
||||
sprintf (tmp + strlen (tmp), " Charging");
|
||||
if (battflag & 128)
|
||||
sprintf (tmp + strlen (tmp), " (NONE)");
|
||||
}
|
||||
sprintf (tmp + strlen (tmp), "}\n");
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
sprintf (tmp, "widget_set B two 1 3 {");
|
||||
if (battflag == 0xff) {
|
||||
sprintf (tmp + strlen (tmp), "Battery Stat Unknown");
|
||||
} else {
|
||||
sprintf (tmp + strlen (tmp), "Batt:");
|
||||
if (battflag & 1)
|
||||
sprintf (tmp + strlen (tmp), " High");
|
||||
if (battflag & 2)
|
||||
sprintf (tmp + strlen (tmp), " Low");
|
||||
if (battflag & 4)
|
||||
sprintf (tmp + strlen (tmp), " Critical");
|
||||
if (battflag & 8 || battstat == 3)
|
||||
sprintf (tmp + strlen (tmp), " Charging");
|
||||
if (battflag & 128)
|
||||
sprintf (tmp + strlen (tmp), " (NONE)");
|
||||
}
|
||||
sprintf (tmp + strlen (tmp), "}\n");
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
|
||||
if (percent > 0) {
|
||||
sprintf (tmp, "widget_set B gauge 2 4 %i\n", (percent * ((lcd_wid - 2) * lcd_cellwid) / 100));
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
}
|
||||
} // end if(lcd_hgt >= 4)
|
||||
else // two-line version of the screen
|
||||
{
|
||||
sprintf (tmp, "widget_set B one 1 2 {");
|
||||
if (acstat == 1)
|
||||
sprintf (tmp + strlen (tmp), "AC, ");
|
||||
if (percent > 0) {
|
||||
sprintf (tmp, "widget_set B gauge 2 4 %i\n", (percent * ((lcd_wid - 2) * lcd_cellwid) / 100));
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
}
|
||||
} // end if(lcd_hgt >= 4)
|
||||
else // two-line version of the screen
|
||||
{
|
||||
sprintf (tmp, "widget_set B one 1 2 {");
|
||||
if (acstat == 1)
|
||||
sprintf (tmp + strlen (tmp), "AC, ");
|
||||
|
||||
if (battflag == 0xff) {
|
||||
sprintf (tmp + strlen (tmp), "No battery???");
|
||||
} else {
|
||||
sprintf (tmp + strlen (tmp), "Batt:");
|
||||
if (battflag & 1)
|
||||
sprintf (tmp + strlen (tmp), " High");
|
||||
if (battflag & 2)
|
||||
sprintf (tmp + strlen (tmp), " Low");
|
||||
if (battflag & 4)
|
||||
sprintf (tmp + strlen (tmp), " Critical");
|
||||
if (battflag & 8 || battstat == 3)
|
||||
sprintf (tmp + strlen (tmp), " Charging");
|
||||
if (battflag & 128)
|
||||
sprintf (tmp + strlen (tmp), " (NONE)");
|
||||
}
|
||||
sprintf (tmp + strlen (tmp), "}\n");
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
if (battflag == 0xff) {
|
||||
sprintf (tmp + strlen (tmp), "No battery???");
|
||||
} else {
|
||||
sprintf (tmp + strlen (tmp), "Batt:");
|
||||
if (battflag & 1)
|
||||
sprintf (tmp + strlen (tmp), " High");
|
||||
if (battflag & 2)
|
||||
sprintf (tmp + strlen (tmp), " Low");
|
||||
if (battflag & 4)
|
||||
sprintf (tmp + strlen (tmp), " Critical");
|
||||
if (battflag & 8 || battstat == 3)
|
||||
sprintf (tmp + strlen (tmp), " Charging");
|
||||
if (battflag & 128)
|
||||
sprintf (tmp + strlen (tmp), " (NONE)");
|
||||
}
|
||||
sprintf (tmp + strlen (tmp), "}\n");
|
||||
if (display)
|
||||
sock_send_string (sock, tmp);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user