Copter: replace if statement with switch statement

This commit is contained in:
murata 2016-10-04 22:12:29 +09:00 committed by Randy Mackay
parent a393bd26d7
commit 60137e0f0b
1 changed files with 7 additions and 3 deletions

View File

@ -41,17 +41,21 @@ void Copter::set_auto_armed(bool b)
void Copter::set_simple_mode(uint8_t b)
{
if(ap.simple_mode != b){
if(b == 0){
switch (b) {
case 0:
Log_Write_Event(DATA_SET_SIMPLE_OFF);
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "SIMPLE mode off");
}else if(b == 1){
break;
case 1:
Log_Write_Event(DATA_SET_SIMPLE_ON);
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "SIMPLE mode on");
}else{
break;
default:
// initialise super simple heading
update_super_simple_bearing(true);
Log_Write_Event(DATA_SET_SUPERSIMPLE_ON);
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "SUPERSIMPLE mode on");
break;
}
ap.simple_mode = b;
}