]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2003-09-01 04:09:34 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Mon, 1 Sep 2003 04:09:35 +0000 (04:09 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Mon, 1 Sep 2003 04:09:35 +0000 (04:09 +0000)
icons nearly finished, but MatrixOrbital only

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

MatrixOrbital.c
bar.c
display.c
display.h
icon.c
icon.h
parser.c
parser.h
processor.c

index f392db0810bddc27ddc8fa9e991932d8ac29bc19..bf45282645444587aaf67821e1bd07d97f77544a 100644 (file)
@@ -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++) {
diff --git a/bar.c b/bar.c
index 82a0881d086c85c17cee2632abfc98b6e2ccb7f8..9b3f826f81f3bbf5d1b5e51662228439f9f5d4ff 100644 (file)
--- a/bar.c
+++ b/bar.c
@@ -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;
   }
 
index 294bf8e42e8f7ade62be047bbc86e319def6ae80..5028b0271838f841a9e6c87aafee6de973ac6c79 100644 (file)
--- a/display.c
+++ b/display.c
@@ -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)
index 9446e7e40fa776799544594193a5f9ac1b9345e9..11510aa25771913169a7f345d776362a13b542fd 100644 (file)
--- a/display.h
+++ b/display.h
@@ -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);
diff --git a/icon.c b/icon.c
index fdd9fbab4458ac70e70810d138821265a0e17add..ae5e33210bcd8006f8c81608176d211a496181a2 100644 (file)
--- a/icon.c
+++ b/icon.c
@@ -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];
diff --git a/icon.h b/icon.h
index dd18c73f9f35090d7db038f04fa62fb49a2780d1..caa3edbc95a89028a3fe44c8ef22cf2d0a4b37c0 100644 (file)
--- a/icon.h
+++ b/icon.h
@@ -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
  *
 #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
index 61da7861292b71079c51a802a0461d26644cba39..e01be9cf6edbed75e50fdbdbc6917e8eb4b0a435 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -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++='\\';
index 65ae689485467ff27094816b1182e9b2679c2e78..6987f11e6ab4adf4e957d288f55b5805bf1c2eba 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -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, 
index 3972485d87320bf0110cb2d905378ea088299ebf..1ca308a5e8e2785f240a339c0c47a2928311952c 100644 (file)
@@ -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;
     }