4
4
5
5
from aioconsole import ainput
6
6
from mavsdk import System
7
- from mavsdk .camera import ( CameraError , Mode , Option , Setting )
7
+ from mavsdk .camera import CameraError , Mode , Option , Setting
8
8
9
9
10
10
usage_str = """
@@ -31,10 +31,10 @@ async def run():
31
31
while True :
32
32
entered_input = await ainput (usage_str )
33
33
34
- if ( entered_input == "p" ) :
34
+ if entered_input == "p" :
35
35
print (f"\n === Current settings ===\n " )
36
36
print_current_settings ()
37
- elif ( entered_input == "m" ) :
37
+ elif entered_input == "m" :
38
38
print (f"\n === Possible modes ===\n " )
39
39
print (f"1. PHOTO" )
40
40
print (f"2. VIDEO" )
@@ -45,7 +45,7 @@ async def run():
45
45
print ("Invalid index" )
46
46
continue
47
47
48
- if ( index_mode == 1 ) :
48
+ if index_mode == 1 :
49
49
chosen_mode = Mode .PHOTO
50
50
else :
51
51
chosen_mode = Mode .VIDEO
@@ -57,13 +57,12 @@ async def run():
57
57
print (f" --> Succeeded" )
58
58
except CameraError as error :
59
59
print (f" --> Failed with code: { error ._result .result_str } " )
60
- elif ( entered_input == "s" ) :
60
+ elif entered_input == "s" :
61
61
print (f"\n === Possible settings ===\n " )
62
62
print_possible_settings (possible_setting_options )
63
63
64
64
try :
65
- index_setting = await \
66
- make_user_choose_setting (possible_setting_options )
65
+ index_setting = await make_user_choose_setting (possible_setting_options )
67
66
except ValueError :
68
67
print ("Invalid index" )
69
68
continue
@@ -73,36 +72,39 @@ async def run():
73
72
74
73
print (f"\n === Available options ===" )
75
74
print (f"Setting: { selected_setting .setting_id } " )
76
- if ( not selected_setting .is_range ) :
75
+ if not selected_setting .is_range :
77
76
print (f"Options:" )
78
77
try :
79
78
print_possible_options (possible_options )
80
- index_option = await \
81
- make_user_choose_option (possible_options )
79
+ index_option = await make_user_choose_option (possible_options )
82
80
selected_option = possible_options [index_option - 1 ]
83
81
84
- print (f"Setting { selected_setting .setting_id } "
85
- f"to { selected_option .option_description } !" )
82
+ print (
83
+ f"Setting { selected_setting .setting_id } "
84
+ f"to { selected_option .option_description } !"
85
+ )
86
86
setting = Setting (
87
- selected_setting .setting_id ,
88
- "" ,
89
- selected_option ,
90
- selected_setting .is_range )
87
+ selected_setting .setting_id ,
88
+ "" ,
89
+ selected_option ,
90
+ selected_setting .is_range ,
91
+ )
91
92
except ValueError :
92
93
print ("Invalid index" )
93
94
continue
94
95
else :
95
96
try :
96
- selected_value = await \
97
- make_user_choose_option_range (possible_options )
97
+ selected_value = await make_user_choose_option_range (
98
+ possible_options
99
+ )
98
100
99
- print (f"Setting { selected_setting .setting_id } "
100
- f" to { selected_value } !" )
101
+ print (f"Setting { selected_setting .setting_id } to { selected_value } !" )
101
102
setting = Setting (
102
- selected_setting .setting_id ,
103
- "" ,
104
- Option (selected_value , "" ),
105
- selected_setting .is_range )
103
+ selected_setting .setting_id ,
104
+ "" ,
105
+ Option (selected_value , "" ),
106
+ selected_setting .is_range ,
107
+ )
106
108
except ValueError :
107
109
print ("Invalid value" )
108
110
continue
@@ -148,7 +150,7 @@ def print_current_settings():
148
150
async def make_user_choose_camera_mode ():
149
151
index_mode_str = await ainput (f"\n Which mode do you want? [1..2] >>> " )
150
152
index_mode = int (index_mode_str )
151
- if ( index_mode < 1 or index_mode > 2 ) :
153
+ if index_mode < 1 or index_mode > 2 :
152
154
raise ValueError ()
153
155
154
156
return index_mode
@@ -163,12 +165,12 @@ def print_possible_settings(possible_settings):
163
165
164
166
async def make_user_choose_setting (possible_settings ):
165
167
n_settings = len (possible_settings )
166
- index_setting_str = await \
167
- ainput ( f"\n Which setting do you want to change?"
168
- f" [1.. { n_settings } ] >>> " )
168
+ index_setting_str = await ainput (
169
+ f"\n Which setting do you want to change? [1.. { n_settings } ] >>> "
170
+ )
169
171
170
172
index_setting = int (index_setting_str )
171
- if ( index_setting < 1 or index_setting > n_settings ) :
173
+ if index_setting < 1 or index_setting > n_settings :
172
174
raise ValueError ()
173
175
174
176
return index_setting
@@ -183,11 +185,12 @@ def print_possible_options(possible_options):
183
185
184
186
async def make_user_choose_option (possible_options ):
185
187
n_options = len (possible_options )
186
- index_option_str = await \
187
- ainput (f"\n Which option do you want? [1..{ n_options } ] >>> " )
188
+ index_option_str = await ainput (
189
+ f"\n Which option do you want? [1..{ n_options } ] >>> "
190
+ )
188
191
189
192
index_option = int (index_option_str )
190
- if ( index_option < 1 or index_option > n_options ) :
193
+ if index_option < 1 or index_option > n_options :
191
194
raise ValueError ()
192
195
193
196
return index_option
@@ -202,12 +205,12 @@ async def make_user_choose_option_range(possible_options):
202
205
interval_value = float (possible_options [2 ].option_id )
203
206
interval_text = f"interval: { interval_value } "
204
207
205
- value_str = await \
206
- ainput ( f"\n What value do you want?"
207
- f" [ { min_value } , { max_value } ] { interval_text } >>> " )
208
+ value_str = await ainput (
209
+ f"\n What value do you want? [ { min_value } , { max_value } ] { interval_text } >>> "
210
+ )
208
211
209
212
value = float (value_str )
210
- if ( value < min_value or value > max_value ) :
213
+ if value < min_value or value > max_value :
211
214
raise ValueError ()
212
215
213
216
return str (value )
0 commit comments