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
2000-03-30 20:20:41 +00:00
parent 2222adcfbe
commit f5a5e9653b
88 changed files with 8207 additions and 8723 deletions
+142 -134
View File
@@ -24,8 +24,8 @@
lcd_logical_driver *curses_drv;
int PAD=255;
int ELLIPSIS=7;
int PAD = 255;
int ELLIPSIS = 7;
//////////////////////////////////////////////////////////////////////////
////////////////////// For Curses Terminal Output ////////////////////////
@@ -34,85 +34,65 @@ int ELLIPSIS=7;
static char icon_char = '@';
int curses_drv_init(struct lcd_logical_driver *driver, char *args)
int
curses_drv_init (struct lcd_logical_driver *driver, char *args)
{
char *argv[64];
int argc;
int i,j;
argc = get_args(argv, args, 64);
int i, j;
for(i=0; i<argc; i++)
{
if(0 == strcmp(argv[i], "-f") ||
0 == strcmp(argv[i], "--forecolor"))
{
if(i + 1 > argc) {
fprintf(stderr, "curses_init: %s requires an argument\n",
argv[i]);
argc = get_args (argv, args, 64);
for (i = 0; i < argc; i++) {
if (0 == strcmp (argv[i], "-f") || 0 == strcmp (argv[i], "--forecolor")) {
if (i + 1 > argc) {
fprintf (stderr, "curses_init: %s requires an argument\n", argv[i]);
return -1;
}
// TODO: color display in curses driver!
printf("Sorry, colors not yet implemented...\n");
printf ("Sorry, colors not yet implemented...\n");
//strcpy(device, argv[++i]);
}
else if(0 == strcmp(argv[i], "-b") ||
0 == strcmp(argv[i], "--backcolor"))
{
if(i + 1 > argc) {
fprintf(stderr, "curses_init: %s requires an argument\n",
argv[i]);
} else if (0 == strcmp (argv[i], "-b") || 0 == strcmp (argv[i], "--backcolor")) {
if (i + 1 > argc) {
fprintf (stderr, "curses_init: %s requires an argument\n", argv[i]);
return -1;
}
// TODO: color display in curses driver!
printf("Sorry, colors not yet implemented...\n");
printf ("Sorry, colors not yet implemented...\n");
//strcpy(device, argv[++i]);
}
else if(0 == strcmp(argv[i], "-B") ||
0 == strcmp(argv[i], "--backlight"))
{
if(i + 1 > argc) {
fprintf(stderr, "curses_init: %s requires an argument\n",
argv[i]);
} else if (0 == strcmp (argv[i], "-B") || 0 == strcmp (argv[i], "--backlight")) {
if (i + 1 > argc) {
fprintf (stderr, "curses_init: %s requires an argument\n", argv[i]);
return -1;
}
// TODO: color display in curses driver!
printf("Sorry, colors not yet implemented...\n");
printf ("Sorry, colors not yet implemented...\n");
//strcpy(device, argv[++i]);
}
else if(0 == strcmp(argv[i], "-h") ||
0 == strcmp(argv[i], "--help"))
{
printf("LCDproc [n]curses driver\n"
"\t-f\t--forecolor\tChange the foreground color\n"
"\t-b\t--backcolor\tChange the backlight's \"off\" color\n"
"\t-B\t--backlight\tChange the backlight's \"on\" color\n"
"\t-h\t--help\t\tShow this help information\n");
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
printf ("LCDproc [n]curses driver\n" "\t-f\t--forecolor\tChange the foreground color\n" "\t-b\t--backcolor\tChange the backlight's \"off\" color\n" "\t-B\t--backlight\tChange the backlight's \"on\" color\n" "\t-h\t--help\t\tShow this help information\n");
return -1;
} else {
printf ("Invalid parameter: %s\n", argv[i]);
}
else
{
printf("Invalid parameter: %s\n", argv[i]);
}
}
curses_drv = driver;
// Init curses...
initscr();
cbreak();
noecho();
nodelay(stdscr, TRUE);
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
initscr ();
cbreak ();
noecho ();
nodelay (stdscr, TRUE);
nonl ();
intrflush (stdscr, FALSE);
keypad (stdscr, TRUE);
curses_drv_clear();
curses_drv_clear ();
// Override output functions...
// Override output functions...
driver->clear = curses_drv_clear;
driver->string = curses_drv_string;
driver->chr = curses_drv_chr;
@@ -122,7 +102,7 @@ int curses_drv_init(struct lcd_logical_driver *driver, char *args)
driver->init_hbar = NULL;
driver->num = curses_drv_num;
driver->init_num = curses_drv_init_num;
driver->init = curses_drv_init;
driver->close = curses_drv_close;
driver->flush = curses_drv_flush;
@@ -139,29 +119,31 @@ int curses_drv_init(struct lcd_logical_driver *driver, char *args)
PAD = '#';
// Change the character used for "..."
ELLIPSIS = '~';
return 200; // 200 is arbitrary. (must be 1 or more)
return 200; // 200 is arbitrary. (must be 1 or more)
}
void curses_drv_close()
void
curses_drv_close ()
{
// Close curses
clear();
move(0,0);
refresh();
endwin();
clear ();
move (0, 0);
refresh ();
endwin ();
drv_base_close ();
drv_base_close();
}
/////////////////////////////////////////////////////////////////
// Clears the LCD screen
//
void curses_drv_clear()
void
curses_drv_clear ()
{
clear();
clear ();
}
@@ -169,100 +151,111 @@ void curses_drv_clear()
// Prints a string on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,4).
//
void curses_drv_string(int x, int y, char string[])
void
curses_drv_string (int x, int y, char string[])
{
int i;
unsigned char *c;
for(i=0; string[i]; i++)
{
for (i = 0; string[i]; i++) {
c = &string[i];
switch(*c)
{
case 0: *c = icon_char; break;
case 255: *c = '#'; break;
switch (*c) {
case 0:
*c = icon_char;
break;
case 255:
*c = '#';
break;
}
}
mvaddstr(y-1, x-1, string);
mvaddstr (y - 1, x - 1, string);
}
/////////////////////////////////////////////////////////////////
// Prints a character on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,4).
//
void curses_drv_chr(int x, int y, char c)
void
curses_drv_chr (int x, int y, char c)
{
switch(c)
{
case 0: c = icon_char; break;
case -1: c = '#'; break;
switch (c) {
case 0:
c = icon_char;
break;
case -1:
c = '#';
break;
}
mvaddch(y-1, x-1, c);
mvaddch (y - 1, x - 1, c);
}
/////////////////////////////////////////////////////////////////
// Sets up for big numbers.
//
void curses_drv_init_num()
void
curses_drv_init_num ()
{
}
/////////////////////////////////////////////////////////////////
// Writes a big number.
//
void curses_drv_num(int x, int num)
void
curses_drv_num (int x, int num)
{
char c;
int y, dx;
c='0'+num;
c = '0' + num;
// printf(&c,"%1d",num);
for(y=1; y<5; y++)
for(dx=0; dx<3; dx++)
curses_drv_chr(x+dx, y, c);
for (y = 1; y < 5; y++)
for (dx = 0; dx < 3; dx++)
curses_drv_chr (x + dx, y, c);
}
/////////////////////////////////////////////////////////////////
// Draws a vertical bar; erases entire column onscreen.
//
void curses_drv_vbar(int x, int len)
void
curses_drv_vbar (int x, int len)
{
char map[]="_.,,ooO8";
char map[] = "_.,,ooO8";
int y;
for(y=lcd.hgt; y > 0 && len>0; y--)
{
if(len >= lcd.cellhgt) curses_drv_chr(x, y, '8');
else curses_drv_chr(x, y, map[len-1]);
for (y = lcd.hgt; y > 0 && len > 0; y--) {
if (len >= lcd.cellhgt)
curses_drv_chr (x, y, '8');
else
curses_drv_chr (x, y, map[len - 1]);
len -= lcd.cellhgt;
}
// move(4-len/lcd.cellhgt, x-1);
// vline(0, len/lcd.cellhgt);
}
/////////////////////////////////////////////////////////////////
// Draws a horizontal bar to the right.
//
void curses_drv_hbar(int x, int y, int len)
void
curses_drv_hbar (int x, int y, int len)
{
for(; x<=lcd.wid && len>0; x++)
{
if(len>=lcd.cellwid)
curses_drv_chr(x, y, '=');
for (; x <= lcd.wid && len > 0; x++) {
if (len >= lcd.cellwid)
curses_drv_chr (x, y, '=');
else
curses_drv_chr(x, y, '-');
curses_drv_chr (x, y, '-');
len -= lcd.cellwid;
}
// move(y-1, x-1);
// hline(0, len/lcd.cellwid);
}
@@ -271,56 +264,71 @@ void curses_drv_hbar(int x, int y, int len)
/////////////////////////////////////////////////////////////////
// Sets character 0 to an icon...
//
void curses_drv_icon(int which, char dest)
void
curses_drv_icon (int which, char dest)
{
if(dest == 0)
switch(which)
{
case 0: icon_char = '+'; break;
case 1: icon_char = '*'; break;
default: icon_char = '#'; break;
if (dest == 0)
switch (which) {
case 0:
icon_char = '+';
break;
case 1:
icon_char = '*';
break;
default:
icon_char = '#';
break;
}
}
//////////////////////////////////////////////////////////////////
// Flushes all output to the lcd...
//
void curses_drv_flush()
void
curses_drv_flush ()
{
curses_drv_draw_frame(curses_drv->framebuf);
curses_drv_draw_frame (curses_drv->framebuf);
}
void curses_drv_flush_box(int lft, int top, int rgt, int bot)
void
curses_drv_flush_box (int lft, int top, int rgt, int bot)
{
curses_drv_flush();
curses_drv_flush ();
}
void curses_drv_draw_frame(char *dat)
void
curses_drv_draw_frame (char *dat)
{
// border(0, 0, 0, 0, 0, 0, lcd.wid+1, lcd.hgt+1);
refresh();
refresh ();
}
char curses_drv_getkey()
char
curses_drv_getkey ()
{
int i;
i = getch();
if(i == KEY_LEFT) return 'D';
if(i == KEY_UP) return 'B';
if(i == KEY_DOWN) return 'C';
if(i == KEY_RIGHT) return 'A';
if(i != ERR) return i;
else return 0;
i = getch ();
if (i == KEY_LEFT)
return 'D';
if (i == KEY_UP)
return 'B';
if (i == KEY_DOWN)
return 'C';
if (i == KEY_RIGHT)
return 'A';
if (i != ERR)
return i;
else
return 0;
}