ArduCopter: reduce redundant event logging

We now only write state changes to the dataflash log when they have
changed.
Also replaced <tab> with <space> in AP_State.pde
This commit is contained in:
Randy Mackay 2013-01-13 00:13:10 +09:00
parent af478d52bc
commit b4bbae56c6

View File

@ -3,18 +3,26 @@
void set_home_is_set(bool b)
{
ap.home_is_set = b;
// if no change, exit immediately
if( ap.home_is_set == b )
return;
if(b) Log_Write_Event(DATA_SET_HOME);
ap.home_is_set = b;
if(b) {
Log_Write_Event(DATA_SET_HOME);
}
}
// ---------------------------------------------
void set_armed(bool b)
{
// if no change, exit immediately
if( ap.armed == b )
return;
ap.armed = b;
if(b){
Log_Write_Event(DATA_ARMED);
}else{
Log_Write_Event(DATA_DISARMED);
}
@ -23,6 +31,10 @@ void set_armed(bool b)
// ---------------------------------------------
void set_auto_armed(bool b)
{
// if no change, exit immediately
if( ap.auto_armed == b )
return;
ap.auto_armed = b;
if(b){
Log_Write_Event(DATA_AUTO_ARMED);
@ -38,9 +50,9 @@ void set_simple_mode(bool b)
}else{
Log_Write_Event(DATA_SET_SIMPLE_OFF);
}
}
ap.simple_mode = b;
}
}
// ---------------------------------------------
static void set_failsafe(bool mode)
@ -75,6 +87,10 @@ void set_low_battery(bool b)
// ---------------------------------------------
void set_takeoff_complete(bool b)
{
// if no change, exit immediately
if( ap.takeoff_complete == b )
return;
if(b){
Log_Write_Event(DATA_TAKEOFF);
}
@ -84,6 +100,10 @@ void set_takeoff_complete(bool b)
// ---------------------------------------------
void set_land_complete(bool b)
{
// if no change, exit immediately
if( ap.land_complete == b )
return;
if(b){
Log_Write_Event(DATA_LAND_COMPLETE);
}
@ -136,5 +156,4 @@ void set_gps_healthy(bool b)
void dump_state()
{
cliSerial->printf("st: %u\n",ap.value);
//cliSerial->printf("%u\n", *(uint16_t*)&ap);
}