Skip to content

Commit

Permalink
msp_osd: reuse existing mode name conversion
Browse files Browse the repository at this point in the history
This saves a bit of flash, keeps the mode names up to date and
works like expected.
  • Loading branch information
MaEtUgR committed Dec 11, 2023
1 parent 8aab3e8 commit ece60b6
Showing 1 changed file with 2 additions and 76 deletions.
78 changes: 2 additions & 76 deletions src/drivers/osd/msp_osd/uorb_to_msp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <math.h>
#include <matrix/math.hpp>
#include <lib/geo/geo.h>
#include <lib/modes/ui.hpp>

// clock access
#include <px4_platform_common/defines.h>
Expand Down Expand Up @@ -77,82 +78,7 @@ msp_name_t construct_display_message(const vehicle_status_s &vehicle_status,
}

// display flight mode
switch (vehicle_status.nav_state) {
case vehicle_status_s::NAVIGATION_STATE_MANUAL:
display.set(MessageDisplayType::FLIGHT_MODE, "MANUAL");
break;

case vehicle_status_s::NAVIGATION_STATE_ALTCTL:
display.set(MessageDisplayType::FLIGHT_MODE, "ALTCTL");
break;

case vehicle_status_s::NAVIGATION_STATE_POSCTL:
display.set(MessageDisplayType::FLIGHT_MODE, "POSCTL");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_MISSION");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_LOITER");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_RTL:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_RTL");
break;

case vehicle_status_s::NAVIGATION_STATE_ACRO:
display.set(MessageDisplayType::FLIGHT_MODE, "ACRO");
break;

case vehicle_status_s::NAVIGATION_STATE_DESCEND:
display.set(MessageDisplayType::FLIGHT_MODE, "DESCEND");
break;

case vehicle_status_s::NAVIGATION_STATE_TERMINATION:
display.set(MessageDisplayType::FLIGHT_MODE, "TERMINATION");
break;

case vehicle_status_s::NAVIGATION_STATE_OFFBOARD:
display.set(MessageDisplayType::FLIGHT_MODE, "OFFBOARD");
break;

case vehicle_status_s::NAVIGATION_STATE_STAB:
display.set(MessageDisplayType::FLIGHT_MODE, "STAB");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_TAKEOFF");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_LAND:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_LAND");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_FOLLOW_TARGET:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_FOLLOW_TARGET");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_PRECLAND:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_PRECLAND");
break;

case vehicle_status_s::NAVIGATION_STATE_ORBIT:
display.set(MessageDisplayType::FLIGHT_MODE, "ORBIT");
break;

case vehicle_status_s::NAVIGATION_STATE_AUTO_VTOL_TAKEOFF:
display.set(MessageDisplayType::FLIGHT_MODE, "AUTO_VTOL_TAKEOFF");
break;

case vehicle_status_s::NAVIGATION_STATE_MAX:
display.set(MessageDisplayType::FLIGHT_MODE, "MAX");
break;

default:
display.set(MessageDisplayType::FLIGHT_MODE, "???");
}
display.set(MessageDisplayType::FLIGHT_MODE, mode_util::nav_state_names[vehicle_status.nav_state]);
}

// display, if updated
Expand Down

0 comments on commit ece60b6

Please sign in to comment.