Skip to content

Commit

Permalink
gps: Change the IF statement to a SWITCH statement
Browse files Browse the repository at this point in the history
  • Loading branch information
muramura authored and bresch committed May 7, 2024
1 parent 6984e6d commit b5467d8
Showing 1 changed file with 17 additions and 6 deletions.
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);
}
}

0 comments on commit b5467d8

Please sign in to comment.