From f3f0b72ff2607397a1d3f6d9523ad85ae271b80c Mon Sep 17 00:00:00 2001 From: reinelt Date: Wed, 10 Sep 2003 14:01:53 +0000 Subject: [lcd4linux @ 2003-09-10 14:01:52 by reinelt] icons nearly finished\! git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@237 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- Raster.c | 23 ++++++++++++++++++++++- XWindow.c | 25 +++++++++++++++++++++++-- icon.c | 19 +++++++++++-------- pixmap.c | 39 ++++++++++++++++++++++++++++++++++++++- pixmap.h | 14 +++++++++----- processor.c | 11 +++++++---- 6 files changed, 110 insertions(+), 21 deletions(-) diff --git a/Raster.c b/Raster.c index 99a63c1..406e7c8 100644 --- a/Raster.c +++ b/Raster.c @@ -1,4 +1,4 @@ -/* $Id: Raster.c,v 1.26 2003/09/09 06:54:43 reinelt Exp $ +/* $Id: Raster.c,v 1.27 2003/09/10 14:01:52 reinelt Exp $ * * driver for raster formats * @@ -20,6 +20,9 @@ * * * $Log: Raster.c,v $ + * Revision 1.27 2003/09/10 14:01:52 reinelt + * icons nearly finished\! + * * Revision 1.26 2003/09/09 06:54:43 reinelt * new function 'cfg_number()' * @@ -158,6 +161,7 @@ #include "cfg.h" #include "display.h" #include "bar.h" +#include "icon.h" #include "pixmap.h" static LCD Lcd; @@ -167,6 +171,7 @@ static int pgap=0; static int rgap=0; static int cgap=0; static int border=0; +static int icons; static unsigned int foreground=0; static unsigned int halfground=0; @@ -392,10 +397,17 @@ int Raster_init (LCD *Self) return -1; } + if (cfg_number("Icons", 0, 0, 8, &icons) < 0) return -1; + if (icons>0) { + info ("allocating %d icons", icons); + icon_init(rows, cols, xres, yres, 8, icons, pix_icon); + } + Self->rows=rows; Self->cols=cols; Self->xres=xres; Self->yres=yres; + Self->icons=icons; Lcd=*Self; pix_clear(); @@ -412,6 +424,11 @@ int Raster_bar (int type, int row, int col, int max, int len1, int len2) return pix_bar (type, row, col, max, len1, len2); } +int Raster_icon (int num, int seq, int row, int col) +{ + return icon_draw (num, seq, row, col); +} + LCD Raster[] = { #ifdef WITH_PPM @@ -421,11 +438,13 @@ LCD Raster[] = { xres: 0, yres: 0, bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T, + icons: 0, gpos: 0, init: Raster_init, clear: Raster_clear, put: Raster_put, bar: Raster_bar, + icon: Raster_icon, gpo: NULL, flush: PPM_flush }, #endif @@ -436,11 +455,13 @@ LCD Raster[] = { xres: 0, yres: 0, bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T, + icons: 0, gpos: 0, init: Raster_init, clear: Raster_clear, put: Raster_put, bar: Raster_bar, + icon: Raster_icon, gpo: NULL, flush: PNG_flush }, #endif diff --git a/XWindow.c b/XWindow.c index 5ff05a3..ee0aa73 100644 --- a/XWindow.c +++ b/XWindow.c @@ -1,4 +1,4 @@ -/* $Id: XWindow.c,v 1.33 2003/09/09 06:54:43 reinelt Exp $ +/* $Id: XWindow.c,v 1.34 2003/09/10 14:01:53 reinelt Exp $ * * X11 Driver for LCD4Linux * @@ -20,6 +20,9 @@ * * * $Log: XWindow.c,v $ + * Revision 1.34 2003/09/10 14:01:53 reinelt + * icons nearly finished\! + * * Revision 1.33 2003/09/09 06:54:43 reinelt * new function 'cfg_number()' * @@ -165,6 +168,7 @@ #include "cfg.h" #include "display.h" #include "bar.h" +#include "icon.h" #include "pixmap.h" @@ -199,6 +203,7 @@ static int cgap=0; /*column gap between characters*/ static int border=0; /*window border*/ static int rows=-1,cols=-1; /*rows+cols without background*/ static int xres=-1,yres=-1; /*xres+yres (same as self->...)*/ +static int icons; /* number of user-defined icons */ static int dimx,dimy; /*total window dimension in pixel*/ static int boxw,boxh; /*box width, box height*/ static int async_update(); /*PROTO*/ @@ -428,6 +433,13 @@ int xlcdinit(LCD *Self) if (*rgbhg=='\\') rgbhg++; if (pix_init(rows,cols,xres,yres)==-1) return -1; + + if (cfg_number("Icons", 0, 0, 8, &icons) < 0) return -1; + if (icons>0) { + info ("allocating %d icons", icons); + icon_init(rows, cols, xres, yres, 8, icons, pix_icon); + } + if (init_x(rows,cols,xres,yres)==-1) return -1; init_signals(); if (init_shm(rows*cols*xres*yres,&LCDpixmap2)==-1) return -1; @@ -437,6 +449,7 @@ int xlcdinit(LCD *Self) Self->cols=cols; Self->xres=xres; Self->yres=yres; + Self->icons=icons; Lcd=*Self; pix_clear(); @@ -450,7 +463,7 @@ int xlcdclear(int full) } -int xlcdput(int row,int col,char *text) +int xlcdput(int row,int col, char *text) { return pix_put(row,col,text); } @@ -462,6 +475,12 @@ int xlcdbar(int type, int row, int col, int max, int len1, int len2) } +int xlcdicon (int num, int seq, int row, int col) +{ + return icon_draw (num, seq, row, col); +} + + int xlcdflush() { int dirty; int row,col; @@ -565,11 +584,13 @@ LCD XWindow[] = { xres: 0, yres: 0, bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T, + icons: 0, gpos: 0, init: xlcdinit, clear: xlcdclear, put: xlcdput, bar: xlcdbar, + icon: xlcdicon, gpo: NULL, flush: xlcdflush, quit: xlcdquit diff --git a/icon.c b/icon.c index cbc48be..a43f007 100644 --- a/icon.c +++ b/icon.c @@ -1,4 +1,4 @@ -/* $Id: icon.c,v 1.5 2003/09/10 03:48:23 reinelt Exp $ +/* $Id: icon.c,v 1.6 2003/09/10 14:01:53 reinelt Exp $ * * generic icon and heartbeat handling * @@ -20,6 +20,9 @@ * * * $Log: icon.c,v $ + * Revision 1.6 2003/09/10 14:01:53 reinelt + * icons nearly finished\! + * * Revision 1.5 2003/09/10 03:48:23 reinelt * Icons for M50530, new processing scheme (Ticks.Text...) * @@ -166,7 +169,7 @@ int icon_init (int rows, int cols, int xres, int yres, int chars, int icons, memset (Bitmap[n].Data, 0, YRES*sizeof(char)); icon_read_bitmap(n); // icons use last ascii codes from userdef chars - Defchar (CHARS-n-1, Bitmap[n].Data); + if (Defchar) Defchar (CHARS-n-1, Bitmap[n].Data); } return 0; @@ -186,19 +189,19 @@ void icon_clear(void) int icon_draw (int num, int seq, int row, int col) { + if (row>=0 && col>=0) { + // icons use last ascii codes from userdef chars + Screen[row*COLS+col]=CHARS-num-1; + } + if (seq>=0) { seq%=Bitmap[num].nData; if (seq!=Bitmap[num].lData) { Bitmap[num].lData=seq; - Defchar (CHARS-num-1, Bitmap[num].Data+seq*YRES); + if (Defchar) Defchar (CHARS-num-1, Bitmap[num].Data+seq*YRES); } } - if (row>=0 && col>=0) { - // icons use last ascii codes from userdef chars - Screen[row*COLS+col]=CHARS-num-1; - } - return 0; } diff --git a/pixmap.c b/pixmap.c index 26f3b2f..8cd086e 100644 --- a/pixmap.c +++ b/pixmap.c @@ -1,4 +1,4 @@ -/* $Id: pixmap.c,v 1.10 2002/08/19 04:41:20 reinelt Exp $ +/* $Id: pixmap.c,v 1.11 2003/09/10 14:01:53 reinelt Exp $ * * generic pixmap driver * @@ -20,6 +20,9 @@ * * * $Log: pixmap.c,v $ + * Revision 1.11 2003/09/10 14:01:53 reinelt + * icons nearly finished\! + * * Revision 1.10 2002/08/19 04:41:20 reinelt * introduced bar.c, moved bar stuff from display.h to bar.h * @@ -84,14 +87,19 @@ * int pix_bar (int type, int row, int col, int max, int len1, int len2); * draws a bar into the pixmap * + * void pix_icon (int ascii, char *buffer) + * used as the "define char" function for icons + * */ + #include #include #include #include "display.h" #include "bar.h" +#include "icon.h" #include "pixmap.h" #include "fontmap.h" #include "debug.h" @@ -103,6 +111,7 @@ static int YRES=0; unsigned char *LCDpixmap=NULL; + int pix_clear(void) { int i; @@ -114,6 +123,7 @@ int pix_clear(void) return 0; } + int pix_init (int rows, int cols, int xres, int yres) { if (rows<1 || cols<1 || xres<1 || yres<1) @@ -133,6 +143,7 @@ int pix_init (int rows, int cols, int xres, int yres) return pix_clear(); } + int pix_put (int row, int col, char *text) { int c, x, y, mask; @@ -157,6 +168,7 @@ int pix_put (int row, int col, char *text) return 0; } + #define N_BAR_T 10 int pix_bar (int type, int row, int col, int max, int len1, int len2) @@ -273,3 +285,28 @@ int pix_bar (int type, int row, int col, int max, int len1, int len2) return 0; } + +void pix_icon (int ascii, char *buffer) +{ + // we have to peek the whole screen for this particular icon, + // and render it again + + int row, col; + int x, y, mask; + int c; + + for (row=0; row>=1; + LCDpixmap[(row*YRES+y)*COLS+col*XRES+x]=buffer[y]&mask?1:0; + } + } + } + } + +} diff --git a/pixmap.h b/pixmap.h index dc3fbae..3c114b4 100644 --- a/pixmap.h +++ b/pixmap.h @@ -1,4 +1,4 @@ -/* $Id: pixmap.h,v 1.3 2000/03/26 19:03:52 reinelt Exp $ +/* $Id: pixmap.h,v 1.4 2003/09/10 14:01:53 reinelt Exp $ * * generic pixmap driver * @@ -20,6 +20,9 @@ * * * $Log: pixmap.h,v $ + * Revision 1.4 2003/09/10 14:01:53 reinelt + * icons nearly finished\! + * * Revision 1.3 2000/03/26 19:03:52 reinelt * * more Pixmap renaming @@ -44,9 +47,10 @@ extern unsigned char *LCDpixmap; -int pix_clear (void); -int pix_init (int rows, int cols, int xres, int yres); -int pix_put (int row, int col, char *text); -int pix_bar (int type, int row, int col, int max, int len1, int len2); +int pix_clear (void); +int pix_init (int rows, int cols, int xres, int yres); +int pix_put (int row, int col, char *text); +int pix_bar (int type, int row, int col, int max, int len1, int len2); +void pix_icon (int ascii, char *buffer); #endif diff --git a/processor.c b/processor.c index 45c61cc..9d2b48f 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.42 2003/09/10 08:37:09 reinelt Exp $ +/* $Id: processor.c,v 1.43 2003/09/10 14:01:53 reinelt Exp $ * * main data processing * @@ -20,6 +20,9 @@ * * * $Log: processor.c,v $ + * Revision 1.43 2003/09/10 14:01:53 reinelt + * icons nearly finished\! + * * Revision 1.42 2003/09/10 08:37:09 reinelt * icons: reorganized tick_* again... * @@ -693,14 +696,14 @@ static char *process_row (char *data, int row, int len) if (type & BAR_H) { for (i=0; i