diff options
author | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-15 14:56:52 +0200 |
---|---|---|
committer | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-15 14:56:52 +0200 |
commit | 4573f9f3e95a0d79c576e3fe0f34023bbf6f0898 (patch) | |
tree | fc5f92391862fd08befb0d5488e1e9bb5ac5f652 | |
parent | 3d06315f862150a978ba3c8a7a5a3b1672b6e89d (diff) | |
download | pyParrotZikTCP-4573f9f3e95a0d79c576e3fe0f34023bbf6f0898.tar.xz pyParrotZikTCP-4573f9f3e95a0d79c576e3fe0f34023bbf6f0898.zip |
Implement head detection setting.
-rw-r--r-- | parrot_zik/interface/version2.py | 17 | ||||
-rw-r--r-- | parrot_zik/model/version2.py | 9 |
2 files changed, 26 insertions, 0 deletions
diff --git a/parrot_zik/interface/version2.py b/parrot_zik/interface/version2.py index ff21004..c348bb4 100644 --- a/parrot_zik/interface/version2.py +++ b/parrot_zik/interface/version2.py @@ -98,14 +98,23 @@ class ParrotZikVersion2Interface(ParrotZikBaseInterface): self.flight_mode = MenuItem("Flight Mode", self.toggle_flight_mode, checkitem=True, visible=False) + self.settings = MenuItem("Settings", None, visible=False) + self.settings_submenu = Menu() + self.settings.set_submenu(self.settings_submenu) + + self.head_detection = MenuItem("Head Detection", self.toggle_head_detection, checkitem=True) + self.settings_submenu.append(self.head_detection) + self.indicator.menu.append(self.room_sound_effect) self.indicator.menu.append(self.noise_cancelation) self.indicator.menu.append(self.flight_mode) + self.indicator.menu.append(self.settings) def activate(self, manager): self.noise_cancelation.show() self.flight_mode.show() self.room_sound_effect.show() + self.settings.show() super(ParrotZikVersion2Interface, self).activate(manager) self._read_noise_cancelation() self.flight_mode.set_active(self.parrot.flight_mode) @@ -130,6 +139,7 @@ class ParrotZikVersion2Interface(ParrotZikBaseInterface): self.noise_cancelation.hide() self.flight_mode.hide() self.room_sound_effect.hide() + self.settings.hide() super(ParrotZikVersion2Interface, self).deactivate() def toggle_flight_mode(self, widget): @@ -222,3 +232,10 @@ class ParrotZikVersion2Interface(ParrotZikBaseInterface): ) for noise_control, menu_item in noise_control_to_menuitem_map: menu_item.set_active(active_noise_control == noise_control) + + def toggle_head_detection(self, widget): + try: + self.parrot.head_detection = self.head_detection.get_active() + self.head_detection.set_active(self.parrot.head_detection) + except resource_manager.DeviceDisconnected: + self.deactivate()
\ No newline at end of file diff --git a/parrot_zik/model/version2.py b/parrot_zik/model/version2.py index 9ef6267..e0bce44 100644 --- a/parrot_zik/model/version2.py +++ b/parrot_zik/model/version2.py @@ -80,6 +80,15 @@ class ParrotZikVersion2(ParrotZikBase): answer = self.resource_manager.get('/api/audio/noise_control/enabled') return self._result_to_bool(answer.audio.noise_control['enabled']) + @property + def head_detection(self): + answer = self.resource_manager.get('/api/system/head_detection/enabled') + return self._result_to_bool(answer.system.head_detection['enabled']) + + @head_detection.setter + def head_detection(self, arg): + self.resource_manager.set('/api/system/head_detection/enabled', arg) + class NoiseControl(object): def __init__(self, type, value): |