]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-01-11 09:26:15 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 11 Jan 2004 09:26:15 +0000 (09:26 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 11 Jan 2004 09:26:15 +0000 (09:26 +0000)
layout starts to exist...

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

cfg.c
drv_MatrixOrbital.c
layout.c
widget.c

diff --git a/cfg.c b/cfg.c
index ddf9f4be5989cf2ca929b8a6f051320c4afb9fd1..c5983d4b3d84d165cad5d16151a66fd4d4ad32f7 100644 (file)
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.24 2004/01/10 20:22:33 reinelt Exp $^
+/* $Id: cfg.c,v 1.25 2004/01/11 09:26:15 reinelt Exp $^
  *
  * config file stuff
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: cfg.c,v $
+ * Revision 1.25  2004/01/11 09:26:15  reinelt
+ * layout starts to exist...
+ *
  * Revision 1.24  2004/01/10 20:22:33  reinelt
  * added new function 'cfg_list()' (not finished yet)
  * added layout.c (will replace processor.c someday)
  *   cfg_cmd can be called _before_ cfg_read()
  *   returns 0 if ok, -1 if arg cannot be parsed
  *
+ * cfg_list (section)
+ *   returns a list of all keys in the specified section
+ *   This list was allocated be cfg_list() and must be 
+ *   freed by the caller!
+ *
  * cfg_get (section, key, defval) 
  *   return the a value for a given key in a given section 
  *   or <defval> if key does not exist
@@ -323,7 +331,7 @@ int l4l_cfg_cmd (char *arg)
 char *l4l_cfg_list (char *section)
 {
   int i, len;
-  char *key;
+  char *key, *list;
   
   // calculate key length
   len=strlen(section)+1;
@@ -333,14 +341,21 @@ char *l4l_cfg_list (char *section)
   strcpy (key, section);
   strcat (key, ".");
   
+  // start with empty string
+  list=malloc(1);
+  *list='\0';
+  
   // search matching entries
   for (i=0; i<nConfig; i++) {
     if (strncasecmp(Config[i].key, key, len)==0) {
-      debug ("found list: %s", Config[i].key);
+      list=realloc(list, strlen(list)+strlen(Config[i].key)-len+2);
+      strcat (list, "|");
+      strcat (list, Config[i].key+len);
     }
   }
   
-  return NULL;
+  free (key);
+  return list;
 }
 
 
index c0e8da11870e6e5f4e969eb2bcbe81d098b2cc86..03fc5b49b1f1e431f2d3c6c594ed0e0a80bd73f7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.4 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.5 2004/01/11 09:26:15 reinelt Exp $
  *
  * new style driver for Matrix Orbital serial display modules
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.5  2004/01/11 09:26:15  reinelt
+ * layout starts to exist...
+ *
  * Revision 1.4  2004/01/10 20:22:33  reinelt
  * added new function 'cfg_list()' (not finished yet)
  * added layout.c (will replace processor.c someday)
@@ -381,7 +384,7 @@ static int drv_MO_start (char *section)
   for (i=0; Models[i].type!=0xff; i++) {
     if (Models[i].type == (int)*buffer) break;
   }
-  info ("MatrixOrbital: Display identifies itself as a '%s' (type 0x%02x)", 
+  info ("MatrixOrbital: display identifies itself as a '%s' (type 0x%02x)", 
        Models[i].name, Models[i].type);
   
   // auto-dedection
@@ -398,13 +401,13 @@ static int drv_MO_start (char *section)
   drv_MO_write ("\3765", 2);
   usleep(100000);
   drv_MO_read (buffer, 2);
-  info ("MatrixOrbital: Display reports Serial Number 0x%x", *(short*)buffer);
+  info ("MatrixOrbital: display reports serial number 0x%x", *(short*)buffer);
   
   // read version number
   drv_MO_write ("\3766", 2);
   usleep(100000);
   drv_MO_read (buffer, 1);
-  info ("MatrixOrbital: Display reports Firmware Version 0x%x", *buffer);
+  info ("MatrixOrbital: display reports firmware version 0x%x", *buffer);
 
   
   // initialize global variables
index 774a4bf4ba8fc7f1aff5a00fe268eaaa7dd5b8e5..65b03731f9394a15a8f4585e974e14feea430b86 100644 (file)
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.1 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: layout.c,v 1.2 2004/01/11 09:26:15 reinelt Exp $
  *
  * new layouter framework
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: layout.c,v $
+ * Revision 1.2  2004/01/11 09:26:15  reinelt
+ * layout starts to exist...
+ *
  * Revision 1.1  2004/01/10 20:22:33  reinelt
  * added new function 'cfg_list()' (not finished yet)
  * added layout.c (will replace processor.c someday)
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "debug.h"
 #include "cfg.h"
 #include "layout.h"
 
 
-#define MAX_ROWS 32
-#define MAX_COLS 80
+void layout_addItem (char *name, int row, int col)
+{
+
+  debug ("layout_addItem(%s, %d, %d)", name, row, col);
+}
+
 
 int layout_init (char *layout)
 {
-  char *section, *widget;
-  char  buffer[15];
+  char *section;
+  char *list;
+  char *key;
+  char *widget;
   int row, col;
   
+  char buffer[32];
+  
   info ("initializing layout '%s'", layout);
   
   // prepare config section
-  // strlen("Layout:")=7, +1=8
+  // strlen("Layout:")=7
   section=malloc(strlen(layout)+8);
   strcpy(section, "Layout:");
   strcat(section, layout);
 
-  cfg_list(section);
-
+  list=cfg_list(section);
+  key=strtok(list, "|");
+  while (key!=NULL) {
+    int i, n;
+    char *k;
+    // map to lower char for scanf()
+    for (k=key; *k!='\0'; k++) *k=tolower(*k);
+    i=sscanf (key, "row%d.col%d%n", &row, &col, &n);
+    if (i==2 && key[n]=='\0') {
+      widget=cfg_get(section, key, NULL);
+      if (widget!=NULL && *widget!='\0') {
+       layout_addItem (widget, row, col);
+      }
+    }
+    key=strtok(NULL, "|");
+  }
+  free (list);
   
   return 0;
 }
index e152571b3d93d0c3d1383aa4fef8980d30d76e72..301914dc3becb17d1d6598e76e762cae15703c56 100644 (file)
--- a/widget.c
+++ b/widget.c
@@ -1,4 +1,4 @@
-/* $Id: widget.c,v 1.4 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: widget.c,v 1.5 2004/01/11 09:26:15 reinelt Exp $
  *
  * generic widget handling
  *
@@ -21,6 +21,9 @@
  *
  *
  * $Log: widget.c,v $
+ * Revision 1.5  2004/01/11 09:26:15  reinelt
+ * layout starts to exist...
+ *
  * Revision 1.4  2004/01/10 20:22:33  reinelt
  * added new function 'cfg_list()' (not finished yet)
  * added layout.c (will replace processor.c someday)
@@ -60,8 +63,8 @@
 static WIDGET_CLASS *Classes=NULL;
 static int          nClasses=0;
 
-static WIDGET *Widgets=NULL;
-static int    nWidgets=0;
+static WIDGET       *Widgets=NULL;
+static int          nWidgets=0;
 
 
 int widget_register (WIDGET_CLASS *widget)