diff options
-rw-r--r-- | MatrixOrbital.c | 20 | ||||
-rw-r--r-- | bar.c | 6 | ||||
-rw-r--r-- | display.c | 9 | ||||
-rw-r--r-- | display.h | 9 | ||||
-rw-r--r-- | icon.c | 68 | ||||
-rw-r--r-- | icon.h | 11 | ||||
-rw-r--r-- | parser.c | 16 | ||||
-rw-r--r-- | parser.h | 7 | ||||
-rw-r--r-- | processor.c | 9 |
9 files changed, 127 insertions, 28 deletions
diff --git a/MatrixOrbital.c b/MatrixOrbital.c index f392db0..bf45282 100644 --- a/MatrixOrbital.c +++ b/MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $Id: MatrixOrbital.c,v 1.34 2003/08/24 05:17:58 reinelt Exp $ +/* $Id: MatrixOrbital.c,v 1.35 2003/09/01 04:09:34 reinelt Exp $ * * driver for Matrix Orbital serial display modules * @@ -20,6 +20,9 @@ * * * $Log: MatrixOrbital.c,v $ + * Revision 1.35 2003/09/01 04:09:34 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.34 2003/08/24 05:17:58 reinelt * liblcd4linux patch from Patrick Schemitz * @@ -372,7 +375,7 @@ static int MO_init (LCD *Self, int protocol) Lcd.icons=Icons; } - icon_init(Lcd.rows, Lcd.cols, XRES, YRES, Icons); + icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, MO_define_char); bar_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS-Icons); bar_add_segment( 0, 0,255, 32); // ASCII 32 = blank @@ -428,7 +431,7 @@ int MO_bar (int type, int row, int col, int max, int len1, int len2) } -int MO_icon (int num, int row, int col, unsigned char *bitmap) +int MO_icon_old (int num, int row, int col, unsigned char *bitmap) { // icons use last ascii codes char ascii=CHARS-num; @@ -443,6 +446,12 @@ int MO_icon (int num, int row, int col, unsigned char *bitmap) } +int MO_icon (int num, int row, int col) +{ + return icon_draw (num, row, col); +} + + int MO_gpo (int num, int val) { if (num>=Lcd.gpos) @@ -470,6 +479,11 @@ static int MO_flush (int protocol) c=bar_peek(row, col); if (c!=-1) { FrameBuffer1[row*Lcd.cols+col]=(char)c; + } else { + c=icon_peek(row, col); + if (c!=-1) { + FrameBuffer1[row*Lcd.cols+col]=(char)c; + } } } for (col=0; col<Lcd.cols; col++) { @@ -1,4 +1,4 @@ -/* $Id: bar.c,v 1.6 2003/08/20 05:26:43 reinelt Exp $ +/* $Id: bar.c,v 1.7 2003/09/01 04:09:34 reinelt Exp $ * * generic bar handling * @@ -20,6 +20,9 @@ * * * $Log: bar.c,v $ + * Revision 1.7 2003/09/01 04:09:34 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.6 2003/08/20 05:26:43 reinelt * small bug in bar compaction fixed * @@ -94,6 +97,7 @@ int bar_init (int rows, int cols, int xres, int yres, int chars) } if ((Bar=malloc (ROWS*COLS*sizeof(BAR)))==NULL) { + error ("bar buffer allocation failed: out of memory"); return -1; } @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.39 2003/08/24 05:17:58 reinelt Exp $ +/* $Id: display.c,v 1.40 2003/09/01 04:09:34 reinelt Exp $ * * framework for device drivers * @@ -20,6 +20,9 @@ * * * $Log: display.c,v $ + * Revision 1.40 2003/09/01 04:09:34 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.39 2003/08/24 05:17:58 reinelt * liblcd4linux patch from Patrick Schemitz * @@ -363,13 +366,13 @@ int lcd_bar (int type, int row, int col, int max, int len1, int len2) return Lcd->bar (type & BAR_HV, row-1, col-1, max, len1, len2); } -int lcd_icon (int num, int row, int col, unsigned char *bitmap) +int lcd_icon (int num, int row, int col) { if (num<1 || num>Lcd->icons) return -1; if (row<1 || row>Lcd->rows) return -1; if (col<1 || col>Lcd->cols) return -1; if (Lcd->icon==NULL) return 0; - return Lcd->icon(num-1, row-1, col-1, bitmap); + return Lcd->icon(num-1, row-1, col-1); } int lcd_gpo (int num, int val) @@ -1,4 +1,4 @@ -/* $Id: display.h,v 1.19 2003/08/24 05:17:58 reinelt Exp $ +/* $Id: display.h,v 1.20 2003/09/01 04:09:34 reinelt Exp $ * * framework for device drivers * @@ -20,6 +20,9 @@ * * * $Log: display.h,v $ + * Revision 1.20 2003/09/01 04:09:34 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.19 2003/08/24 05:17:58 reinelt * liblcd4linux patch from Patrick Schemitz * @@ -112,7 +115,7 @@ typedef struct LCD { int (*clear) (int full); int (*put) (int x, int y, char *text); int (*bar) (int type, int x, int y, int max, int len1, int len2); - int (*icon) (int num, int row, int col, unsigned char *bitmap); + int (*icon) (int num, int row, int col); int (*gpo) (int num, int val); int (*flush) (void); int (*quit) (void); @@ -135,7 +138,7 @@ int lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars, int *icons int lcd_clear (int full); int lcd_put (int row, int col, char *text); int lcd_bar (int type, int row, int col, int max, int len1, int le2); -int lcd_icon (int num, int row, int col, unsigned char *bitmap); +int lcd_icon (int num, int row, int col); int lcd_gpo (int num, int val); int lcd_flush (void); int lcd_quit (void); @@ -1,4 +1,4 @@ -/* $Id: icon.c,v 1.2 2003/08/24 05:17:58 reinelt Exp $ +/* $Id: icon.c,v 1.3 2003/09/01 04:09:34 reinelt Exp $ * * generic icon and heartbeat handling * @@ -20,6 +20,9 @@ * * * $Log: icon.c,v $ + * Revision 1.3 2003/09/01 04:09:34 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.2 2003/08/24 05:17:58 reinelt * liblcd4linux patch from Patrick Schemitz * @@ -32,6 +35,7 @@ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include "debug.h" #include "cfg.h" @@ -42,28 +46,43 @@ static int ROWS=0; static int COLS=0; static int XRES=0; static int YRES=0; +static int CHARS; static int ICONS=0; -static int *Screen; - +static int *Screen=NULL; +static char *Bitmap=NULL; -#if 0 -static int icon_get_bitmap (int num) +static int icon_read_bitmap (int num, char *bitmap) { - int row, col; + int row, col, len; char key[15]; char *val; + char map; - for (row=1; row<=8; row++) { - snprintf (key, sizeof(key), "Icons%d.Bitmap%d", num, row); - val=cfg_get(key); + for (row=0; row<YRES; row++) { + snprintf (key, sizeof(key), "Icon%d.Bitmap%d", num+1, row+1); + val=cfg_get(key, ""); + len=strlen(val); + map=0; + debug ("read_bitmap: num=%d row=%d val=<%s> len=%d", num, row, val, len); + for (col=0; col<XRES; col++) { + map<<=1; + if (col<len && val[col]=='*') { + map|=1; + } + } + *(bitmap+row-1)=map; } + return 0; } -#endif -int icon_init (int rows, int cols, int xres, int yres, int icons) + +int icon_init (int rows, int cols, int xres, int yres, int chars, int icons, + void(*defchar)(int ascii, char *bitmap)) { + int n; + if (rows<1 || cols<1) return -1; @@ -71,6 +90,7 @@ int icon_init (int rows, int cols, int xres, int yres, int icons) COLS=cols; XRES=xres; YRES=yres; + CHARS=chars, ICONS=icons; if (Screen) { @@ -78,11 +98,29 @@ int icon_init (int rows, int cols, int xres, int yres, int icons) } if ((Screen=malloc(ROWS*COLS*sizeof(*Screen)))==NULL) { + error ("icon buffer allocation failed: out of memory"); return -1; } icon_clear(); + if (Bitmap) { + free (Bitmap); + } + + if ((Bitmap=malloc(YRES*icons*sizeof(*Bitmap)))==NULL) { + error ("icon bitmap allocation failed: out of memory"); + return -1; + } + + memset (Bitmap, 0, YRES*icons*sizeof(*Bitmap)); + + for (n=0; n<icons; n++) { + icon_read_bitmap(n, Bitmap+YRES*n); + // icons use last ascii codes from userdef chars + defchar (CHARS-n-1, Bitmap+YRES*n); + } + return 0; } @@ -98,6 +136,14 @@ void icon_clear(void) } +int icon_draw (int num, int row, int col) +{ + // icons use last ascii codes from userdef chars + Screen[row*COLS+col]=CHARS-num-1; + return 0; +} + + int icon_peek (int row, int col) { return Screen[row*COLS+col]; @@ -1,4 +1,4 @@ -/* $Id: icon.h,v 1.1 2003/08/24 04:31:56 reinelt Exp $ +/* $Id: icon.h,v 1.2 2003/09/01 04:09:35 reinelt Exp $ * * generic icon and heartbeat handling * @@ -20,6 +20,9 @@ * * * $Log: icon.h,v $ + * Revision 1.2 2003/09/01 04:09:35 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.1 2003/08/24 04:31:56 reinelt * icon.c icon.h added * @@ -29,8 +32,10 @@ #ifndef _ICON_H_ #define _ICON_H_ -int icon_init (int rows, int cols, int xres, int yres, int icons); +int icon_init (int rows, int cols, int xres, int yres, int chars, int icons, + void(*defchar)(int ascii, char *bitmap)); void icon_clear(void); -int icon_peek (int row, int col); +int icon_draw (int num, int row, int col); +int icon_peek (int row, int col); #endif @@ -1,4 +1,4 @@ -/* $Id: parser.c,v 1.19 2003/06/21 05:46:18 reinelt Exp $ +/* $Id: parser.c,v 1.20 2003/09/01 04:09:35 reinelt Exp $ * * row definition parser * @@ -20,6 +20,9 @@ * * * $Log: parser.c,v $ + * Revision 1.20 2003/09/01 04:09:35 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.19 2003/06/21 05:46:18 reinelt * DVB client integrated * @@ -135,6 +138,7 @@ typedef struct { static SYMTAB Symtab[] = {{ "%", T_PERCENT, C_GENERIC, 0 }, { "$", T_DOLLAR, C_GENERIC, 0 }, + { "&", T_AMPERSAND, C_GENERIC, 0 }, { "o", T_OS, C_GENERIC, 0 }, { "v", T_RELEASE, C_GENERIC, 0 }, { "p", T_CPU, C_GENERIC, 0 }, @@ -302,6 +306,16 @@ char *parse_row (char *string, int supported_bars, int usage[]) } break; + case '&': + if (*(s+1)<'1'||*(s+1)>'9') { + s++; + error ("WARNING: illegal '&%c' in <%s>", *s, string); + } else { + *p++=*s++; + *p++=*s++; + } + break; + case '\\': if (*(s+1)=='\\') { *p++='\\'; @@ -1,4 +1,4 @@ -/* $Id: parser.h,v 1.12 2003/06/21 05:46:18 reinelt Exp $ +/* $Id: parser.h,v 1.13 2003/09/01 04:09:35 reinelt Exp $ * * row definition parser * @@ -20,6 +20,9 @@ * * * $Log: parser.h,v $ + * Revision 1.13 2003/09/01 04:09:35 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.12 2003/06/21 05:46:18 reinelt * DVB client integrated * @@ -78,7 +81,7 @@ #define _PARSER_H_ typedef enum { - T_PERCENT=128, T_DOLLAR, + T_PERCENT=128, T_DOLLAR, T_AMPERSAND, T_OS, T_RELEASE, T_CPU, T_RAM, T_MEM_TOTAL, T_MEM_USED, T_MEM_FREE, T_MEM_SHARED, T_MEM_BUFFER, T_MEM_CACHE, T_MEM_AVAIL, T_LOAD_1, T_LOAD_2, T_LOAD_3, T_OVERLOAD, diff --git a/processor.c b/processor.c index 3972485..1ca308a 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.37 2003/08/24 05:17:58 reinelt Exp $ +/* $Id: processor.c,v 1.38 2003/09/01 04:09:35 reinelt Exp $ * * main data processing * @@ -20,6 +20,9 @@ * * * $Log: processor.c,v $ + * Revision 1.38 2003/09/01 04:09:35 reinelt + * icons nearly finished, but MatrixOrbital only + * * Revision 1.37 2003/08/24 05:17:58 reinelt * liblcd4linux patch from Patrick Schemitz * @@ -676,6 +679,10 @@ static char *process_row (char *data, int row, int len) *p++='\t'; } + } else if (*s=='&') { + lcd_icon(*(++s)-'0', row, p-buffer+1); + *p++='\t'; + } else { *p++=*s; } |