diff options
author | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-14 15:31:04 +0200 |
---|---|---|
committer | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-14 15:31:04 +0200 |
commit | 7e32d6a1829b99eac6e0150dd4a80062801d6ffe (patch) | |
tree | 0371cb853fa198f5fc1fb2ad1dfbe654fc0bf380 /ParrotZik.py | |
parent | ac763c2f9e34cdb8e8cc24f96941459f3944011c (diff) | |
download | pyParrotZikTCP-7e32d6a1829b99eac6e0150dd4a80062801d6ffe.tar.xz pyParrotZikTCP-7e32d6a1829b99eac6e0150dd4a80062801d6ffe.zip |
Add reading noise_control.
Diffstat (limited to 'ParrotZik.py')
-rw-r--r-- | ParrotZik.py | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/ParrotZik.py b/ParrotZik.py index a79f410..1240d66 100644 --- a/ParrotZik.py +++ b/ParrotZik.py @@ -123,6 +123,28 @@ class Rooms: SILENT_ROOM: 'Silent Room', } +class NoiseControl(object): + def __init__(self, type, value): + self.type = type + self.value = value + + @classmethod + def from_noise_control(cls, noise_control): + return cls(noise_control['type'], int(noise_control['value'])) + + def __eq__(self, other): + return self.type == other.type and self.value == other.value + + def __str__(self): + return '{}++{}'.format(self.type, self.value) + +class NoiseControlTypes: + NOISE_CONTROL_MAX = NoiseControl('anc', 2) + NOISE_CONTROL_ON = NoiseControl('anc', 1) + NOISE_CONTROL_OFF = NoiseControl('off', 1) + STREET_MODE = NoiseControl('aoc', 1) + STREET_MODE_MAX = NoiseControl('aoc', 2) + class ParrotZikBase(object): def __init__(self, api): @@ -162,16 +184,6 @@ class ParrotZikBase(object): return self._result_to_bool( data.answer.system.anc_phone_mode["enabled"]) - @property - def cancel_noise(self): - data = self.api.get("/api/audio/noise_cancellation/enabled") - return self._result_to_bool( - data.answer.audio.noise_cancellation["enabled"]) - - @cancel_noise.setter - def cancel_noise(self, arg): - self.api.set("/api/audio/noise_cancellation/enabled", arg) - def _result_to_bool(self, result): if result == "true": return True @@ -206,6 +218,16 @@ class ParrotZikVersion1(ParrotZikBase): def concert_hall(self, arg): self.api.get("/api/audio/sound_effect/enabled", arg) + @property + def cancel_noise(self): + data = self.api.get("/api/audio/noise_cancellation/enabled") + return self._result_to_bool( + data.answer.audio.noise_cancellation["enabled"]) + + @cancel_noise.setter + def cancel_noise(self, arg): + self.api.set("/api/audio/noise_cancellation/enabled", arg) + class ParrotZikVersion2(ParrotZikBase): @property @@ -264,11 +286,11 @@ class ParrotZikVersion2(ParrotZikBase): @property def noise_control(self): data = self.api.get('/api/audio/noise_control') - return self._result_to_bool(data.answer.audio.noise_control['value']) + return NoiseControl.from_noise_control(data.answer.audio.noise_control) @noise_control.setter def noise_control(self, arg): - self.api.set('/api/audio/noise_control', arg) + pass @property def noise_control_enabled(self): |