1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
from parrot_zik.model.base import ParrotZikBase
from parrot_zik.resource_manager import Version2ResourceManager
class ParrotZikVersion2(ParrotZikBase):
def __init__(self, resource_manager):
super(ParrotZikVersion2, self).__init__(
resource_manager.get_resource_manager(
Version2ResourceManager))
@property
def version(self):
answer = self.resource_manager.get('/api/software/version')
return answer.software['sip6']
@property
def battery_level(self):
return self.get_battery_level('percent')
@property
def flight_mode(self):
answer = self.resource_manager.get('/api/flight_mode')
return self._result_to_bool(answer.flight_mode['enabled'])
@flight_mode.setter
def flight_mode(self, arg):
if arg:
self.resource_manager.toggle_on('/api/flight_mode')
else:
self.resource_manager.toggle_off('/api/flight_mode')
@property
def sound_effect(self):
answer = self.resource_manager.get('/api/audio/sound_effect/enabled')
return self._result_to_bool(answer.audio.sound_effect['enabled'])
@sound_effect.setter
def sound_effect(self, arg):
self.resource_manager.set('/api/audio/sound_effect/enabled', arg)
@property
def room(self):
answer = self.resource_manager.get('/api/audio/sound_effect/room_size')
return answer.audio.sound_effect['room_size']
@room.setter
def room(self, arg):
self.resource_manager.set('/api/audio/sound_effect/room_size', arg)
@property
def external_noise(self):
answer = self.resource_manager.get('/api/audio/noise')
return int(answer.audio.noise['external'])
@property
def internal_noise(self):
answer = self.resource_manager.get('/api/audio/noise')
return int(answer.audio.noise['internal'])
@property
def angle(self):
answer = self.resource_manager.get('/api/audio/sound_effect/angle')
return int(answer.audio.sound_effect['angle'])
@angle.setter
def angle(self, arg):
self.resource_manager.set('/api/audio/sound_effect/angle', arg)
@property
def noise_control(self):
answer = self.resource_manager.get('/api/audio/noise_control')
return NoiseControl.from_noise_control(answer.audio.noise_control)
@noise_control.setter
def noise_control(self, arg):
self.resource_manager.set('/api/audio/noise_control', arg)
@property
def noise_control_enabled(self):
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):
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 '{}&value={}'.format(self.type, self.value)
class NoiseControlTypes:
representation = {
'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 Rooms:
representation = [
'concert',
'jazz',
'living',
'silent',
]
class Angles:
representation = [30, 60, 90, 120, 150, 180]
class SoundSource:
LINE_IN = 'line-in'
A2DP = 'a2dp'
|