summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/tools
diff options
context:
space:
mode:
Diffstat (limited to 'digital/io-hub/tools')
-rw-r--r--digital/io-hub/tools/io_hub/mex.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/digital/io-hub/tools/io_hub/mex.py b/digital/io-hub/tools/io_hub/mex.py
index 22e9e900..44c41010 100644
--- a/digital/io-hub/tools/io_hub/mex.py
+++ b/digital/io-hub/tools/io_hub/mex.py
@@ -121,6 +121,27 @@ class Mex:
m.push ('L', self.contacts)
self.node.send (m)
+ class PosReport (Observable):
+ """General purpose position report.
+
+ - pos: dict of sequence of (x, y) coordinates (millimeters). The dict
+ is indexed by position identifier.
+
+ """
+
+ def __init__ (self, node, instance):
+ Observable.__init__ (self)
+ self.pos = { }
+ node.register (instance + ':pos-report', self.__handle)
+
+ def __handle (self, msg):
+ p = [ ]
+ id, = msg.pop ('b')
+ while len (msg) >= 4:
+ p.append (msg.pop ('hh'))
+ self.pos[id] = p
+ self.notify ()
+
def __init__ (self, node, instance = 'io-hub0'):
self.adc = tuple (self.ADC (node, instance, i) for i in range (0, ADC_NB))
self.pwm = tuple (self.PWM () for i in range (0, PWM_NB))
@@ -128,4 +149,5 @@ class Mex:
self.__contact_pack = self.Contact.Pack (node, instance)
self.contact = tuple (self.Contact (self.__contact_pack, i)
for i in range (CONTACT_NB))
+ self.pos_report = self.PosReport (node, instance)