aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--MatrixOrbital.c108
-rw-r--r--processor.c11
-rw-r--r--udelay.c34
3 files changed, 135 insertions, 18 deletions
diff --git a/MatrixOrbital.c b/MatrixOrbital.c
index 237320e..2187276 100644
--- a/MatrixOrbital.c
+++ b/MatrixOrbital.c
@@ -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
*
@@ -22,6 +22,13 @@
*
*
* $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
*
@@ -214,6 +221,7 @@
#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);
}
diff --git a/processor.c b/processor.c
index b426e6c..788d900 100644
--- a/processor.c
+++ b/processor.c
@@ -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
*
@@ -22,6 +22,13 @@
*
*
* $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:
diff --git a/udelay.c b/udelay.c
index 8f5fe28..d728039 100644
--- 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
*
@@ -22,6 +22,13 @@
*
*
* $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
*
@@ -120,12 +127,8 @@
#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);