]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-03-19 09:17:46 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 19 Mar 2004 09:17:46 +0000 (09:17 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 19 Mar 2004 09:17:46 +0000 (09:17 +0000)
removed the extra 'goto' function, row and col are additional parameters
of the write() function now.

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

drv_Crystalfontz.c
drv_Cwlinux.c
drv_HD44780.c
drv_M50530.c
drv_MatrixOrbital.c
drv_USBLCD.c
drv_generic_text.c
drv_generic_text.h

index 7b7889d6d8c1ec362545da15f252df7a60c7c84d..164141e75dd9e0bfda4cca488d5c84875bffd3a5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_Crystalfontz.c,v 1.13 2004/03/03 03:41:02 reinelt Exp $
+/* $Id: drv_Crystalfontz.c,v 1.14 2004/03/19 09:17:46 reinelt Exp $
  *
  * new style driver for Crystalfontz display modules
  *
  *
  *
  * $Log: drv_Crystalfontz.c,v $
+ * Revision 1.14  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.13  2004/03/03 03:41:02  reinelt
  * Crystalfontz Contrast issue fixed
  *
@@ -105,7 +110,6 @@ static char Name[]="Crystalfontz";
 
 static int Model;
 static int Protocol;
-static int Row, Col;
 
 // ring buffer for bytes received from the display
 static unsigned char RingBuffer[256];
@@ -328,56 +332,41 @@ static void drv_CF_send (int cmd, int len, char *data)
 }
 
 
-static void drv_CF_write1 (unsigned char *string, int len)
+static void drv_CF_write1 (int row, int col, unsigned char *data, int len)
 {
-  drv_generic_serial_write (string, len);
+  char cmd[3]="\021xy"; // set cursor position
+  
+  if (row==0 && col==0) {
+    drv_generic_serial_write ("\001", 1); // cursor home
+  } else {
+    cmd[1]=(char)col;
+    cmd[2]=(char)row;
+    drv_generic_serial_write (cmd, 3);
+  }
+  
+  drv_generic_serial_write (data, len);
 }
 
 
-static void drv_CF_write2 (unsigned char *string, int len)
+static void drv_CF_write2 (int row, int col, unsigned char *data, int len)
 {
   // limit length
-  if (Col+len>16) len=16-Col;
+  if (col+len>16) len=16-col;
   if (len<0) len=0;
   
   // sanity check
-  if (Row>=2 || Col+len>16) {
+  if (row>=2 || col+len>16) {
     error ("%s: internal error: write outside linebuffer bounds!", Name);
     return;
   }
-  memcpy (Line+16*Row+Col, string, len);
-  drv_CF_send (7+Row, 16, Line+16*Row);
-}
-
-
-static void drv_CF_write3 (unsigned char *string, int len)
-{
-  debug ("write3(<%.*s>,%d)", len, string, len);
-
-  
+  memcpy (Line+16*row+col, data, len);
+  drv_CF_send (7+row, 16, Line+16*row);
 }
 
 
-static void drv_CF_goto1 (int row, int col)
-{
-  char cmd[3]="\021xy"; // set cursor position
-  
-  if (row==0 && col==0) {
-    drv_CF_write1("\001", 1); // cursor home
-  } else {
-    cmd[1]=(char)col;
-    cmd[2]=(char)row;
-    drv_CF_write1(cmd, 3);
-  }
-}
-
-static void drv_CF_goto23 (int row, int col)
+static void drv_CF_write3 (int row, int col, unsigned char *data, int len)
 {
-  // as the 633 does not have random access to the display content,
-  // and the 631 needs coordinates with random access, 
-  // we just store the needed cursor position
-  Row=row;
-  Col=col;
+  debug ("write3(<%.*s>,%d)", len, data, len);
 }
 
 
@@ -387,8 +376,8 @@ static void drv_CF_defchar1 (int ascii, unsigned char *buffer)
   
   // user-defineable chars start at 128, but are defined at 0
   cmd[1]=(char)(ascii-CHAR0); 
-  drv_CF_write1 (cmd, 2);
-  drv_CF_write1 (buffer, 8);
+  drv_generic_serial_write (cmd, 2);
+  drv_generic_serial_write (buffer, 8);
 }
 
 
@@ -422,7 +411,7 @@ static int drv_CF_contrast (int contrast)
     if (Contrast > 100) Contrast = 100;
     buffer[0] = 15; // Set LCD Contrast
     buffer[1] = Contrast;
-    drv_CF_write1 (buffer, 2);
+    drv_generic_serial_write (buffer, 2);
     break;
 
   case 2:
@@ -457,7 +446,7 @@ static int drv_CF_backlight (int backlight)
   case 1:
     buffer[0] = 14; // Set LCD Backlight
     buffer[1] = Backlight;
-    drv_CF_write1 (buffer, 2);
+    drv_generic_serial_write (buffer, 2);
     break;
 
   case 2:
@@ -611,10 +600,10 @@ static int drv_CF_scan_DOW (unsigned char index)
 // init sequences for 626, 632, 634, 636 
 static void drv_CF_start_1 (void)
 {
-  drv_CF_write1 ("\014", 1);  // Form Feed (Clear Display)
-  drv_CF_write1 ("\004", 1);  // hide cursor
-  drv_CF_write1 ("\024", 1);  // scroll off
-  drv_CF_write1 ("\030", 1);  // wrap off
+  drv_generic_serial_write ("\014", 1);  // Form Feed (Clear Display)
+  drv_generic_serial_write ("\004", 1);  // hide cursor
+  drv_generic_serial_write ("\024", 1);  // scroll off
+  drv_generic_serial_write ("\030", 1);  // wrap off
 }
 
 
@@ -852,14 +841,12 @@ int drv_CF_init (char *section)
   case 1:
     CHAR0 = 128;   // ASCII of first user-defineable char
     GOTO_COST = 3; // number of bytes a goto command requires
-    drv_generic_text_real_goto    = drv_CF_goto1;
     drv_generic_text_real_write   = drv_CF_write1;
     drv_generic_text_real_defchar = drv_CF_defchar1;
     break;
   case 2:
     CHAR0 = 0; // ASCII of first user-defineable char
     GOTO_COST = 20; // there is no goto on 633
-    drv_generic_text_real_goto    = drv_CF_goto23;
     drv_generic_text_real_write   = drv_CF_write2;
     drv_generic_text_real_defchar = drv_CF_defchar23;
     break;
@@ -867,7 +854,6 @@ int drv_CF_init (char *section)
     CHAR0 = 0; // ASCII of first user-defineable char
     // Fixme: 
     GOTO_COST = 3; // number of bytes a goto command requires
-    drv_generic_text_real_goto    = drv_CF_goto23;
     drv_generic_text_real_write   = drv_CF_write2;
     drv_generic_text_real_defchar = drv_CF_defchar23;
     break;
index 9757069d38703b05c1f15e4e057970999daa5d04..349aa541914f768f8ed50f5e5d63fd7b658300ee 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_Cwlinux.c,v 1.3 2004/02/14 11:56:17 reinelt Exp $
+/* $Id: drv_Cwlinux.c,v 1.4 2004/03/19 09:17:46 reinelt Exp $
  *
  * new style driver for Cwlinux display modules
  *
  *
  *
  * $Log: drv_Cwlinux.c,v $
+ * Revision 1.4  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.3  2004/02/14 11:56:17  reinelt
  * M50530 driver ported
  * changed lots of 'char' to 'unsigned char'
@@ -95,12 +100,15 @@ static MODEL Models[] = {
 // ***  hardware dependant functions    ***
 // ****************************************
 
-static void drv_CW_goto (int row, int col)
+static void drv_CW_write (int row, int col, unsigned char *data, int len)
 {
   char cmd[6]="\376Gxy\375";
+  
   cmd[2]=(char)col;
   cmd[3]=(char)row;
-  drv_generic_serial_write(cmd, 5);
+  drv_generic_serial_write (cmd, 5);
+
+  drv_generic_serial_write (data, len);
 }
 
 
@@ -279,8 +287,7 @@ int drv_CW_init (char *section)
   GOTO_COST = 3;  // number of bytes a goto command requires
 
   // real worker functions
-  drv_generic_text_real_write   = drv_generic_serial_write;
-  drv_generic_text_real_goto    = drv_CW_goto;
+  drv_generic_text_real_write = drv_CW_write;
 
   switch (Protocol) {
     case 1:
index 3b1abecd97ac054bc7f06cbed72ee9d7580d7ce9..ba5c91232fe2937e671be36cc1f41fd154bc521e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_HD44780.c,v 1.16 2004/03/11 06:39:58 reinelt Exp $
+/* $Id: drv_HD44780.c,v 1.17 2004/03/19 09:17:46 reinelt Exp $
  *
  * new style driver for HD44780-based displays
  *
  *
  *
  * $Log: drv_HD44780.c,v $
+ * Revision 1.17  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.16  2004/03/11 06:39:58  reinelt
  * big patch from Martin:
  * - reuse filehandles
@@ -480,9 +485,10 @@ static void drv_HD_goto (int row, int col)
 }
 
 
-static void drv_HD_write (unsigned char *string, int len)
+static void drv_HD_write (int row, int col, unsigned char *data, int len)
 {
-  drv_HD_data (currController, string, len, T_EXEC);
+  drv_HD_goto (row, col);
+  drv_HD_data (currController, data, len, T_EXEC);
 }
 
 
@@ -730,7 +736,6 @@ int drv_HD_init (char *section)
   
   // real worker functions
   drv_generic_text_real_write   = drv_HD_write;
-  drv_generic_text_real_goto    = drv_HD_goto;
   drv_generic_text_real_defchar = drv_HD_defchar;
 
 
index 7361855e665682a1a20589feed2743e636907a8b..929e52716883ab018993aea09d3b7b7a887eca31 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_M50530.c,v 1.2 2004/02/15 21:43:43 reinelt Exp $
+/* $Id: drv_M50530.c,v 1.3 2004/03/19 09:17:46 reinelt Exp $
  *
  * new style driver for M50530-based displays
  *
  *
  *
  * $Log: drv_M50530.c,v $
+ * Revision 1.3  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.2  2004/02/15 21:43:43  reinelt
  * T6963 driver nearly finished
  * framework for graphic displays done
@@ -122,31 +127,33 @@ static void drv_M5_command (unsigned int cmd, int delay)
 }
 
 
-static void drv_M5_write (unsigned char *string, int len)
+static void drv_M5_write (int row, int col, unsigned char *data, int len)
 {
   unsigned int cmd;
-
+  unsigned int pos;
+  
+  pos=row*48+col;
+  if (row>3) pos-=168;
+  drv_M5_command (0x300|pos, 20);
+  
   while (len--) {
-    cmd=*string++;
+    cmd=*data++;
     drv_M5_command (0x100|cmd, 20);
   }
 }
 
 
-static void drv_M5_goto (int row, int col)
-{
-  int pos=row*48+col;
-  if (row>3) pos-=168;
-  drv_M5_command (0x300|pos, 20);
-}
-
-
 static void drv_M5_defchar (int ascii, unsigned char *buffer)
 {
+  int i;
+  
   drv_M5_command (0x300+192+8*(ascii-CHAR0), 20);
+
   // Fixme: looks like the M50530 cannot control the bottom line
   // therefore we have only 7 bytes here
-  drv_M5_write (buffer, 7);
+  for (i=0; i<7; i++) {
+    drv_M5_command (0x100|buffer[i], 20);
+  }
 }
 
 
@@ -283,7 +290,6 @@ int drv_M5_init (char *section)
   
   // real worker functions
   drv_generic_text_real_write   = drv_M5_write;
-  drv_generic_text_real_goto    = drv_M5_goto;
   drv_generic_text_real_defchar = drv_M5_defchar;
 
 
index 29e2fd2d2121364f84fc74e402b6459ebae34df4..899b124c519f118dba831ddb396d893e65f4371a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.20 2004/02/14 11:56:17 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.21 2004/03/19 09:17:46 reinelt Exp $
  *
  * new style driver for Matrix Orbital serial display modules
  *
  *
  *
  * $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.21  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.20  2004/02/14 11:56:17  reinelt
  * M50530 driver ported
  * changed lots of 'char' to 'unsigned char'
@@ -187,12 +192,15 @@ static MODEL Models[] = {
 // ***  hardware dependant functions    ***
 // ****************************************
 
-static void drv_MO_goto (int row, int col)
+static void drv_MO_write (int row, int col, unsigned char *data, int len)
 {
   char cmd[5]="\376Gyx";
+
   cmd[2]=(char)col+1;
   cmd[3]=(char)row+1;
   drv_generic_serial_write(cmd,4);
+
+  drv_generic_serial_write (data, len);
 }
 
 
@@ -468,8 +476,7 @@ int drv_MO_init (char *section)
   GOTO_COST=4; // number of bytes a goto command requires
   
   // real worker functions
-  drv_generic_text_real_write   = drv_generic_serial_write;
-  drv_generic_text_real_goto    = drv_MO_goto;
+  drv_generic_text_real_write   = drv_MO_write;
   drv_generic_text_real_defchar = drv_MO_defchar;
 
 
index 25223880262de823aafe38e2ab821dc4e0d93c61..69273afa8218564ab861ad82e9a40a83413a73b2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_USBLCD.c,v 1.1 2004/02/15 08:22:47 reinelt Exp $
+/* $Id: drv_USBLCD.c,v 1.2 2004/03/19 09:17:46 reinelt Exp $
  *
  * new style driver for USBLCD displays
  *
  *
  *
  * $Log: drv_USBLCD.c,v $
+ * Revision 1.2  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.1  2004/02/15 08:22:47  reinelt
  * ported USBLCD driver to NextGeneration
  * added drv_M50530.c (I forgot yesterday, sorry)
@@ -109,28 +114,30 @@ static void drv_UL_command (unsigned char cmd)
 }
 
 
-static void drv_UL_write (unsigned char *string, int len)
+static void drv_UL_write (int row, int col, unsigned char *data, int len)
 {
+  int pos=(row%2)*64+(row/2)*20+col;
+  drv_UL_command (0x80|pos);
+
   while (len--) {
-    if(*string==0) *BufPtr++=*string;
-    *BufPtr++=*string++;
+    if(*data==0) *BufPtr++=*data;
+    *BufPtr++=*data++;
   }
-  drv_UL_send();
-}
 
-
-static void drv_UL_goto (int row, int col)
-{
-  int pos=(row%2)*64+(row/2)*20+col;
-  drv_UL_command (0x80|pos);
+  drv_UL_send();
 }
 
-
 static void drv_UL_defchar (int ascii, unsigned char *buffer)
 {
+  int i;
+  
   drv_UL_command (0x40|8*ascii);
-  drv_UL_write (buffer, 8);
-  // drv_UL_write() will call drv_UL_send(), so don't call it here!
+
+  for (i=0; i<8; i++) {
+    *BufPtr++ = *buffer++;
+  }
+
+  drv_UL_send();
 }
 
 
@@ -283,7 +290,6 @@ int drv_UL_init (char *section)
   
   // real worker functions
   drv_generic_text_real_write   = drv_UL_write;
-  drv_generic_text_real_goto    = drv_UL_goto;
   drv_generic_text_real_defchar = drv_UL_defchar;
 
 
index 3fd5666322628411b7e65acbd8ad20bb75709b11..bb28a89844824f5d49532315f18a891f117dacac 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.c,v 1.12 2004/03/03 03:47:04 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.13 2004/03/19 09:17:46 reinelt Exp $
  *
  * generic driver helper for text-based displays
  *
  *
  *
  * $Log: drv_generic_text.c,v $
+ * Revision 1.13  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.12  2004/03/03 03:47:04  reinelt
  * big patch from Martin Hejl:
  * - use qprintf() where appropriate
@@ -211,7 +216,7 @@ int drv_generic_text_draw (WIDGET *W)
 {
   WIDGET_TEXT *Text=W->data;
   char *txt, *fb1, *fb2;
-  int row, col, len, end;
+  int row, col, col0, len, end;
   
   row=W->row;
   col=W->col;
@@ -232,7 +237,7 @@ int drv_generic_text_draw (WIDGET *W)
     for (; col<=end && col<DCOLS; col++) {
       int pos1, pos2, equal;
       if (fb1[col]==fb2[col]) continue;
-      drv_generic_text_real_goto (row, col);
+      col0 = col;
       for (pos1=col, pos2=pos1, col++, equal=0; col<=end && col<DCOLS; col++) {
        if (fb1[col]==fb2[col]) {
          // If we find just one equal byte, we don't break, because this 
@@ -243,8 +248,8 @@ int drv_generic_text_draw (WIDGET *W)
          equal=0;
        }
       }
-      memcpy                      (fb2+pos1, fb1+pos1, pos2-pos1+1);
-      drv_generic_text_real_write (fb2+pos1,           pos2-pos1+1);
+      memcpy                      (           fb2+pos1, fb1+pos1, pos2-pos1+1);
+      drv_generic_text_real_write (row, col0, fb2+pos1,           pos2-pos1+1);
     }
   }
 
@@ -297,8 +302,7 @@ int drv_generic_text_icon_draw (WIDGET *W)
   // maybe send icon to the display
   if (DisplayFB[row*DCOLS+col]!=ascii) {
     DisplayFB[row*DCOLS+col]=ascii;
-    drv_generic_text_real_goto (row, col);
-    drv_generic_text_real_write (DisplayFB+row*DCOLS+col, 1);
+    drv_generic_text_real_write (row, col, DisplayFB+row*DCOLS+col, 1);
   }
 
   return 0;
@@ -577,7 +581,7 @@ static void drv_generic_text_bar_define_chars(void)
 int drv_generic_text_bar_draw (WIDGET *W)
 {
   WIDGET_BAR *Bar = W->data;
-  int row, col, len, res, max, val1, val2;
+  int row, col, col0, len, res, max, val1, val2;
   int c, n, s;
   DIRECTION dir;
   
@@ -639,7 +643,7 @@ int drv_generic_text_bar_draw (WIDGET *W)
     for (col=0; col<DCOLS; col++) {
       int pos1, pos2, equal;
       if (LayoutFB[row*LCOLS+col]==DisplayFB[row*DCOLS+col]) continue;
-      drv_generic_text_real_goto (row, col);
+      col0 = col;
       for (pos1=col, pos2=pos1, col++, equal=0; col<DCOLS; col++) {
        if (LayoutFB[row*LCOLS+col]==DisplayFB[row*DCOLS+col]) {
          // If we find just one equal byte, we don't break, because this 
@@ -650,8 +654,8 @@ int drv_generic_text_bar_draw (WIDGET *W)
          equal=0;
        }
       }
-      memcpy                      (DisplayFB+row*DCOLS+pos1, LayoutFB+row*LCOLS+pos1, pos2-pos1+1);
-      drv_generic_text_real_write (DisplayFB+row*DCOLS+pos1,                          pos2-pos1+1);
+      memcpy                      (           DisplayFB+row*DCOLS+pos1, LayoutFB+row*LCOLS+pos1, pos2-pos1+1);
+      drv_generic_text_real_write (row, col0, DisplayFB+row*DCOLS+pos1,                          pos2-pos1+1);
     }
   }
   
index 05d7fd503c6018b764a04f1aa3c1155fe72dfe8b..16d143633d780cd7ec6148d5d3c3e18bc763b241 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.h,v 1.7 2004/02/18 06:39:20 reinelt Exp $
+/* $Id: drv_generic_text.h,v 1.8 2004/03/19 09:17:46 reinelt Exp $
  *
  * generic driver helper for text-based displays
  *
  *
  *
  * $Log: drv_generic_text.h,v $
+ * Revision 1.8  2004/03/19 09:17:46  reinelt
+ *
+ * removed the extra 'goto' function, row and col are additional parameters
+ * of the write() function now.
+ *
  * Revision 1.7  2004/02/18 06:39:20  reinelt
  * T6963 driver for graphic displays finished
  *
@@ -76,8 +81,7 @@ extern int CHARS, CHAR0; // number of user-defineable characters, ASCII of first
 extern int ICONS;        // number of user-defineable characters reserved for icons
 
 // these functions must be implemented by the real driver
-void (*drv_generic_text_real_goto)(int row, int col);
-void (*drv_generic_text_real_write)(unsigned char *buffer, int len);
+void (*drv_generic_text_real_write)(int row, int col, unsigned char *data, int len);
 void (*drv_generic_text_real_defchar)(int ascii, unsigned char *buffer);
 
 // generic functions and widget callbacks