From 06a6d5eb7dfafc057bf58f4c7dbeba4b11388f60 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 16 Apr 2013 00:40:12 +0200 Subject: digital/io-hub/tools: add cannon UI --- digital/io-hub/tools/io_hub/io_hub.py | 3 +++ digital/io-hub/tools/ui_apbirthday.py | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'digital/io-hub/tools') 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 () -- cgit v1.2.3