Copter: Change to ternary operator

This commit is contained in:
muramura 2023-09-23 08:36:10 +09:00 committed by Peter Barker
parent ec601684e6
commit d36667c84a
1 changed files with 3 additions and 15 deletions

View File

@ -585,27 +585,15 @@ void ModeZigZag::spray(bool b)
uint32_t ModeZigZag::wp_distance() const
{
if (is_auto) {
return wp_nav->get_wp_distance_to_destination();
} else {
return 0;
}
return is_auto ? wp_nav->get_wp_distance_to_destination() : 0;
}
int32_t ModeZigZag::wp_bearing() const
{
if (is_auto) {
return wp_nav->get_wp_bearing_to_destination();
} else {
return 0;
}
return is_auto ? wp_nav->get_wp_bearing_to_destination() : 0;
}
float ModeZigZag::crosstrack_error() const
{
if (is_auto) {
return wp_nav->crosstrack_error();
} else {
return 0;
}
return is_auto ? wp_nav->crosstrack_error() : 0;
}
#endif // MODE_ZIGZAG_ENABLED == ENABLED