Converted old to new functions.
This commit is contained in:
+63
-55
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+28
-24
@@ -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<len; pos++ ) {
|
||||
if( 2 * pos < ((long) promille * len / 500 + 1) ) {
|
||||
debug_chr (drvthis, x, y-pos, '|');
|
||||
} else {
|
||||
; /* print nothing */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
debug_hbar (Driver *drvthis, int x, int y, int len)
|
||||
debug_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
report (RPT_INFO, "hbar(%i,%i,%i)", x, y, len);
|
||||
int pos;
|
||||
|
||||
for (; x < width && len > 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; pos<len; pos++ ) {
|
||||
if( 2 * pos < ((long) promille * len / 500 + 1) ) {
|
||||
debug_chr (drvthis, x+pos, y, '-');
|
||||
} else {
|
||||
; /* print nothing */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
debug_icon (Driver *drvthis, int which, char dest)
|
||||
debug_icon (Driver *drvthis, int x, int y, int icon)
|
||||
{
|
||||
report (RPT_INFO, "icon(%i,%i", which, dest);
|
||||
report (RPT_INFO, "icon(%i,%i,%i)", x, y, icon);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Return a keypress
|
||||
//
|
||||
MODULE_EXPORT char
|
||||
debug_getkey (Driver *drvthis)
|
||||
MODULE_EXPORT char *
|
||||
debug_get_key (Driver *drvthis)
|
||||
{
|
||||
report (RPT_INFO, "getkey()");
|
||||
return 0;
|
||||
report (RPT_INFO, "get_key()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -12,17 +12,17 @@ MODULE_EXPORT void debug_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void debug_string (Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void debug_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void debug_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void debug_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void debug_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void debug_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void debug_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void debug_icon (Driver *drvthis, int which, char dest);
|
||||
MODULE_EXPORT void debug_icon (Driver *drvthis, int x, int y, int icon);
|
||||
|
||||
MODULE_EXPORT void debug_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT void debug_set_contrast (Driver *drvthis, int promille);
|
||||
MODULE_EXPORT void debug_backlight (Driver *drvthis, int promille);
|
||||
|
||||
MODULE_EXPORT char debug_getkey (Driver *drvthis);
|
||||
MODULE_EXPORT char *debug_get_key (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT void debug_init_vbar (Driver *drvthis);
|
||||
MODULE_EXPORT void debug_init_hbar (Driver *drvthis);
|
||||
|
||||
+21
-33
@@ -118,9 +118,9 @@ text_init (Driver *drvthis, char *args)
|
||||
drvthis->string = 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<len; pos++ ) {
|
||||
if( 2 * pos < ((long) promille * len / 500 + 1) ) {
|
||||
text_chr (drvthis, x, y-pos, '|');
|
||||
} else {
|
||||
; /* print nothing */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
text_hbar (Driver *drvthis, int x, int y, int len)
|
||||
text_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
for (; x <= width && len > 0; x++) {
|
||||
text_chr (drvthis, x, y, '-');
|
||||
int pos;
|
||||
|
||||
len -= LCD_DEFAULT_CELLWIDTH;
|
||||
for ( pos=0; pos<len; pos++ ) {
|
||||
if( 2 * pos < ((long) promille * len / 500 + 1) ) {
|
||||
text_chr (drvthis, x+pos, y, '-');
|
||||
} else {
|
||||
; /* print nothing */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ MODULE_EXPORT void text_backlight (Driver *drvthis, int on);
|
||||
//MODULE_EXPORT void text_init_vbar (Driver *drvthis);
|
||||
//MODULE_EXPORT void text_init_hbar (Driver *drvthis);
|
||||
//MODULE_EXPORT void text_init_num (Driver *drvthis);
|
||||
MODULE_EXPORT void text_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void text_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void text_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void text_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void text_num (Driver *drvthis, int x, int num);
|
||||
//MODULE_EXPORT void text_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user