AP_Compass: use switch statement in failed() method

This commit is contained in:
Peter Barker 2022-10-05 13:14:15 +11:00 committed by Andrew Tridgell
parent dc58d0406c
commit afd8d8255f
2 changed files with 17 additions and 4 deletions

View File

@ -138,9 +138,21 @@ void CompassCalibrator::new_sample(const Vector3f& sample)
bool CompassCalibrator::failed() {
WITH_SEMAPHORE(state_sem);
return (cal_state.status == Status::FAILED ||
cal_state.status == Status::BAD_ORIENTATION ||
cal_state.status == Status::BAD_RADIUS);
switch (cal_state.status) {
case Status::FAILED:
case Status::BAD_ORIENTATION:
case Status::BAD_RADIUS:
return true;
case Status::SUCCESS:
case Status::NOT_STARTED:
case Status::WAITING_TO_START:
case Status::RUNNING_STEP_ONE:
case Status::RUNNING_STEP_TWO:
return false;
}
// compiler guarantees we don't get here
return true;
}

View File

@ -34,7 +34,8 @@ public:
// update the state machine and calculate offsets, diagonals and offdiagonals
void update();
// compass calibration states
// compass calibration states - these correspond to the mavlink
// MAG_CAL_STATUS enumeration
enum class Status {
NOT_STARTED = 0,
WAITING_TO_START = 1,