Copter: send_available_mode
report custom scripting modes
This commit is contained in:
parent
d3ffa2e56a
commit
551a7b8a20
@ -1742,7 +1742,16 @@ uint8_t GCS_MAVLINK_Copter::send_available_mode(uint8_t index) const
|
||||
#endif
|
||||
};
|
||||
|
||||
const uint8_t mode_count = ARRAY_SIZE(modes);
|
||||
const uint8_t base_mode_count = ARRAY_SIZE(modes);
|
||||
uint8_t mode_count = base_mode_count;
|
||||
|
||||
#if AP_SCRIPTING_ENABLED
|
||||
for (uint8_t i = 0; i < ARRAY_SIZE(copter.mode_guided_custom); i++) {
|
||||
if (copter.mode_guided_custom[i] != nullptr) {
|
||||
mode_count += 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Convert to zero indexed
|
||||
const uint8_t index_zero = index - 1;
|
||||
@ -1752,8 +1761,27 @@ uint8_t GCS_MAVLINK_Copter::send_available_mode(uint8_t index) const
|
||||
}
|
||||
|
||||
// Ask the mode for its name and number
|
||||
const char* name = modes[index_zero]->name();
|
||||
uint8_t mode_number = (uint8_t)modes[index_zero]->mode_number();
|
||||
const char* name;
|
||||
uint8_t mode_number;
|
||||
|
||||
if (index_zero < base_mode_count) {
|
||||
name = modes[index_zero]->name();
|
||||
mode_number = (uint8_t)modes[index_zero]->mode_number();
|
||||
|
||||
} else {
|
||||
#if AP_SCRIPTING_ENABLED
|
||||
const uint8_t custom_index = index_zero - base_mode_count;
|
||||
if (copter.mode_guided_custom[custom_index] == nullptr) {
|
||||
// Invalid index, should not happen
|
||||
return mode_count;
|
||||
}
|
||||
name = copter.mode_guided_custom[custom_index]->name();
|
||||
mode_number = (uint8_t)copter.mode_guided_custom[custom_index]->mode_number();
|
||||
#else
|
||||
// Should not endup here
|
||||
return mode_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MODE_AUTO_ENABLED
|
||||
// Auto RTL is odd
|
||||
|
Loading…
Reference in New Issue
Block a user