]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2003-09-10 14:01:52 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 10 Sep 2003 14:01:53 +0000 (14:01 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 10 Sep 2003 14:01:53 +0000 (14:01 +0000)
icons nearly finished\!

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@237 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

Raster.c
XWindow.c
icon.c
pixmap.c
pixmap.h
processor.c

index 99a63c1845c9674e120c19b53bbd629f5ba575fe..406e7c80b43d07fa9e849e17ad846fb53f038afd 100644 (file)
--- 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()'
  *
 #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
index 5ff05a35986928082baf4d05e75f91eee24e35c8..ee0aa73e711712856bbd35cc09803ee80de5c43a 100644 (file)
--- 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()'
  *
 #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 cbc48be0427c49061eb3425c9dcb3ee4b40c1d3a..a43f00793f81b0d5ca826d5af84cb2b0888a69df 100644 (file)
--- 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;
 }
 
index 26f3b2f976329959eeb7e682ff8b05ead16f7916..8cd086e2cb7d75935ff2feea45b9ed61264eb7a1 100644 (file)
--- 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
  *
  * 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 <stdlib.h>
 #include <stdio.h>
 #include <time.h>
 
 #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<ROWS/YRES; row++) {
+    for (col=0; col<COLS/XRES; col++) {
+      c=icon_peek(row, col);
+      if (c!=ascii) continue;
+      for (y=0; y<YRES; y++) {
+       mask=1<<XRES;
+       for (x=0; x<XRES; x++) {
+         mask>>=1;
+         LCDpixmap[(row*YRES+y)*COLS+col*XRES+x]=buffer[y]&mask?1:0;
+       }
+      }
+    }
+  }
+  
+}
index dc3fbae8832bf198e0353f46f371d7107455ce5a..3c114b47d0fade43e1ec0ce012233084ee4c4607 100644 (file)
--- 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
 
 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
index 45c61ccc42aa7cdef37b3fae6f9088201d9931c2..9d2b48f804f9918903432caf8b34b80b72737bb8 100644 (file)
@@ -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<len && p-buffer<cols; i++)
-         *p++=' ';
+         *p++='\t';
       } else {
-       *p++=' ';
+       *p++='\t';
       }
       
     } else if (*s=='&') {
       lcd_icon(*(++s)-'0', 0, row, p-buffer+1);
-      *p++=' ';
+      *p++='\t';
       
     } else {
       *p++=*s;