All pastes #1482764 Raw Edit

arduino.py diff

public python v1 · immutable
#1482764 ·published 2009-07-03 06:54 UTC
rendered paste body
Index: project/reprap/arduino_emc-hal/arduino.py===================================================================--- a/project/reprap/arduino_emc-hal/arduino.py+++ b/project/reprap/arduino_emc-hal/arduino.py@@ -20,4 +20,10 @@ import sys import time++try:+        import psyco+        psyco.full()+except ImportError:+        pass  def encode(addr, data):@@ -74,14 +80,14 @@                 v = (firstbyte << 7) | byte                 port = (v >> 11) & 7+                if port in range (6):+                    if port > nout:+                        b = v & 1024+                        c['digital-in-%02d' % pinmap[port]] = b != 0+                        c['digital-in-%02d-not' % pinmap[port]] = b == 0 -                if port >= nout:-                    b = v & 1024-                    c['digital-in-%02d' % pinmap[port]] = b != 0-                    c['digital-in-%02d-not' % pinmap[port]] = b == 0--                gain = c['analog-in-%02d-gain' % port] or 1.-                offset = c['analog-in-%02d-offset' % port]-                value = (v & 1023) / 1023. * 5.0 * gain + offset-                c['analog-in-%02d' % port] = value+                    gain = c['analog-in-%02d-gain' % port] or 1.+                    offset = c['analog-in-%02d-offset' % port]+                    value = (v & 1023) / 1023. * 5.0 * gain + offset+                    c['analog-in-%02d' % port] = value              firstbyte = byte