annotate light8/parport.c @ 134:f2f73a2171e6

many adjustments to the loops and timing many adjustments to the loops and timing now sends the hardware updates only when clients change, but at least 1Hz new option to adjust the rate of the loop that considers sending changes (if the lights have changed)
author drewp
date Sat, 14 Jun 2003 14:59:09 +0000
parents f0e27aa8f0f5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 #include <stdio.h>
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 #include <stdlib.h>
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 #include <unistd.h>
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 #include <sys/ioctl.h>
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 #include <asm/io.h>
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 #include <fcntl.h>
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 #include <Python.h>
45b12307c695 Initial revision
drewp
parents:
diff changeset
8
115
f0e27aa8f0f5 attempt to make a better exception with getparport(). didn't help, afaict
drewp
parents: 4
diff changeset
9 int getparport() {
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
10 if( ioperm(888,3,1) ) {
45b12307c695 Initial revision
drewp
parents:
diff changeset
11 printf("Couldn't get parallel port at 888-890\n");
45b12307c695 Initial revision
drewp
parents:
diff changeset
12
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 // the following doesn't have any effect!
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 PyErr_SetString(PyExc_IOError,"Couldn't get parallel port at 888-890");
115
f0e27aa8f0f5 attempt to make a better exception with getparport(). didn't help, afaict
drewp
parents: 4
diff changeset
15 return 0;
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 }
115
f0e27aa8f0f5 attempt to make a better exception with getparport(). didn't help, afaict
drewp
parents: 4
diff changeset
17 return 1;
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 }
45b12307c695 Initial revision
drewp
parents:
diff changeset
19
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 void outdata(unsigned char val) {
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 outb(val,888);
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 }
45b12307c695 Initial revision
drewp
parents:
diff changeset
23
45b12307c695 Initial revision
drewp
parents:
diff changeset
24 void outcontrol( unsigned char val ) {
45b12307c695 Initial revision
drewp
parents:
diff changeset
25 outb(val,890);
45b12307c695 Initial revision
drewp
parents:
diff changeset
26 }
45b12307c695 Initial revision
drewp
parents:
diff changeset
27
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 void outbyte( unsigned char val ) {
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 // set data, raise clock, lower clock
45b12307c695 Initial revision
drewp
parents:
diff changeset
30 outdata(val);
45b12307c695 Initial revision
drewp
parents:
diff changeset
31 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
32 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
33 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
34 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
35 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
36 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
37 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
38 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
39 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
40 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
41 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
42 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
43 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
44 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
45 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
46 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
47 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
48 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
49 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
50 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
51 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
52 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
53 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
54 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
55 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
56 outcontrol(2);
45b12307c695 Initial revision
drewp
parents:
diff changeset
57 outcontrol(3);
45b12307c695 Initial revision
drewp
parents:
diff changeset
58 }
45b12307c695 Initial revision
drewp
parents:
diff changeset
59 void outstart() {
45b12307c695 Initial revision
drewp
parents:
diff changeset
60 // send start code: pin 14 high, 5ms to let a dmx cycle finish,
45b12307c695 Initial revision
drewp
parents:
diff changeset
61 // then pin14 low (pin1 stays low)
45b12307c695 Initial revision
drewp
parents:
diff changeset
62 outcontrol(1);
45b12307c695 Initial revision
drewp
parents:
diff changeset
63 usleep(5000);
45b12307c695 Initial revision
drewp
parents:
diff changeset
64 outcontrol(3);
45b12307c695 Initial revision
drewp
parents:
diff changeset
65 }