Skip to content

Commit 5a37a23

Browse files
committed
modules: rcsetup: flake8 compliance
1 parent b7d20f7 commit 5a37a23

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

Diff for: MAVProxy/modules/mavproxy_rcsetup.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
#!/usr/bin/env python
2-
'''RC min/max setup'''
1+
'''
2+
RC min/max setup
3+
4+
AP_FLAKE8_CLEAN
5+
'''
36

47
from MAVProxy.modules.lib import mp_module
58

9+
610
class RCSetupModule(mp_module.MPModule):
711
def __init__(self, mpstate):
812
super(RCSetupModule, self).__init__(mpstate, "rcsetup")
@@ -17,15 +21,15 @@ def __init__(self, mpstate):
1721
def clear_rc_cal(self):
1822
self.rc_cal = []
1923
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
2226
self.rc_cal.append([1500, 1500, False])
2327

2428
def apply_rc_cal(self):
2529
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:
2933
continue
3034

3135
self.param_set('RC%u_MIN' % i, self.rc_cal[i][0], 5)
@@ -80,41 +84,40 @@ def idle_task(self):
8084

8185
def cmd_rctrim(self, args):
8286
'''set RCx_TRIM'''
83-
if not 'RC_CHANNELS' in self.status.msgs:
87+
if 'RC_CHANNELS' not in self.status.msgs:
8488
print("No RC_CHANNELS to trim with")
8589
return
8690
m = self.status.msgs['RC_CHANNELS']
87-
for ch in range(1,5):
91+
for ch in range(1, 5):
8892
self.param_set('RC%u_TRIM' % ch, getattr(m, 'chan%u_raw' % ch))
8993

90-
9194
def unload(self):
9295
if 'rcreset' in self.mpstate.command_map:
9396
self.mpstate.command_map.pop('rcreset')
9497
if 'rctrim' in self.mpstate.command_map:
9598
self.mpstate.command_map.pop('rctrim')
9699

97-
98100
def mavlink_packet(self, m):
99101
'''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:
102104
return
103105

104106
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):
106108
v = getattr(m, 'chan%u_raw' % i)
107109

108110
if self.get_cal_min(i) > v:
109-
self.set_cal_min(i,v)
111+
self.set_cal_min(i, v)
110112
self.console.writeln("Calibrating: RC%u_MIN=%u" % (i, v))
111113
if self.get_cal_max(i) < v:
112-
self.set_cal_max(i,v)
114+
self.set_cal_max(i, v)
113115
self.console.writeln("Calibrating: RC%u_MAX=%u" % (i, v))
114116

115117
def print_cal_usage(self):
116118
print("Usage rccal <start|done>")
117119

120+
118121
def init(mpstate):
119122
'''initialise module'''
120123
return RCSetupModule(mpstate)

0 commit comments

Comments
 (0)