1
- #!/usr/bin/env python
2
- '''RC min/max setup'''
1
+ '''
2
+ RC min/max setup
3
+
4
+ AP_FLAKE8_CLEAN
5
+ '''
3
6
4
7
from MAVProxy .modules .lib import mp_module
5
8
9
+
6
10
class RCSetupModule (mp_module .MPModule ):
7
11
def __init__ (self , mpstate ):
8
12
super (RCSetupModule , self ).__init__ (mpstate , "rcsetup" )
@@ -17,15 +21,15 @@ def __init__(self, mpstate):
17
21
def clear_rc_cal (self ):
18
22
self .rc_cal = []
19
23
self .rc_cal .append ("" ) # 0 will be empty
20
- for i in range (1 ,self .num_channels + 1 ):
21
- #min, max, modified
24
+ for i in range (1 , self .num_channels + 1 ):
25
+ # min, max, modified
22
26
self .rc_cal .append ([1500 , 1500 , False ])
23
27
24
28
def apply_rc_cal (self ):
25
29
for i in range (1 , len (self .rc_cal )):
26
- #only apply calibration changes to channels that
27
- #were modified during calibration
28
- if ( self .rc_cal [i ][2 ] == False ) :
30
+ # only apply calibration changes to channels that
31
+ # were modified during calibration
32
+ if self .rc_cal [i ][2 ] is False :
29
33
continue
30
34
31
35
self .param_set ('RC%u_MIN' % i , self .rc_cal [i ][0 ], 5 )
@@ -80,41 +84,40 @@ def idle_task(self):
80
84
81
85
def cmd_rctrim (self , args ):
82
86
'''set RCx_TRIM'''
83
- if not 'RC_CHANNELS' in self .status .msgs :
87
+ if 'RC_CHANNELS' not in self .status .msgs :
84
88
print ("No RC_CHANNELS to trim with" )
85
89
return
86
90
m = self .status .msgs ['RC_CHANNELS' ]
87
- for ch in range (1 ,5 ):
91
+ for ch in range (1 , 5 ):
88
92
self .param_set ('RC%u_TRIM' % ch , getattr (m , 'chan%u_raw' % ch ))
89
93
90
-
91
94
def unload (self ):
92
95
if 'rcreset' in self .mpstate .command_map :
93
96
self .mpstate .command_map .pop ('rcreset' )
94
97
if 'rctrim' in self .mpstate .command_map :
95
98
self .mpstate .command_map .pop ('rctrim' )
96
99
97
-
98
100
def mavlink_packet (self , m ):
99
101
'''handle an incoming mavlink packet'''
100
- #do nothing if not caibrating
101
- if ( self .calibrating == False ) :
102
+ # do nothing if not caibrating
103
+ if self .calibrating is False :
102
104
return
103
105
104
106
if m .get_type () == 'RC_CHANNELS' :
105
- for i in range (1 ,self .num_channels + 1 ):
107
+ for i in range (1 , self .num_channels + 1 ):
106
108
v = getattr (m , 'chan%u_raw' % i )
107
109
108
110
if self .get_cal_min (i ) > v :
109
- self .set_cal_min (i ,v )
111
+ self .set_cal_min (i , v )
110
112
self .console .writeln ("Calibrating: RC%u_MIN=%u" % (i , v ))
111
113
if self .get_cal_max (i ) < v :
112
- self .set_cal_max (i ,v )
114
+ self .set_cal_max (i , v )
113
115
self .console .writeln ("Calibrating: RC%u_MAX=%u" % (i , v ))
114
116
115
117
def print_cal_usage (self ):
116
118
print ("Usage rccal <start|done>" )
117
119
120
+
118
121
def init (mpstate ):
119
122
'''initialise module'''
120
123
return RCSetupModule (mpstate )
0 commit comments