summaryrefslogtreecommitdiff
path: root/digital/io-hub/tools/io_hub
diff options
context:
space:
mode:
authorNicolas Schodet2012-05-12 02:02:03 +0200
committerNicolas Schodet2012-05-12 11:15:57 +0200
commit382b99e11c033f1952cbe2b9e082cd35812a13e3 (patch)
tree008571474836ee5913085089a0835911239c13cb /digital/io-hub/tools/io_hub
parentfb73dbae0dc7d6b9f117c74bb8de2a073ab4253b (diff)
digital/ui-hub: add debug draw module to debug path finding
Diffstat (limited to 'digital/io-hub/tools/io_hub')
-rw-r--r--digital/io-hub/tools/io_hub/mex.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/digital/io-hub/tools/io_hub/mex.py b/digital/io-hub/tools/io_hub/mex.py
index dd383dbc..989a992c 100644
--- a/digital/io-hub/tools/io_hub/mex.py
+++ b/digital/io-hub/tools/io_hub/mex.py
@@ -224,6 +224,31 @@ class Mex:
self.pos[id] = p
self.notify ()
+ class DebugDraw (Observable):
+ """General purpose debug drawing."""
+
+ def __init__ (self, node, instance):
+ Observable.__init__ (self)
+ self.drawing = [ ]
+ node.register (instance + ':debug-draw', self.__handle)
+
+ def __handle (self, msg):
+ self.drawing = [ ]
+ while len (msg):
+ t, = msg.pop ('c')
+ if t == 'c':
+ x, y, r, c = msg.pop ('hhhb')
+ self.drawing.append (['circle', x, y, r, c])
+ elif t == 's':
+ x1, y1, x2, y2, c = msg.pop ('hhhhb')
+ self.drawing.append (['segment', x1, y1, x2, y2, c])
+ elif t == 'p':
+ x, y, c = msg.pop ('hhb')
+ self.drawing.append (['point', x, y, c])
+ else:
+ raise ValueError
+ self.notify ()
+
def __init__ (self, node, instance = 'io-hub0',
pwm_nb = 0, contact_nb = 0, output_nb = 0, codebar = False):
self.adc = tuple (self.ADC (node, instance, i) for i in range (0, ADC_NB))
@@ -244,4 +269,5 @@ class Mex:
for i in (0, 1))
self.path = self.Path (node, instance)
self.pos_report = self.PosReport (node, instance)
+ self.debug_draw = self.DebugDraw (node, instance)