Blackbox erase additions

This commit is contained in:
Bryce Johnson 2017-02-07 21:22:09 -06:00
parent 88282e034f
commit e71e93ae02
2 changed files with 16 additions and 8 deletions

View File

@ -254,6 +254,7 @@ typedef enum BlackboxState {
BLACKBOX_STATE_SHUTTING_DOWN, //11
BLACKBOX_STATE_START_ERASE, //12
BLACKBOX_STATE_ERASING, //13
BLACKBOX_STATE_ERASED //14
} BlackboxState;
@ -1466,17 +1467,15 @@ static void blackboxLogIteration(timeUs_t currentTimeUs)
void handleBlackbox(timeUs_t currentTimeUs)
{
int i;
static bool erasedOnce = false; //Only allow one erase per FC reboot.
switch (blackboxState) {
case BLACKBOX_STATE_STOPPED:
if (ARMING_FLAG(ARMED)) {
blackboxOpen();
startBlackbox();
}
if (IS_RC_MODE_ACTIVE(BOXBLACKBOXERASE) && !erasedOnce) {
if (IS_RC_MODE_ACTIVE(BOXBLACKBOXERASE)) {
blackboxSetState(BLACKBOX_STATE_START_ERASE);
erasedOnce = true;
}
break;
case BLACKBOX_STATE_PREPARE_LOG_FILE:
@ -1610,17 +1609,24 @@ void handleBlackbox(timeUs_t currentTimeUs)
case BLACKBOX_STATE_ERASING:
if (isBlackboxErased()) {
//Done eraseing
blackboxSetState(BLACKBOX_STATE_STOPPED);
blackboxSetState(BLACKBOX_STATE_ERASED);
beeper(BEEPER_BLACKBOX_ERASE);
}
break;
case BLACKBOX_STATE_ERASED:
if (!IS_RC_MODE_ACTIVE(BOXBLACKBOXERASE)) {
blackboxSetState(BLACKBOX_STATE_STOPPED);
}
break;
default:
break;
}
// Did we run out of room on the device? Stop!
if (isBlackboxDeviceFull()) {
if (blackboxState != BLACKBOX_STATE_ERASING && blackboxState != BLACKBOX_STATE_START_ERASE) {
if (blackboxState != BLACKBOX_STATE_ERASING
&& blackboxState != BLACKBOX_STATE_START_ERASE
&& blackboxState != BLACKBOX_STATE_ERASED) {
blackboxSetState(BLACKBOX_STATE_STOPPED);
// ensure we reset the test mode flag if we stop due to full memory card
if (startedLoggingInTestMode) startedLoggingInTestMode = false;

View File

@ -151,7 +151,7 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = {
{ BOXAIRMODE, "AIR MODE;", 28 },
{ BOX3DDISABLESWITCH, "DISABLE 3D SWITCH;", 29},
{ BOXFPVANGLEMIX, "FPV ANGLE MIX;", 30},
{ BOXBLACKBOXERASE, "BLACKBOX ERASE;", 31 },
{ BOXBLACKBOXERASE, "BLACKBOX ERASE (>30s);", 31 },
{ CHECKBOX_ITEM_COUNT, NULL, 0xFF }
};
@ -380,7 +380,9 @@ void initActiveBoxIds(void)
#ifdef BLACKBOX
if (feature(FEATURE_BLACKBOX)) {
activeBoxIds[activeBoxIdCount++] = BOXBLACKBOX;
#ifdef USE_FLASHFS
activeBoxIds[activeBoxIdCount++] = BOXBLACKBOXERASE;
#endif
}
#endif