]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2003-10-12 04:46:19 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 12 Oct 2003 04:46:19 +0000 (04:46 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 12 Oct 2003 04:46:19 +0000 (04:46 +0000)
first try to integrate the Evaluator into a display driver (MatrixOrbital here)
small warning in processor.c fixed (thanks to Zachary Giles)
workaround for udelay() on alpha (no msr.h avaliable) (thanks to Zachary Giles)

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

MatrixOrbital.c
processor.c
udelay.c

index 237320ec6b1df0661e89c9b0caec54e98980f255..218727609aeb7a1adee82804a83c6c193b6b65b4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: MatrixOrbital.c,v 1.45 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: MatrixOrbital.c,v 1.46 2003/10/12 04:46:19 reinelt Exp $
  *
  * driver for Matrix Orbital serial display modules
  *
  *
  *
  * $Log: MatrixOrbital.c,v $
+ * Revision 1.46  2003/10/12 04:46:19  reinelt
+ *
+ *
+ * first try to integrate the Evaluator into a display driver (MatrixOrbital here)
+ * small warning in processor.c fixed (thanks to Zachary Giles)
+ * workaround for udelay() on alpha (no msr.h avaliable) (thanks to Zachary Giles)
+ *
  * Revision 1.45  2003/10/05 17:58:50  reinelt
  * libtool junk; copyright messages cleaned up
  *
 
 #include "debug.h"
 #include "cfg.h"
+#include "client.h"
 #include "lock.h"
 #include "display.h"
 #include "bar.h"
@@ -403,6 +411,89 @@ int MO_clear2 (int full)
 }
 
 
+static void client_contrast (RESULT *result, RESULT *arg1)
+{
+  char buffer[4];
+  double contrast;
+
+  contrast=R2N(arg1);
+  if (contrast<0  ) contrast=0;
+  if (contrast>255) contrast=255;
+  snprintf (buffer, 4, "\376P%c", (int)contrast);
+  MO_write (buffer, 3);
+  
+  SetResult(&result, R_NUMBER, &contrast); 
+}
+
+
+static void client_backlight (RESULT *result, RESULT *arg1)
+{
+  char buffer[4];
+  double backlight;
+
+  backlight=R2N(arg1);
+  if (backlight<-1  ) backlight=-1;
+  if (backlight>255) backlight=255;
+  if (backlight<0) {
+    // backlight off
+    snprintf (buffer, 3, "\376F");
+    MO_write (buffer, 2);
+  } else {
+    // backlight on for n minutes
+    snprintf (buffer, 4, "\376B%c", (int)backlight);
+    MO_write (buffer, 3);
+  }
+  SetResult(&result, R_NUMBER, &backlight); 
+}
+
+
+static void client_gpo (RESULT *result, RESULT *arg1, RESULT *arg2)
+{
+  int num;
+  double val;
+  char cmd[3]="\376";
+  // Fixme
+  int protocol=2;
+  
+  num=R2N(arg1);
+  val=R2N(arg2);
+  
+  if (num<0.0) num=0.0;
+  if (val<0.0) val=0.0;
+  
+  switch (protocol) {
+  case 1:
+    if (num==0) {
+      if (val>=1.0) {
+       val=1.0;
+       MO_write ("\376W", 2);  // GPO on
+      } else {
+       val=0.0;
+       MO_write ("\376V", 2);  // GPO off
+      }
+    } else {
+      error("Fixme");
+      val=-1.0;
+    }
+    break;
+    
+  case 2:
+    if (val>=1.0) {
+      val=1.0;
+      cmd[1]='W';  // GPO on
+    } else {
+      val=0.0;
+      cmd[1]='V';  // GPO off
+    }
+    cmd[2]=(char)num;
+    MO_write (cmd, 3);
+    break;
+  }
+
+  SetResult(&result, R_NUMBER, &val); 
+}
+
+
 static int MO_init (LCD *Self, int protocol)
 {
   int i;  
@@ -498,6 +589,11 @@ static int MO_init (LCD *Self, int protocol)
   MO_write ("\376D", 2);  // line wrapping off
   MO_write ("\376R", 2);  // auto scroll off
 
+  // register as a client
+  AddFunction ("contrast",  1, client_contrast);
+  AddFunction ("backlight", 1, client_backlight);
+  AddFunction ("gpo",       2, client_gpo);
+
   return 0;
 }
 
@@ -565,7 +661,7 @@ static int MO_flush (int protocol)
   int row, col, pos1, pos2;
   int c, equal;
   int gpo;
-
+  
   bar_process(MO_define_char);
   
   for (row=0; row<Lcd.rows; row++) {
@@ -594,7 +690,7 @@ static int MO_flush (int protocol)
   }
   
   memcpy (FrameBuffer2, FrameBuffer1, Lcd.rows*Lcd.cols*sizeof(char));
-
+  
   switch (protocol) {
   case 1:
     if (GPO[0]) {
@@ -612,7 +708,7 @@ static int MO_flush (int protocol)
     }
     break;
   }
-
+  
   return 0;
 }
 
@@ -639,12 +735,12 @@ int MO_quit (void)
     free(FrameBuffer1);
     FrameBuffer1=NULL;
   }
-
+  
   if (FrameBuffer2) {
     free(FrameBuffer2);
     FrameBuffer2=NULL;
   }
-
+  
   return (0);
 }
 
index b426e6c5d7ac6a1aa0095bbb475af9cc5cd3d748..788d900b018d9bbcc1fa49f8153722a828e710f8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: processor.c,v 1.47 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: processor.c,v 1.48 2003/10/12 04:46:19 reinelt Exp $
  *
  * main data processing
  *
  *
  *
  * $Log: processor.c,v $
+ * Revision 1.48  2003/10/12 04:46:19  reinelt
+ *
+ *
+ * first try to integrate the Evaluator into a display driver (MatrixOrbital here)
+ * small warning in processor.c fixed (thanks to Zachary Giles)
+ * workaround for udelay() on alpha (no msr.h avaliable) (thanks to Zachary Giles)
+ *
  * Revision 1.47  2003/10/05 17:58:50  reinelt
  * libtool junk; copyright messages cleaned up
  *
@@ -584,7 +591,7 @@ static void print_token (int token, char **p, char *start)
 
   case T_EXEC:
     i = (token>>8)-'0';
-    *p+=sprintf (*p, "%.*s",cols-(*p-start), exec[i].s);
+    *p+=sprintf (*p, "%.*s",cols-(int)(*p-start), exec[i].s);
     break;
     
   default:
index 8f5fe2891e8f34040aab4fc85fd44d73b22bc994..d728039f8375d0764a8254c06a00e5895b575c20 100644 (file)
--- a/udelay.c
+++ b/udelay.c
@@ -1,4 +1,4 @@
-/* $Id: udelay.c,v 1.13 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: udelay.c,v 1.14 2003/10/12 04:46:19 reinelt Exp $
  *
  * short delays
  *
  *
  *
  * $Log: udelay.c,v $
+ * Revision 1.14  2003/10/12 04:46:19  reinelt
+ *
+ *
+ * first try to integrate the Evaluator into a display driver (MatrixOrbital here)
+ * small warning in processor.c fixed (thanks to Zachary Giles)
+ * workaround for udelay() on alpha (no msr.h avaliable) (thanks to Zachary Giles)
+ *
  * Revision 1.13  2003/10/05 17:58:50  reinelt
  * libtool junk; copyright messages cleaned up
  *
 
 #ifdef HAVE_ASM_MSR_H
 #include <asm/msr.h>
-#else
-#warning asm/msr.h not found.
-#warning using hard-coded definition.
-#define rdtscl(low) \
-     __asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
 #endif
+
 #endif
 
 
@@ -231,15 +234,21 @@ static void getCPUinfo (int *hasTSC, double *MHz)
 
 void udelay_init (void)
 {
+#ifdef HAVE_ASM_MSR_H
+  
   int tsc;
   double mhz;
-  
+
   getCPUinfo (&tsc, &mhz);
   
   if (tsc && mhz>0.0) {
     ticks_per_usec=ceil(mhz);
     debug ("using TSC delay loop, %u ticks per microsecond", ticks_per_usec);
-  } else {
+  } else
+
+#endif
+
+ {
     ticks_per_usec=0;
     debug ("using gettimeofday() delay loop");
   }
@@ -249,6 +258,8 @@ void udelay_init (void)
 void ndelay (unsigned long nsec)
 {
 
+#ifdef HAVE_ASM_MSR_H
+
   if (ticks_per_usec) {
 
     unsigned int t1, t2;
@@ -261,8 +272,11 @@ void ndelay (unsigned long nsec)
       rdtscl(t2);
     } while ((t2-t1)<nsec);
     
-  } else {
-    
+  } else
+
+#endif
+
+ {    
     struct timeval now, end;
     
     gettimeofday (&end, NULL);