mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 08:13:56 -04:00
Copter: simplify auxsw duplicates check
This commit is contained in:
parent
edf6964487
commit
b81074d83a
@ -69,6 +69,7 @@ enum aux_sw_func {
|
||||
AUXSW_RELAY4 = 36, // Relay4 pin on/off (in Mission planner set CH10_OPT = 36)
|
||||
AUXSW_THROW = 37, // change to THROW flight mode
|
||||
AUXSW_AVOID_ADSB = 38, // enable AP_Avoidance library
|
||||
AUXSW_SWITCH_MAX,
|
||||
};
|
||||
|
||||
// Frame types
|
||||
|
@ -86,23 +86,23 @@ bool Copter::check_if_auxsw_mode_used(uint8_t auxsw_mode_check)
|
||||
// check_duplicate_auxsw - Check to see if any Aux Switch Functions are duplicated
|
||||
bool Copter::check_duplicate_auxsw(void)
|
||||
{
|
||||
bool ret = ((g.ch7_option != AUXSW_DO_NOTHING) && (g.ch7_option == g.ch8_option ||
|
||||
g.ch7_option == g.ch9_option || g.ch7_option == g.ch10_option ||
|
||||
g.ch7_option == g.ch11_option || g.ch7_option == g.ch12_option));
|
||||
uint8_t auxsw_option_counts[AUXSW_SWITCH_MAX] = {};
|
||||
auxsw_option_counts[g.ch7_option]++;
|
||||
auxsw_option_counts[g.ch8_option]++;
|
||||
auxsw_option_counts[g.ch9_option]++;
|
||||
auxsw_option_counts[g.ch10_option]++;
|
||||
auxsw_option_counts[g.ch11_option]++;
|
||||
auxsw_option_counts[g.ch12_option]++;
|
||||
|
||||
ret = ret || ((g.ch8_option != AUXSW_DO_NOTHING) && (g.ch8_option == g.ch9_option ||
|
||||
g.ch8_option == g.ch10_option || g.ch8_option == g.ch11_option ||
|
||||
g.ch8_option == g.ch12_option));
|
||||
|
||||
ret = ret || ((g.ch9_option != AUXSW_DO_NOTHING) && (g.ch9_option == g.ch10_option ||
|
||||
g.ch9_option == g.ch11_option || g.ch9_option == g.ch12_option));
|
||||
|
||||
ret = ret || ((g.ch10_option != AUXSW_DO_NOTHING) && (g.ch10_option == g.ch11_option ||
|
||||
g.ch10_option == g.ch12_option));
|
||||
|
||||
ret = ret || ((g.ch11_option != AUXSW_DO_NOTHING) && (g.ch11_option == g.ch12_option));
|
||||
|
||||
return ret;
|
||||
for (uint8_t i=0; i<sizeof(auxsw_option_counts); i++) {
|
||||
if (i == AUXSW_DO_NOTHING) {
|
||||
continue;
|
||||
}
|
||||
if (auxsw_option_counts[i] > 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Copter::reset_control_switch()
|
||||
|
Loading…
Reference in New Issue
Block a user