mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-24 15:27:41 +08:00
fix(OSD): show Cruise as flight mode if in Position and fixed-wing
Signed-off-by: Silvan <silvan@auterion.com>
This commit is contained in:
@@ -89,7 +89,7 @@ msp_name_t construct_display_message(const vehicle_status_s &vehicle_status,
|
||||
}
|
||||
|
||||
// display flight mode
|
||||
display.set(MessageDisplayType::FLIGHT_MODE, mode_util::nav_state_names[vehicle_status.nav_state]);
|
||||
display.set(MessageDisplayType::FLIGHT_MODE, mode_util::nav_state_name(vehicle_status.nav_state, vehicle_status.vehicle_type));
|
||||
}
|
||||
|
||||
// display, if updated
|
||||
|
||||
@@ -103,6 +103,26 @@ const char *const nav_state_names[vehicle_status_s::NAVIGATION_STATE_MAX] = {
|
||||
"External 8",
|
||||
};
|
||||
|
||||
/**
|
||||
* @return Human-readable name for a nav_state, taking the vehicle type into account.
|
||||
*
|
||||
* The position control mode is shown as "Cruise" for fixed-wing vehicles (including VTOLs in
|
||||
* forward flight, which report VEHICLE_TYPE_FIXED_WING) and as "Position" for all other types.
|
||||
*/
|
||||
static inline const char *nav_state_name(uint8_t nav_state, uint8_t vehicle_type)
|
||||
{
|
||||
if (nav_state >= vehicle_status_s::NAVIGATION_STATE_MAX) {
|
||||
return "(unknown)";
|
||||
}
|
||||
|
||||
if (nav_state == vehicle_status_s::NAVIGATION_STATE_POSCTL
|
||||
&& vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING) {
|
||||
return "Cruise";
|
||||
}
|
||||
|
||||
return nav_state_names[nav_state];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return returns true for advanced modes
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user