mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-31 13:08:34 -04:00
RC_Channel: add get_stick_gesture_pos() for OSD menus
This commit is contained in:
parent
9e5c6248cb
commit
16f0f5ecfd
@ -1922,12 +1922,26 @@ RC_Channel::AuxSwitchPos RC_Channel::get_aux_switch_pos() const
|
||||
return position;
|
||||
}
|
||||
|
||||
// return switch position value as LOW, MIDDLE, HIGH
|
||||
// if reading the switch fails then it returns LOW
|
||||
RC_Channel::AuxSwitchPos RC_Channels::get_channel_pos(const uint8_t rcmapchan) const
|
||||
// return stick gesture pos as LOW, MIDDLE, HIGH
|
||||
// this function uses different threshold values to RC_Chanel::get_aux_switch_pos()
|
||||
// to avoid glitching on the stick travel and also always honours channel reversal
|
||||
RC_Channel::AuxSwitchPos RC_Channel::get_stick_gesture_pos() const
|
||||
{
|
||||
const RC_Channel* chan = rc().channel(rcmapchan-1);
|
||||
return chan != nullptr ? chan->get_aux_switch_pos() : RC_Channel::AuxSwitchPos::LOW;
|
||||
const uint16_t in = get_radio_in();
|
||||
if (in <= 900 || in >= 2200) {
|
||||
return RC_Channel::AuxSwitchPos::LOW;
|
||||
}
|
||||
|
||||
// switch is reversed if 'reversed' option set on channel and switches reverse is allowed by RC_OPTIONS
|
||||
bool switch_reversed = get_reverse();
|
||||
|
||||
if (in < RC_Channel::AUX_PWM_TRIGGER_LOW) {
|
||||
return switch_reversed ? RC_Channel::AuxSwitchPos::HIGH : RC_Channel::AuxSwitchPos::LOW;
|
||||
}
|
||||
if (in > RC_Channel::AUX_PWM_TRIGGER_HIGH) {
|
||||
return switch_reversed ? RC_Channel::AuxSwitchPos::LOW : RC_Channel::AuxSwitchPos::HIGH;
|
||||
}
|
||||
return RC_Channel::AuxSwitchPos::MIDDLE;
|
||||
}
|
||||
|
||||
RC_Channel *RC_Channels::find_channel_for_option(const RC_Channel::AUX_FUNC option)
|
||||
|
@ -317,6 +317,9 @@ public:
|
||||
|
||||
AuxSwitchPos get_aux_switch_pos() const;
|
||||
|
||||
// aux position for stick gestures used by RunCam menus etc
|
||||
AuxSwitchPos get_stick_gesture_pos() const;
|
||||
|
||||
// wrapper function around do_aux_function which allows us to log
|
||||
bool run_aux_function(AUX_FUNC ch_option, AuxSwitchPos pos, AuxFuncTriggerSource source);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user