Removed lcddriver.c (doesn't do anything, isn't in any makefiles, etc.).

Passed *every* piece of source in this project through indent. I'm setting
things up with ctags soon and am actually going to *gasp* use a nice
programming environment to continue development in. :)
This commit is contained in:
William Ferrell committed 2000-03-30 20:20:41 +00:00
1 parent 2222adcfbe
commit f5a5e9653b
88 files changed
+8207 -8723

No files matched your search

+126 -120
View File
@@ -14,48 +14,51 @@
int batt_fd = 0;
static int get_batt_stat(int *acstat, int *battstat,
int *battflag, int *percent);
static int get_batt_stat (int *acstat, int *battstat, int *battflag, int *percent);
static int get_batt_stat(int *acstat, int *battstat,
int *battflag, int *percent)
static int
get_batt_stat (int *acstat, int *battstat, int *battflag, int *percent)
{
char str[64];
if(!batt_fd)
batt_fd = open("/proc/apm", O_RDONLY);
if(batt_fd <= 0) return -1;
char str[64];
if(lseek(batt_fd, 0, 0) != 0) return -1;
if (!batt_fd)
batt_fd = open ("/proc/apm", O_RDONLY);
if (batt_fd <= 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 (lseek (batt_fd, 0, 0) != 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;
return 0;
return 0;
}
int batt_init()
int
batt_init ()
{
static int first = 1;
if(first)
{
if (first) {
first = 0;
sock_send_string(sock, "screen_add B\n");
sock_send_string (sock, "screen_add B\n");
}
return 0;
}
int batt_close()
int
batt_close ()
{
if(batt_fd) close(batt_fd);
if (batt_fd)
close (batt_fd);
batt_fd = 0;
return 0;
@@ -72,122 +75,125 @@ int batt_close()
//Batt: Low (Charging)
//E------------------F
int battery_screen(int rep, int display)
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)
{
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");
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(display) sock_send_string(sock, tmp);
if (percent >= 0)
sprintf (buffer, "%i%%", percent);
else
sprintf (buffer, "??%%");
sprintf (tmp, "widget_set B title {Batt: %s: %s}\n", buffer, host);
if(lcd_hgt >= 4) // 4-line version of the screen
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;
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);
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);
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)");
}
} // end if(lcd_hgt >= 4)
else // two-line version of the screen
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(battflag == 0xff)
{
sprintf(tmp+strlen(tmp), "No battery???");
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)");
}
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 + strlen (tmp), "}\n");
if (display)
sock_send_string (sock, tmp);
}
return 0;
return 0;
}