Skip to content

Commit

Permalink
modules: rcsetup: flake8 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Nov 9, 2024
1 parent b7d20f7 commit 166cdcb
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions MAVProxy/modules/mavproxy_rcsetup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env python
'''RC min/max setup'''
'''
RC min/max setup
AP_FLAKE8_CLEAN
'''

from MAVProxy.modules.lib import mp_module


class RCSetupModule(mp_module.MPModule):
def __init__(self, mpstate):
super(RCSetupModule, self).__init__(mpstate, "rcsetup")
Expand Down Expand Up @@ -80,41 +84,40 @@ def idle_task(self):

def cmd_rctrim(self, args):
'''set RCx_TRIM'''
if not 'RC_CHANNELS' in self.status.msgs:
if 'RC_CHANNELS' not in self.status.msgs:
print("No RC_CHANNELS to trim with")
return
m = self.status.msgs['RC_CHANNELS']
for ch in range(1,5):
for ch in range(1, 5):
self.param_set('RC%u_TRIM' % ch, getattr(m, 'chan%u_raw' % ch))


def unload(self):
if 'rcreset' in self.mpstate.command_map:
self.mpstate.command_map.pop('rcreset')
if 'rctrim' in self.mpstate.command_map:
self.mpstate.command_map.pop('rctrim')


def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
#do nothing if not caibrating
if (self.calibrating == False):
# do nothing if not caibrating
if self.calibrating is False:
return

if m.get_type() == 'RC_CHANNELS':
for i in range(1,self.num_channels+1):
for i in range(1, self.num_channels+1):
v = getattr(m, 'chan%u_raw' % i)

if self.get_cal_min(i) > v:
self.set_cal_min(i,v)
self.set_cal_min(i, v)
self.console.writeln("Calibrating: RC%u_MIN=%u" % (i, v))
if self.get_cal_max(i) < v:
self.set_cal_max(i,v)
self.set_cal_max(i, v)
self.console.writeln("Calibrating: RC%u_MAX=%u" % (i, v))

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


def init(mpstate):
'''initialise module'''
return RCSetupModule(mpstate)

0 comments on commit 166cdcb

Please sign in to comment.