summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Schodet2013-04-16 00:40:12 +0200
committerNicolas Schodet2013-04-16 00:40:55 +0200
commit06a6d5eb7dfafc057bf58f4c7dbeba4b11388f60 (patch)
tree6dea5445fe3a69a2e9c941b75569cbb443e5cf9b
parentfe3a6c40aa7ccb7ea9d2ff0594252575b1bcddb8 (diff)
digital/io-hub/tools: add cannon UI
-rw-r--r--digital/io-hub/tools/io_hub/io_hub.py3
-rw-r--r--digital/io-hub/tools/ui_apbirthday.py24
2 files changed, 26 insertions, 1 deletions
diff --git a/digital/io-hub/tools/io_hub/io_hub.py b/digital/io-hub/tools/io_hub/io_hub.py
index bbd8952b..cd954648 100644
--- a/digital/io-hub/tools/io_hub/io_hub.py
+++ b/digital/io-hub/tools/io_hub/io_hub.py
@@ -64,6 +64,9 @@ class Proto:
def pressure (self, val):
self.proto.send ('f', 'H', val)
+ def potentiometer (self, index, val, eeprom = False):
+ self.proto.send ('p', 'BHB', index, val, eeprom)
+
def close (self):
self.reset ()
self.proto.wait (lambda: True)
diff --git a/digital/io-hub/tools/ui_apbirthday.py b/digital/io-hub/tools/ui_apbirthday.py
index bbca9d6b..aeff3059 100644
--- a/digital/io-hub/tools/ui_apbirthday.py
+++ b/digital/io-hub/tools/ui_apbirthday.py
@@ -113,8 +113,28 @@ class InterAPBirthday (Frame):
def pressure_set ():
val = pressure_scale.get ()
self.io.pressure (val)
- button = Button (frame, text = 'Set', command = pressure_set)
+ button = Button (frame, text = 'Set', command = pressure_set,
+ padx = 0, pady = 0)
button.pack ()
+ # Cannon.
+ frame = LabelFrame (misc_frame, text = 'Cannon')
+ frame.pack ()
+ cannon_speed_scale = Scale (frame, from_ = 256, to = 0,
+ orient = HORIZONTAL)
+ cannon_speed_scale.pack ()
+ frame = Frame (frame)
+ frame.pack ()
+ def cannon_speed_set ():
+ self.io.potentiometer (1, cannon_speed_scale.get ())
+ button = Button (frame, text = 'Set', command = cannon_speed_set,
+ padx = 0, pady = 0)
+ button.pack (side = LEFT)
+ def cannon_fire ():
+ self.io.potentiometer (0, (0, 256)[self.cannon_fire_var.get ()])
+ self.cannon_fire_var = IntVar ()
+ button = Checkbutton (frame, indicatoron = 0, text = 'Fire!',
+ command = cannon_fire, variable = self.cannon_fire_var)
+ button.pack (side = LEFT)
def reset (self):
mask = 0
@@ -123,6 +143,8 @@ class InterAPBirthday (Frame):
mask |= 1 << i
self.io.output (mask, 'clear')
self.io.pressure (0)
+ self.cannon_fire_var.set (0)
+ self.io.potentiometer (0, 0)
if __name__ == '__main__':
app = InterAPBirthday ()