2009-03-22 11:11:18 +00:00
|
|
|
/** \file server/drivers/lcd_lib.c
|
|
|
|
|
* LCD library of useful functions for drivers.
|
|
|
|
|
*
|
|
|
|
|
* Drawn from the "base driver" which really was the precursor
|
|
|
|
|
* to this library.
|
|
|
|
|
*
|
|
|
|
|
* \todo Make use of the \c options parameter to specify SEAMLESS_HBARS,
|
|
|
|
|
* the height of hbars, etc.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-09-28 21:16:31 +00:00
|
|
|
#include "lcd.h"
|
2002-02-08 00:05:02 +00:00
|
|
|
|
2006-10-08 11:43:21 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-06-17 10:20:55 +00:00
|
|
|
# include "config.h"
|
2006-10-08 11:43:21 +00:00
|
|
|
#endif
|
|
|
|
|
|
2009-03-22 11:11:18 +00:00
|
|
|
/**
|
2002-02-08 00:05:02 +00:00
|
|
|
* This function places a hbar using the v0.5 API format and the given cellwidth.
|
|
|
|
|
* It assumes that custom chars have been statically defined, so that number
|
2009-03-22 11:11:18 +00:00
|
|
|
* 1 has 1 pixel, number 2 has 2 etc.
|
2010-10-30 18:04:21 +00:00
|
|
|
*
|
2002-02-08 00:05:02 +00:00
|
|
|
* LCDs that have the custom chars at other char numbers than 0 should put the
|
|
|
|
|
* first custom char number in cc_offset.
|
|
|
|
|
*/
|
2009-03-22 11:11:18 +00:00
|
|
|
void
|
|
|
|
|
lib_hbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellwidth, int cc_offset)
|
2002-02-08 00:05:02 +00:00
|
|
|
{
|
|
|
|
|
int total_pixels = ((long) 2 * len * cellwidth + 1 ) * promille / 2000;
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
|
|
for (pos = 0; pos < len; pos ++ ) {
|
|
|
|
|
|
|
|
|
|
int pixels = total_pixels - cellwidth * pos;
|
|
|
|
|
|
2006-04-08 20:25:06 +00:00
|
|
|
if ( pixels >= cellwidth ) {
|
2002-02-08 00:05:02 +00:00
|
|
|
/* write a "full" block to the screen... */
|
2010-10-30 18:04:21 +00:00
|
|
|
#if defined(SEAMLESS_HBARS)
|
2005-06-04 14:16:11 +00:00
|
|
|
drvthis->chr (drvthis, x+pos, y, cellwidth + cc_offset);
|
|
|
|
|
#else
|
2002-02-08 00:05:02 +00:00
|
|
|
drvthis->icon (drvthis, x+pos, y, ICON_BLOCK_FILLED);
|
2005-06-04 14:16:11 +00:00
|
|
|
#endif
|
2002-02-08 00:05:02 +00:00
|
|
|
}
|
2006-04-08 20:25:06 +00:00
|
|
|
else if ( pixels > 0 ) {
|
2002-02-08 00:05:02 +00:00
|
|
|
/* write a partial block... */
|
|
|
|
|
drvthis->chr (drvthis, x+pos, y, pixels + cc_offset);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
; /* write nothing (not even a space) */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-22 11:11:18 +00:00
|
|
|
/**
|
2002-02-08 00:05:02 +00:00
|
|
|
* This function places a vbar using the v0.5 API format and the given cellwidth.
|
|
|
|
|
* It assumes that custom chars have been statically defined, so that number
|
2009-03-22 11:11:18 +00:00
|
|
|
* 1 has 1 pixel, number 2 has 2 etc., just like in good old times.
|
2010-10-30 18:04:21 +00:00
|
|
|
*
|
2002-02-08 00:05:02 +00:00
|
|
|
* LCDs that have the custom chars at other char numbers than 0 should put the
|
|
|
|
|
* first custom char number in cc_offset.
|
|
|
|
|
*/
|
2009-03-22 11:11:18 +00:00
|
|
|
void
|
|
|
|
|
lib_vbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellheight, int cc_offset)
|
2002-02-08 00:05:02 +00:00
|
|
|
{
|
|
|
|
|
int total_pixels = ((long) 2 * len * cellheight + 1 ) * promille / 2000;
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
|
|
for (pos = 0; pos < len; pos ++ ) {
|
|
|
|
|
|
|
|
|
|
int pixels = total_pixels - cellheight * pos;
|
|
|
|
|
|
2006-04-08 20:25:06 +00:00
|
|
|
if ( pixels >= cellheight ) {
|
2002-02-08 00:05:02 +00:00
|
|
|
/* write a "full" block to the screen... */
|
|
|
|
|
drvthis->icon (drvthis, x, y-pos, ICON_BLOCK_FILLED);
|
|
|
|
|
}
|
2006-04-08 20:25:06 +00:00
|
|
|
else if ( pixels > 0 ) {
|
2002-02-08 00:05:02 +00:00
|
|
|
/* write a partial block... */
|
|
|
|
|
drvthis->chr (drvthis, x, y-pos, pixels + cc_offset);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
; /* write nothing (not even a space) */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|