vbar/hbar/heartbeat/icon adaptation to new API.
This commit is contained in:
+95
-64
@@ -313,13 +313,13 @@ HD44780_init (Driver * drvthis, char *args)
|
|||||||
//drvthis->output = HD44780_output; // not implemented
|
//drvthis->output = HD44780_output; // not implemented
|
||||||
drvthis->init_vbar = HD44780_init_vbar;
|
drvthis->init_vbar = HD44780_init_vbar;
|
||||||
drvthis->init_hbar = HD44780_init_hbar;
|
drvthis->init_hbar = HD44780_init_hbar;
|
||||||
drvthis->old_vbar = HD44780_vbar;
|
drvthis->vbar = HD44780_vbar;
|
||||||
drvthis->old_hbar = HD44780_hbar;
|
drvthis->hbar = HD44780_hbar;
|
||||||
drvthis->init_num = HD44780_init_num;
|
drvthis->init_num = HD44780_init_num;
|
||||||
drvthis->num = HD44780_num;
|
drvthis->num = HD44780_num;
|
||||||
drvthis->heartbeat = HD44780_heartbeat;
|
drvthis->heartbeat = HD44780_heartbeat;
|
||||||
drvthis->set_char = HD44780_set_char;
|
drvthis->set_char = HD44780_set_char;
|
||||||
drvthis->old_icon = HD44780_icon;
|
drvthis->icon = HD44780_icon;
|
||||||
//drvthis->draw_frame = HD44780_draw_frame; // TO BE REMOVED
|
//drvthis->draw_frame = HD44780_draw_frame; // TO BE REMOVED
|
||||||
|
|
||||||
if ((p->hd44780_functions = (HD44780_functions *) malloc (sizeof (HD44780_functions))) == NULL) {
|
if ((p->hd44780_functions = (HD44780_functions *) malloc (sizeof (HD44780_functions))) == NULL) {
|
||||||
@@ -469,7 +469,7 @@ HD44780_flush (Driver *drvthis)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug( RPT_DEBUG, "HD44780: flushed %d chars", count );
|
debug( RPT_DEBUG, "HD44780: flushed %d chars", count );
|
||||||
|
|
||||||
/* Check which defineable chars we need to update */
|
/* Check which defineable chars we need to update */
|
||||||
count = 0;
|
count = 0;
|
||||||
for( i = 0; i < NUM_UDCs; i ++ ) {
|
for( i = 0; i < NUM_UDCs; i ++ ) {
|
||||||
@@ -718,41 +718,79 @@ HD44780_init_hbar (Driver *drvthis)
|
|||||||
// Draws a vertical bar...
|
// Draws a vertical bar...
|
||||||
//
|
//
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_vbar (Driver *drvthis, int x, int len)
|
HD44780_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||||
{
|
{
|
||||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
//PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||||
char map[9] = { 32, 1, 2, 3, 4, 5, 6, 7, 255 };
|
char map[8] = { 32, 1, 2, 3, 4, 5, 6, 7 };
|
||||||
|
int total_pixels = (long) len * LCD_DEFAULT_CELLHEIGHT * promille / 1000;
|
||||||
|
int pos;
|
||||||
|
|
||||||
int y;
|
/* x and y are the start position of the bar.
|
||||||
for (y = p->height; y > 0 && len > 0; y--) {
|
* The bar by default grows in the 'up' direction
|
||||||
if (len >= p->cellheight)
|
* (other direction not yet implemented).
|
||||||
HD44780_chr (drvthis, x, y, 255);
|
* len is the number of characters that the bar is long at 100%
|
||||||
else
|
* promille is the number of promilles (0..1000) that the bar should be filled.
|
||||||
HD44780_chr (drvthis, x, y, map[len]);
|
*/
|
||||||
|
|
||||||
len -= p->cellheight;
|
HD44780_init_vbar(drvthis);
|
||||||
|
|
||||||
|
for (pos = 0; pos < len; pos ++ ) {
|
||||||
|
|
||||||
|
int pixels = total_pixels - LCD_DEFAULT_CELLHEIGHT * pos;
|
||||||
|
|
||||||
|
if( pixels >= LCD_DEFAULT_CELLHEIGHT ) {
|
||||||
|
/* write a "full" block to the screen... */
|
||||||
|
HD44780_icon (drvthis, x, y-pos, ICON_BLOCK_FILLED);
|
||||||
|
}
|
||||||
|
else if( pixels > 0 ) {
|
||||||
|
/* write a partial block... */
|
||||||
|
HD44780_chr (drvthis, x, y-pos, map[pixels]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
; // write nothing (not even a space)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// Draws a horizontal bar to the right.
|
// Draws a horizontal bar to the right.
|
||||||
//
|
//
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_hbar (Driver *drvthis, int x, int y, int len)
|
HD44780_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||||
{
|
{
|
||||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
//PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||||
char map[6] = { 32, 1, 2, 3, 4, 255 };
|
char map[5] = { 32, 1, 2, 3, 4 };
|
||||||
|
int total_pixels = (long) len * LCD_DEFAULT_CELLWIDTH * promille / 1000;
|
||||||
|
int pos;
|
||||||
|
|
||||||
for (; x <= p->width && len > 0; x++) {
|
/* x and y are the start position of the bar.
|
||||||
if (len >= p->cellwidth)
|
* The bar by default grows in the 'up' direction
|
||||||
HD44780_chr (drvthis, x, y, 255);
|
* (other direction not yet implemented).
|
||||||
else
|
* len is the number of characters that the bar is long at 100%
|
||||||
HD44780_chr (drvthis, x, y, map[len]);
|
* promille is the number of promilles (0..1000) that the bar should be filled.
|
||||||
|
*/
|
||||||
|
|
||||||
len -= p->cellwidth;
|
HD44780_init_hbar(drvthis);
|
||||||
|
|
||||||
|
for (pos = 0; pos < len; pos ++ ) {
|
||||||
|
|
||||||
|
int pixels = total_pixels - LCD_DEFAULT_CELLWIDTH * pos;
|
||||||
|
|
||||||
|
if( pixels >= LCD_DEFAULT_CELLWIDTH ) {
|
||||||
|
/* write a "full" block to the screen. */
|
||||||
|
HD44780_icon (drvthis, x+pos, y, ICON_BLOCK_FILLED);
|
||||||
|
}
|
||||||
|
else if( pixels > 0 ) {
|
||||||
|
/* write a partial block... */
|
||||||
|
HD44780_chr (drvthis, x+pos, y, map[pixels]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
; // write nothing (not even a space)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
@@ -837,12 +875,12 @@ HD44780_init_num (Driver *drvthis)
|
|||||||
0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0
|
0, 0, 0, 0, 0
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if( p->udcmode == UDCMODE_BIGNUM ) {
|
if( p->udcmode == UDCMODE_BIGNUM ) {
|
||||||
/* Work already done */
|
/* Work already done */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( p->udcmode != UDCMODE_STANDARD ) {
|
if( p->udcmode != UDCMODE_STANDARD ) {
|
||||||
/* Not supported (yet) */
|
/* Not supported (yet) */
|
||||||
report( RPT_WARNING, "HD44780_init_num: Cannot combine two modes using user defined characters" );
|
report( RPT_WARNING, "HD44780_init_num: Cannot combine two modes using user defined characters" );
|
||||||
@@ -966,7 +1004,7 @@ MODULE_EXPORT void
|
|||||||
HD44780_heartbeat (Driver *drvthis, int type)
|
HD44780_heartbeat (Driver *drvthis, int type)
|
||||||
{
|
{
|
||||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||||
|
|
||||||
static int timer = 0;
|
static int timer = 0;
|
||||||
int whichIcon;
|
int whichIcon;
|
||||||
static int saved_type = HEARTBEAT_ON;
|
static int saved_type = HEARTBEAT_ON;
|
||||||
@@ -975,18 +1013,14 @@ HD44780_heartbeat (Driver *drvthis, int type)
|
|||||||
saved_type = type;
|
saved_type = type;
|
||||||
|
|
||||||
if (type == HEARTBEAT_ON) {
|
if (type == HEARTBEAT_ON) {
|
||||||
// Set this to pulsate like a real heart beat...
|
/* Set this to pulsate like a real heart beat... */
|
||||||
whichIcon = (! ((timer + 4) & 5));
|
if( ((timer + 4) & 5))
|
||||||
|
whichIcon = ICON_HEART_OPEN;
|
||||||
|
else
|
||||||
|
whichIcon = ICON_HEART_FILLED;
|
||||||
|
|
||||||
// This defines a custom character EVERY time...
|
/* place the icon */
|
||||||
// not efficient... is this necessary?
|
HD44780_icon (drvthis, p->width, 1, whichIcon);
|
||||||
HD44780_icon (drvthis, whichIcon, 0);
|
|
||||||
|
|
||||||
// Put character on screen...
|
|
||||||
HD44780_chr (drvthis, p->width, 1, 0);
|
|
||||||
|
|
||||||
// change display...
|
|
||||||
HD44780_flush (drvthis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timer++;
|
timer++;
|
||||||
@@ -1020,7 +1054,7 @@ HD44780_set_char (Driver *drvthis, int n, char *dat)
|
|||||||
}
|
}
|
||||||
if( p->udc_buf[n*p->cellheight+row] != letter ) {
|
if( p->udc_buf[n*p->cellheight+row] != letter ) {
|
||||||
p->udc_dirty[n] = 1; /* only mark as dirty if really different */
|
p->udc_dirty[n] = 1; /* only mark as dirty if really different */
|
||||||
}
|
}
|
||||||
p->udc_buf[n*p->cellheight+row] = letter;
|
p->udc_buf[n*p->cellheight+row] = letter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1029,46 +1063,43 @@ HD44780_set_char (Driver *drvthis, int n, char *dat)
|
|||||||
// Set default icon into a userdef char
|
// Set default icon into a userdef char
|
||||||
//
|
//
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_icon (Driver *drvthis, int which, char dest)
|
HD44780_icon (Driver *drvthis, int x, int y, int icon)
|
||||||
{
|
{
|
||||||
//PrivateData *p = (PrivateData *) drvthis->private_data;
|
char heart_open[] = {
|
||||||
char icons[3][5 * 8] = {
|
1, 1, 1, 1, 1,
|
||||||
{
|
|
||||||
1, 1, 1, 1, 1, // Empty Heart
|
|
||||||
1, 0, 1, 0, 1,
|
1, 0, 1, 0, 1,
|
||||||
0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0,
|
||||||
1, 0, 0, 0, 1,
|
1, 0, 0, 0, 1,
|
||||||
1, 1, 0, 1, 1,
|
1, 1, 0, 1, 1,
|
||||||
1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1 };
|
||||||
},
|
|
||||||
|
|
||||||
{
|
char heart_filled[] = {
|
||||||
1, 1, 1, 1, 1, // Filled Heart
|
1, 1, 1, 1, 1,
|
||||||
1, 0, 1, 0, 1,
|
1, 0, 1, 0, 1,
|
||||||
0, 1, 0, 1, 0,
|
0, 1, 0, 1, 0,
|
||||||
0, 1, 1, 1, 0,
|
0, 1, 1, 1, 0,
|
||||||
0, 1, 1, 1, 0,
|
0, 1, 1, 1, 0,
|
||||||
1, 0, 1, 0, 1,
|
1, 0, 1, 0, 1,
|
||||||
1, 1, 0, 1, 1,
|
1, 1, 0, 1, 1,
|
||||||
1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1 };
|
||||||
},
|
|
||||||
|
|
||||||
{
|
switch( icon ) {
|
||||||
0, 0, 0, 0, 0, // Ellipsis
|
case ICON_BLOCK_FILLED:
|
||||||
0, 0, 0, 0, 0,
|
HD44780_chr( drvthis, x, y, 255 );
|
||||||
0, 0, 0, 0, 0,
|
break;
|
||||||
0, 0, 0, 0, 0,
|
case ICON_HEART_FILLED:
|
||||||
0, 0, 0, 0, 0,
|
HD44780_set_char( drvthis, 0, heart_filled );
|
||||||
0, 0, 0, 0, 0,
|
HD44780_chr( drvthis, x, y, 0 );
|
||||||
0, 0, 0, 0, 0,
|
break;
|
||||||
1, 0, 1, 0, 1,
|
case ICON_HEART_OPEN:
|
||||||
},
|
HD44780_set_char( drvthis, 0, heart_open );
|
||||||
|
HD44780_chr( drvthis, x, y, 0 );
|
||||||
};
|
break;
|
||||||
|
default:
|
||||||
HD44780_set_char (drvthis, dest, &icons[which][0]);
|
report( RPT_WARNING, "HD44780_icon: unknown or unsupported icon: %d", icon );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ MODULE_EXPORT void HD44780_flush (Driver *drvthis);
|
|||||||
MODULE_EXPORT void HD44780_string (Driver *drvthis, int x, int y, char *s);
|
MODULE_EXPORT void HD44780_string (Driver *drvthis, int x, int y, char *s);
|
||||||
MODULE_EXPORT void HD44780_chr (Driver *drvthis, int x, int y, char ch);
|
MODULE_EXPORT void HD44780_chr (Driver *drvthis, int x, int y, char ch);
|
||||||
|
|
||||||
MODULE_EXPORT void HD44780_vbar (Driver *drvthis, int x, int len);
|
MODULE_EXPORT void HD44780_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||||
MODULE_EXPORT void HD44780_hbar (Driver *drvthis, int x, int y, int len);
|
MODULE_EXPORT void HD44780_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||||
MODULE_EXPORT void HD44780_num (Driver *drvthis, int x, int num);
|
MODULE_EXPORT void HD44780_num (Driver *drvthis, int x, int num);
|
||||||
MODULE_EXPORT void HD44780_heartbeat (Driver *drvthis, int type);
|
MODULE_EXPORT void HD44780_heartbeat (Driver *drvthis, int type);
|
||||||
MODULE_EXPORT void HD44780_icon (Driver *drvthis, int which, char dest);
|
MODULE_EXPORT void HD44780_icon (Driver *drvthis, int x, int y, int icon);
|
||||||
|
|
||||||
MODULE_EXPORT void HD44780_set_char (Driver *drvthis, int n, char *dat);
|
MODULE_EXPORT void HD44780_set_char (Driver *drvthis, int n, char *dat);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user