Permalink
Browse files

Added an arduino sketch (part of documentation on how to make an adap…

…ter cable)
  • Loading branch information...
1 parent 1b087e3 commit 45a8204b765a4379ebe16de3801b93a9ade41d1b @stg committed Jul 5, 2012
Showing with 23 additions and 1 deletion.
  1. +22 −0 arduino_cable_sketch/arduino_cable_sketch.ino
  2. +1 −1 gui/picture.c
@@ -0,0 +1,22 @@
+#define pinPort( P ) ( ( P ) <= 7 ? &PORTD : ( ( P ) <= 13 ? &PORTB : &PORTC ) )
+#define pinBit( P ) ( ( P ) <= 7 ? ( P ) : ( ( P ) <= 13 ? ( P ) - 8 : ( P ) - 14 ) )
+#define fastWrite( P, V ) bitWrite( *pinPort( P ), pinBit( P ), ( V ) )
+#define fastRead( P ) bitRead( *pinPort( P ), pinBit( P ) )
+
+void setup() {
+ pinMode(0, INPUT);
+ pinMode(1, OUTPUT);
+ pinMode(2, INPUT);
+ pinMode(3, OUTPUT);
+}
+
+void loop() {
+ // disable interrupts - reduces jitter
+ cli();
+ while(1) {
+ // copy+invert data between pc usb port (0&1)
+ // and machine "virtual" serial port (2&3)
+ fastWrite(3,!fastRead(0));
+ fastWrite(2,!fastRead(1));
+ }
+}
View
@@ -19,7 +19,7 @@
#define MIN3(x,y,z) ((y) <= (z) ? ((x) <= (y) ? (x) : (y)) : ((x) <= (z) ? (x) : (z)))
#define MAX3(x,y,z) ((y) >= (z) ? ((x) >= (y) ? (x) : (y)) : ((x) >= (z) ? (x) : (z)))
-// byte order access fixes bug in FreeImage
+// byte order access fixes color ordering problem in FreeImage
#define RED(q) ((q)->rgbBlue)
#define GREEN(q) ((q)->rgbGreen)
#define BLUE(q) ((q)->rgbRed)

0 comments on commit 45a8204

Please sign in to comment.