mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
RC_Channel: Aux switches to respect 'reverse' option
This commit is contained in:
parent
f04acbd7de
commit
f92d539b41
@ -966,10 +966,14 @@ bool RC_Channel::read_3pos_switch(RC_Channel::aux_switch_pos_t &ret) const
|
||||
if (in <= 900 or in >= 2200) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// switch is reversed if 'reversed' option set on channel and switches reverse is allowed by RC_OPTIONS
|
||||
bool switch_reversed = reversed && rc().switch_reverse_allowed();
|
||||
|
||||
if (in < AUX_PWM_TRIGGER_LOW) {
|
||||
ret = LOW;
|
||||
ret = switch_reversed ? HIGH : LOW;
|
||||
} else if (in > AUX_PWM_TRIGGER_HIGH) {
|
||||
ret = HIGH;
|
||||
ret = switch_reversed ? LOW : HIGH;
|
||||
} else {
|
||||
ret = MIDDLE;
|
||||
}
|
||||
|
@ -358,6 +358,11 @@ public:
|
||||
return get_singleton() != nullptr && (_options & uint32_t(Option::FPORT_PAD));
|
||||
}
|
||||
|
||||
// should a channel reverse option affect aux switches
|
||||
bool switch_reverse_allowed(void) const {
|
||||
return get_singleton() != nullptr && (_options & uint32_t(Option::ALLOW_SWITCH_REV));
|
||||
}
|
||||
|
||||
bool ignore_overrides() const {
|
||||
return _options & uint32_t(Option::IGNORE_OVERRIDES);
|
||||
}
|
||||
@ -401,6 +406,7 @@ protected:
|
||||
LOG_DATA = (1 << 4), // log rc input bytes
|
||||
ARMING_CHECK_THROTTLE = (1 << 5), // run an arming check for neutral throttle
|
||||
ARMING_SKIP_CHECK_RPY = (1 << 6), // skip the an arming checks for the roll/pitch/yaw channels
|
||||
ALLOW_SWITCH_REV = (1 << 7), // honor the reversed flag on switches
|
||||
};
|
||||
|
||||
void new_override_received() {
|
||||
|
@ -86,7 +86,7 @@ const AP_Param::GroupInfo RC_Channels::var_info[] = {
|
||||
// @DisplayName: RC options
|
||||
// @Description: RC input options
|
||||
// @User: Advanced
|
||||
// @Bitmask: 0:Ignore RC Receiver, 1:Ignore MAVLink Overrides, 2:Ignore Receiver Failsafe, 3:FPort Pad, 4:Log RC input bytes, 5:Arming check throttle for 0 input, 6:Skip the arming check for neutral Roll/Pitch/Yay sticks
|
||||
// @Bitmask: 0:Ignore RC Receiver, 1:Ignore MAVLink Overrides, 2:Ignore Receiver Failsafe, 3:FPort Pad, 4:Log RC input bytes, 5:Arming check throttle for 0 input, 6:Skip the arming check for neutral Roll/Pitch/Yay sticks, 7:Allow Switch reverse
|
||||
AP_GROUPINFO("_OPTIONS", 33, RC_CHANNELS_SUBCLASS, _options, 0),
|
||||
|
||||
AP_GROUPEND
|
||||
|
Loading…
Reference in New Issue
Block a user