From 085b539d34e7a6bbdda9bf36b0384882fbe88a09 Mon Sep 17 00:00:00 2001 From: robijn Date: Fri, 8 Feb 2002 00:05:02 +0000 Subject: [PATCH] Lib update. Added vbar and hbar functions that use a statically defined custom charset. Let the lib heartbeat function use the new icon function. --- server/drivers/lcd_lib.c | 74 ++++++++++++++++++++++++++++++++++++---- server/drivers/lcd_lib.h | 4 +++ 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/server/drivers/lcd_lib.c b/server/drivers/lcd_lib.c index 2be8b05..1c10b73 100644 --- a/server/drivers/lcd_lib.c +++ b/server/drivers/lcd_lib.c @@ -1,13 +1,9 @@ #include -#include #include -#include -#include #include -#include #include "lcd.h" -#include "render.h" + // ================================================== // LCD library of useful functions for drivers @@ -18,7 +14,6 @@ // TODO: What should this really be? Probably should be in the // driver code or headers or something... -#define MAX_CUSTOM_CHARS 16 /* ANY DRIVER SHOULD SIMPLY FREE ITS FRAMEBUFFER AT CLOSE() @@ -148,10 +143,75 @@ output_heartbeat (struct lcd_logical_driver *driver, int type) { */ // change display... - driver->flush (driver); + //driver->flush (driver); } timer++; timer &= 0x0f; } + +void +lib_hbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellwidth, int cc_offset) +/* + * 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 + * 1 has 1 pixel, number 2 has 2 etc... + * LCDs that have the custom chars at other char numbers than 0 should put the + * first custom char number in cc_offset. + */ +{ + int total_pixels = ((long) 2 * len * cellwidth + 1 ) * promille / 2000; + int pos; + + for (pos = 0; pos < len; pos ++ ) { + + int pixels = total_pixels - cellwidth * pos; + + if( pixels >= cellwidth ) { + /* write a "full" block to the screen... */ + drvthis->icon (drvthis, x+pos, y, ICON_BLOCK_FILLED); + } + else if( pixels > 0 ) { + /* write a partial block... */ + drvthis->chr (drvthis, x+pos, y, pixels + cc_offset); + break; + } + else { + ; /* write nothing (not even a space) */ + } + } +} + + +void +lib_vbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellheight, int cc_offset) +/* + * 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 + * 1 has 1 pixel, number 2 has 2 etc., just like in good old times... + * LCDs that have the custom chars at other char numbers than 0 should put the + * first custom char number in cc_offset. + */ +{ + int total_pixels = ((long) 2 * len * cellheight + 1 ) * promille / 2000; + int pos; + + for (pos = 0; pos < len; pos ++ ) { + + int pixels = total_pixels - cellheight * pos; + + if( pixels >= cellheight ) { + /* write a "full" block to the screen... */ + drvthis->icon (drvthis, x, y-pos, ICON_BLOCK_FILLED); + } + else if( pixels > 0 ) { + /* write a partial block... */ + drvthis->chr (drvthis, x, y-pos, pixels + cc_offset); + break; + } + else { + ; /* write nothing (not even a space) */ + } + } +} diff --git a/server/drivers/lcd_lib.h b/server/drivers/lcd_lib.h index 00d1336..c5ccb8d 100644 --- a/server/drivers/lcd_lib.h +++ b/server/drivers/lcd_lib.h @@ -7,5 +7,9 @@ int new_framebuf (struct lcd_logical_driver *driver, char *oldbuf); +void output_heartbeat (struct lcd_logical_driver *driver, int type); +void lib_hbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellwidth, int cc_offset); +void lib_vbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellheight, int cc_offset); + #endif