flightmodes: flag advanced modes accordingly

This commit is contained in:
Yannick Fuhrer 2023-11-08 09:31:37 +01:00 committed by Beat Küng
parent c0b9ecdc82
commit c7e11f1774
No known key found for this signature in database
GPG Key ID: 866DB5F0E24821BB
2 changed files with 35 additions and 0 deletions

View File

@ -99,4 +99,35 @@ const char *const nav_state_names[vehicle_status_s::NAVIGATION_STATE_MAX] = {
"External 8",
};
/**
* @return returns true for advanced modes
*/
static inline bool isAdvanced(uint8_t nav_state)
{
switch (nav_state) {
case vehicle_status_s::NAVIGATION_STATE_ALTCTL: return false;
case vehicle_status_s::NAVIGATION_STATE_POSCTL: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL1: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL2: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL3: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL4: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL5: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL6: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL7: return false;
case vehicle_status_s::NAVIGATION_STATE_EXTERNAL8: return false;
}
return true;
}
} // namespace mode_util

View File

@ -88,6 +88,10 @@ private:
// Set the mode name if not a standard mode
available_modes.standard_mode = (uint8_t)mode_util::getStandardModeFromNavState(nav_state);
if (mode_util::isAdvanced(nav_state)) {
available_modes.properties |= MAV_MODE_PROPERTY_ADVANCED;
}
if (available_modes.standard_mode == MAV_STANDARD_MODE_NON_STANDARD) {
static_assert(sizeof(available_modes.mode_name) >= sizeof(ExternalModeName::name), "mode name too short");