Mercurial > code > home > repos > light9
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 |
rev | line source |
---|---|
0 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <unistd.h> | |
4 #include <sys/ioctl.h> | |
5 #include <asm/io.h> | |
6 #include <fcntl.h> | |
7 #include <Python.h> | |
8 | |
115
f0e27aa8f0f5
attempt to make a better exception with getparport(). didn't help, afaict
drewp
parents:
4
diff
changeset
|
9 int getparport() { |
0 | 10 if( ioperm(888,3,1) ) { |
11 printf("Couldn't get parallel port at 888-890\n"); | |
12 | |
13 // the following doesn't have any effect! | |
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 | 16 } |
115
f0e27aa8f0f5
attempt to make a better exception with getparport(). didn't help, afaict
drewp
parents:
4
diff
changeset
|
17 return 1; |
0 | 18 } |
19 | |
20 void outdata(unsigned char val) { | |
21 outb(val,888); | |
22 } | |
23 | |
24 void outcontrol( unsigned char val ) { | |
25 outb(val,890); | |
26 } | |
27 | |
28 void outbyte( unsigned char val ) { | |
29 // set data, raise clock, lower clock | |
30 outdata(val); | |
31 outcontrol(2); | |
32 outcontrol(2); | |
33 outcontrol(2); | |
34 outcontrol(2); | |
35 outcontrol(2); | |
36 outcontrol(2); | |
37 outcontrol(2); | |
38 outcontrol(2); | |
39 outcontrol(2); | |
40 outcontrol(2); | |
41 outcontrol(2); | |
42 outcontrol(2); | |
43 outcontrol(2); | |
44 outcontrol(2); | |
45 outcontrol(2); | |
46 outcontrol(2); | |
47 outcontrol(2); | |
48 outcontrol(2); | |
49 outcontrol(2); | |
50 outcontrol(2); | |
51 outcontrol(2); | |
52 outcontrol(2); | |
53 outcontrol(2); | |
54 outcontrol(2); | |
55 outcontrol(2); | |
56 outcontrol(2); | |
57 outcontrol(3); | |
58 } | |
59 void outstart() { | |
60 // send start code: pin 14 high, 5ms to let a dmx cycle finish, | |
61 // then pin14 low (pin1 stays low) | |
62 outcontrol(1); | |
63 usleep(5000); | |
64 outcontrol(3); | |
65 } |