def cmd_switch(self, args):
        '''handle RC switch changes'''
        mapping = [ 0, 1165, 1295, 1425, 1555, 1685, 1815 ]
        if len(args) != 1:
            print("Usage: switch <pwmvalue>")
            return
        value = int(args[0])
        if value < 0 or value > 6:
            print("Invalid switch value. Use 1-6 for flight modes, '0' to disable")
            return
        if self.vehicle_type == 'copter':
            default_channel = 5
        else:
            default_channel = 8
        if self.vehicle_type == 'rover':
            flite_mode_ch_parm = int(self.get_mav_param("MODE_CH", default_channel))
        else:
            flite_mode_ch_parm = int(self.get_mav_param("FLTMODE_CH", default_channel))
        self.override[flite_mode_ch_parm - 1] = mapping[value]
        self.override_counter = 10
        self.send_rc_override()
        if value == 0:
            print("Disabled RC switch override")
        else:
            print("Set RC switch override to %u (PWM=%u channel=%u)" % (
                value, mapping[value], flite_mode_ch_parm))
def cmd_switch ( self , args ) : mapping = [ 0 , 1165 , 1295 , 1425 , 1555 , 1685 , 1815 ] if len ( args ) != 1 : print ( "Usage: switch <pwmvalue>" ) return value = int ( args [ 0 ] ) if value < 0 or value > 6 : print ( "Invalid switch value. Use 1-6 for flight modes, '0' to disable" ) return if self . vehicle_type == 'copter' : default_channel = 5 else : default_channel = 8 if self . vehicle_type == 'rover' : flite_mode_ch_parm = int ( self . get_mav_param ( "MODE_CH" , default_channel ) ) else : flite_mode_ch_parm = int ( self . get_mav_param ( "FLTMODE_CH" , default_channel ) ) self . override [ flite_mode_ch_parm - 1 ] = mapping [ value ] self . override_counter = 10 self . send_rc_override ( ) if value == 0 : print ( "Disabled RC switch override" ) else : print ( "Set RC switch override to %u (PWM=%u channel=%u)" % ( value , mapping [ value ] , flite_mode_ch_parm ) )
handle RC switch changes