Set blackbox file handler to NULL after closing file
[inav.git] / src / main / cms / cms_menu_blackbox.c
blobd16a3c79fcbec36e045d492eeb3ed5bcec343496
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
19 // CMS things for blackbox and flashfs.
22 #include <stdbool.h>
23 #include <stdint.h>
25 #include "platform.h"
27 #ifdef USE_CMS
29 #include "blackbox/blackbox.h"
31 #include "cms/cms.h"
32 #include "cms/cms_types.h"
33 #include "cms/cms_menu_blackbox.h"
35 #include "common/utils.h"
37 #include "config/feature.h"
39 #include "drivers/flash.h"
40 #include "drivers/time.h"
42 #include "fc/config.h"
43 #include "fc/settings.h"
45 #include "io/flashfs.h"
47 #ifdef USE_FLASHFS
48 static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr)
50 UNUSED(ptr);
52 displayClearScreen(pDisplay);
53 displayWrite(pDisplay, 5, 3, "ERASING FLASH...");
54 displayResync(pDisplay); // Was max7456RefreshAll(); Why at this timing?
56 flashfsEraseCompletely();
57 while (!flashIsReady()) {
58 delay(100);
61 displayClearScreen(pDisplay);
62 displayResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI?
64 return 0;
66 #endif // USE_FLASHFS
68 static bool cmsx_Blackbox_Enabled(bool *enabled)
70 if (enabled) {
71 if (*enabled) {
72 featureSet(FEATURE_BLACKBOX);
73 } else {
74 featureClear(FEATURE_BLACKBOX);
77 return featureConfigured(FEATURE_BLACKBOX);
80 static const OSD_Entry cmsx_menuBlackboxEntries[] =
82 OSD_LABEL_ENTRY("-- BLACKBOX --"),
83 OSD_BOOL_FUNC_ENTRY("ENABLED", cmsx_Blackbox_Enabled),
84 OSD_SETTING_ENTRY("RATE DENOM", SETTING_BLACKBOX_RATE_DENOM),
86 #ifdef USE_FLASHFS
87 OSD_FUNC_CALL_ENTRY("ERASE FLASH", cmsx_EraseFlash),
88 #endif // USE_FLASHFS
90 OSD_BACK_AND_END_ENTRY,
93 const CMS_Menu cmsx_menuBlackbox = {
94 #ifdef CMS_MENU_DEBUG
95 .GUARD_text = "MENUBB",
96 .GUARD_type = OME_MENU,
97 #endif
98 .onEnter = NULL,
99 .onExit = NULL,
100 .onGlobalExit = NULL,
101 .entries = cmsx_menuBlackboxEntries
103 #endif