diff --git a/server/drivers/curses_drv.c b/server/drivers/curses_drv.c index 8426877..951b81c 100644 --- a/server/drivers/curses_drv.c +++ b/server/drivers/curses_drv.c @@ -372,9 +372,9 @@ curses_drv_init (Driver *drvthis, char *args) drvthis->backlight = curses_drv_backlight; //drvthis->set_char = NULL; - drvthis->old_icon = curses_drv_icon; // NEEDS TO BE CHANGED ! + drvthis->icon = curses_drv_icon; - drvthis->getkey = curses_drv_getkey; + drvthis->get_key = curses_drv_get_key; drvthis->heartbeat = curses_drv_heartbeat; // Change the character used for "..." @@ -498,7 +498,7 @@ curses_drv_string (Driver *drvthis, int x, int y, char *string) // *p = icon_char; // break; case 255: - *p = PAD; + *p = PAD; // CAN BE REMOVED AS SOON AS SERVER USES _icon INSTEAD OF character 255 break; } p++; @@ -521,10 +521,10 @@ curses_drv_chr (Driver *drvthis, int x, int y, char c) switch (c) { case 0: - c = icon_char; + c = icon_char; // The whole icon_char stuff can be removed too if API change is complete break; case -1: // translates to 255 (ouch!) - c = PAD; + c = PAD; // CAN BE REMOVED AS SOON AS SERVER USES _icon INSTEAD OF character 255 break; //default: // normal character... @@ -570,16 +570,17 @@ curses_drv_vbar (Driver *drvthis, int x, int y, int len, int promille, int optio { char map[] = { ACS_S9, ACS_S9, ACS_S7, ACS_S7, ACS_S3, ACS_S3, ACS_S1, ACS_S1 }; int pos; - int total_pixels = (long) len * LCD_DEFAULT_CELLHEIGHT * promille / 1000; + int total_pixels = ((long) 2 * len * LCD_DEFAULT_CELLHEIGHT + 1 ) * promille / 2000; ValidX(x); ValidY(y); - // x and y are the start position of the bar. - // The bar by default grows in the 'up' direction - // (other directions not yet implemented). - // len is the number of characters that the bar is long at 100% - // promille is the number of percent * 10 that the bar should be filled. + /* x and y are the start position of the bar. + * The bar by default grows in the 'up' direction + * (other direction not yet implemented). + * len is the number of characters that the bar is long at 100% + * promille is the number of promilles (0..1000) that the bar should be filled. + */ for (pos = 0; pos < len; pos ++ ) { @@ -588,8 +589,7 @@ curses_drv_vbar (Driver *drvthis, int x, int y, int len, int promille, int optio ValidY(y-pos); if( pixels >= LCD_DEFAULT_CELLHEIGHT ) { - // write a "full" block to the screen... - //curses_drv_chr (x, y, '8'); + /* write a "full" block to the screen... */ curses_drv_chr (drvthis, x, y-pos, ACS_BLOCK); } else if( pixels > 0 ) { @@ -610,16 +610,17 @@ MODULE_EXPORT void curses_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int options) { int pos; - int total_pixels = (long) len * LCD_DEFAULT_CELLWIDTH * promille / 1000; + int total_pixels = ((long) 2 * len * LCD_DEFAULT_CELLWIDTH + 1 ) * promille / 2000; ValidX(x); ValidY(y); - // x and y are the start position of the bar. - // The bar by default grows in the 'up' direction - // (other directions not yet implemented). - // len is the number of characters that the bar is long at 100% - // promille is the number of percent * 10 that the bar should be filled. + /* x and y are the start position of the bar. + * The bar by default grows in the 'right' direction + * (other direction not yet implemented). + * len is the number of characters that the bar is long at 100% + * promille is the number of promilles (0..1000) that the bar should be filled. + */ for (pos = 0; pos < len; pos ++ ) { @@ -628,12 +629,11 @@ curses_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int optio ValidX(x+pos); if( pixels >= LCD_DEFAULT_CELLHEIGHT * 2/3 ) { - // write a "full" block to the screen... - //curses_drv_chr (x, y, '8'); + /* write a "full" block to the screen... */ curses_drv_chr (drvthis, x+pos, y, '='); } else if( pixels > LCD_DEFAULT_CELLHEIGHT * 1/3 ) { - // write a partial block... + /* write a partial block... */ curses_drv_chr (drvthis, x+pos, y, '-'); break; } @@ -647,21 +647,22 @@ curses_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int optio // Sets character 0 to an icon... // MODULE_EXPORT void -curses_drv_icon (Driver *drvthis, int which, char dest) +curses_drv_icon (Driver *drvthis, int x, int y, int icon) { - if (dest == 0) - switch (which) { - case 0: - icon_char = '+'; - break; - case 1: - icon_char = '*'; - break; - default: - icon_char = PAD; - break; - } - + switch (icon) { + case ICON_HEART_OPEN: + curses_drv_chr( drvthis, x, y, '+'); + break; + case ICON_HEART_FILLED: + curses_drv_chr( drvthis, x, y, '*'); + break; + case ICON_BLOCK_FILLED: + curses_drv_chr( drvthis, x, y, ACS_BLOCK); + break; + } +/* There was something with placing PAD + * What wasthat ever for ? + */ } ///////////////////////////////////////////////////////////// @@ -679,17 +680,14 @@ curses_drv_heartbeat (Driver *drvthis, int type) if (type == HEARTBEAT_ON) { // Set this to pulsate like a real heart beat... - whichIcon = (! ((timer + 4) & 5)); - - // This defines a custom character EVERY time... - // not efficient... is this necessary? - curses_drv_icon (drvthis, whichIcon, 0); - - // Put character on screen... - curses_drv_chr (drvthis, width, 1, 0); - - // change display... - curses_drv_flush (drvthis); + if ( (timer + 4) & 5 ) { + whichIcon = ICON_HEART_OPEN; + } + else { + whichIcon = ICON_HEART_FILLED; + } + // Place the icon on screen + curses_drv_icon (drvthis, width, 1, whichIcon); } timer++; @@ -715,10 +713,11 @@ curses_drv_flush (Driver *drvthis) } -MODULE_EXPORT char -curses_drv_getkey (Driver *drvthis) +MODULE_EXPORT char * +curses_drv_get_key (Driver *drvthis) { int i; + static char ret_val[2] = {0,0}; i = getch (); @@ -728,22 +727,31 @@ curses_drv_getkey (Driver *drvthis) return 0; break; case KEY_LEFT: - return 'D'; + return "ArrowLeft"; break; case KEY_UP: - return 'B'; + return "ArrowUp"; break; case KEY_DOWN: - return 'C'; + return "ArrowDown"; break; case KEY_RIGHT: - return 'A'; + return "ArrowRight"; break; case ERR: - return 0; + return NULL; + break; + case KEY_ENTER: + case 0x0D: + return "Enter"; /* Is this correct ? */ + break; + case 0x1B: + return "Escape"; break; default: - return i; + report( RPT_INFO, "curses_drv: Unknown key 0x%4x", i ); + ret_val[0] = (char) i & 0xFF; + return ret_val; break; } } diff --git a/server/drivers/curses_drv.h b/server/drivers/curses_drv.h index 1395961..21c845e 100644 --- a/server/drivers/curses_drv.h +++ b/server/drivers/curses_drv.h @@ -16,11 +16,11 @@ MODULE_EXPORT void curses_drv_vbar (Driver *drvthis, int x, int y, int len, int MODULE_EXPORT void curses_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void curses_drv_num (Driver *drvthis, int x, int num); MODULE_EXPORT void curses_drv_heartbeat (Driver *drvthis, int type); -MODULE_EXPORT void curses_drv_icon (Driver *drvthis, int which, char dest); +MODULE_EXPORT void curses_drv_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT void curses_drv_backlight (Driver *drvthis, int on); -MODULE_EXPORT char curses_drv_getkey (Driver *drvthis); +MODULE_EXPORT char *curses_drv_get_key (Driver *drvthis); MODULE_EXPORT void curses_drv_init_num (Driver *drvthis); diff --git a/server/drivers/debug.c b/server/drivers/debug.c index 9e3e846..c549d0e 100644 --- a/server/drivers/debug.c +++ b/server/drivers/debug.c @@ -54,8 +54,8 @@ debug_init (Driver *drvthis, char *args) drvthis->clear = debug_clear; drvthis->string = debug_string; drvthis->chr = debug_chr; - drvthis->old_vbar = debug_vbar; - drvthis->old_hbar = debug_hbar; + drvthis->vbar = debug_vbar; + drvthis->hbar = debug_hbar; drvthis->init_num = debug_init_num; drvthis->num = debug_num; @@ -67,11 +67,11 @@ debug_init (Driver *drvthis, char *args) drvthis->set_contrast = debug_set_contrast; drvthis->backlight = debug_backlight; drvthis->set_char = debug_set_char; - drvthis->old_icon = debug_icon; + drvthis->icon = debug_icon; drvthis->init_vbar = debug_init_vbar; drvthis->init_hbar = debug_init_hbar; - drvthis->getkey = debug_getkey; + drvthis->get_key = debug_get_key; return 0; } @@ -229,51 +229,55 @@ debug_set_char (Driver *drvthis, int n, char *dat) // Draws a vertical bar; erases entire column onscreen. // MODULE_EXPORT void -debug_vbar (Driver *drvthis, int x, int len) +debug_vbar (Driver *drvthis, int x, int y, int len, int promille, int options) { - int y; + int pos; - report (RPT_INFO, "vbar(%i,%i)", x, len); + report (RPT_INFO, "vbar(%i,%i,%i,%i,%i)", x, y, len, promille, options); - for (y = height; y > 0 && len > 0; y--) { - debug_chr (drvthis, x, y, '|'); - - len -= LCD_DEFAULT_CELLHEIGHT; + for ( pos=0; pos 0; x++) { - debug_chr (drvthis, x, y, '-'); + report (RPT_INFO, "hbar(%i,%i,%i,%i,%i)", x, y, len, promille, options); - len -= LCD_DEFAULT_CELLWIDTH; + for ( pos=0; posstring = text_string; drvthis->chr = text_chr; - drvthis->old_vbar = text_vbar; + drvthis->vbar = text_vbar; //drvthis->init_vbar = NULL; - drvthis->old_hbar = text_hbar; + drvthis->hbar = text_hbar; //drvthis->init_hbar = NULL; drvthis->num = text_num; //drvthis->init_num = NULL; @@ -131,7 +131,7 @@ text_init (Driver *drvthis, char *args) //drvthis->set_char = NULL; //drvthis->icon = NULL; - //drvthis->getkey = NULL; + //drvthis->get_key = NULL; return 0; } @@ -266,28 +266,11 @@ text_backlight (Driver *drvthis, int on) */ } -//void -//text_init_vbar () -//{ -//// printf("Vertical bars.\n"); -//} - -//void -//text_init_hbar () -//{ -//// printf("Horizontal bars.\n"); -//} - -//void -//text_init_num () -//{ -//// printf("Big Numbers.\n"); -//} - ///////////////////////////////////////////////////////////////// // Writes a big number. (by Rene Wagner from lcdm001.c) // -MODULE_EXPORT void text_num (Driver *drvthis, int x, int num) +MODULE_EXPORT void +text_num (Driver *drvthis, int x, int num) { //PrivateData * p = (PrivateData*) drvthis->private_data; @@ -309,28 +292,33 @@ MODULE_EXPORT void text_num (Driver *drvthis, int x, int num) // Draws a vertical bar; erases entire column onscreen. // MODULE_EXPORT void -text_vbar (Driver *drvthis, int x, int len) +text_vbar (Driver *drvthis, int x, int y, int len, int promille, int options) { - int y; - for (y = height; y > 0 && len > 0; y--) { - text_chr (drvthis, x, y, '|'); + int pos; - len -= LCD_DEFAULT_CELLHEIGHT; + for ( pos=0; pos 0; x++) { - text_chr (drvthis, x, y, '-'); + int pos; - len -= LCD_DEFAULT_CELLWIDTH; + for ( pos=0; pos