Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gps: Change the IF statement to a SWITCH statement #23069

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/drivers/gps/gps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,30 +728,41 @@ GPS::run()
int32_t gps_ubx_mode = 0;
param_get(handle, &gps_ubx_mode);

if (gps_ubx_mode == 1) { // heading
switch (gps_ubx_mode) {
case 1: // heading
if (_instance == Instance::Main) {
ubx_mode = GPSDriverUBX::UBXMode::RoverWithMovingBase;

} else {
ubx_mode = GPSDriverUBX::UBXMode::MovingBase;
}

} else if (gps_ubx_mode == 2) {
break;

case 2:
ubx_mode = GPSDriverUBX::UBXMode::MovingBase;
break;

} else if (gps_ubx_mode == 3) {
case 3:
if (_instance == Instance::Main) {
ubx_mode = GPSDriverUBX::UBXMode::RoverWithMovingBaseUART1;

} else {
ubx_mode = GPSDriverUBX::UBXMode::MovingBaseUART1;
}

} else if (gps_ubx_mode == 4) {
break;

case 4:
ubx_mode = GPSDriverUBX::UBXMode::MovingBaseUART1;
break;

} else if (gps_ubx_mode == 5) { // rover with static base on Uart2
case 5: // rover with static base on Uart2
ubx_mode = GPSDriverUBX::UBXMode::RoverWithStaticBaseUart2;
break;

default:
break;

}
}
Expand Down Expand Up @@ -1561,4 +1572,4 @@ int
gps_main(int argc, char *argv[])
{
return GPS::main(argc, argv);
}
}