Copter: simplify should_log (NFC)

This commit is contained in:
Peter Barker 2017-06-09 13:14:13 +10:00 committed by Randy Mackay
parent c9a4119ee9
commit cfd6d95927
1 changed files with 12 additions and 4 deletions

View File

@ -492,14 +492,22 @@ void Copter::check_usb_mux(void)
bool Copter::should_log(uint32_t mask) bool Copter::should_log(uint32_t mask)
{ {
#if LOGGING_ENABLED == ENABLED #if LOGGING_ENABLED == ENABLED
if (!(mask & g.log_bitmask) || in_mavlink_delay) { if (in_mavlink_delay) {
return false; return false;
} }
bool ret = motors->armed() || DataFlash.log_while_disarmed(); if (!(mask & g.log_bitmask)) {
if (ret && !DataFlash.logging_started() && !in_log_download) { return false;
}
if (!motors->armed() && !DataFlash.log_while_disarmed()) {
return false;
}
if (in_log_download) {
return false;
}
if (!DataFlash.logging_started()) {
start_logging(); start_logging();
} }
return ret; return true;
#else #else
return false; return false;
#endif #endif