Set blackbox file handler to NULL after closing file
[inav.git] / src / main / cms / cms_menu_builtin.c
blobe9849df8619a911edd34556f597fe2a2ec9ff5a4
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 // Built-in menu contents and support functions
22 #include <stdbool.h>
23 #include <stdint.h>
24 #include <string.h>
25 #include <ctype.h>
27 #include "platform.h"
29 #ifdef USE_CMS
31 #include "build/version.h"
33 #include "common/utils.h"
35 #include "drivers/time.h"
37 #include "cms/cms.h"
38 #include "cms/cms_types.h"
39 #include "cms/cms_menu_builtin.h"
41 // Sub menus
43 #include "cms/cms_menu_imu.h"
44 #include "cms/cms_menu_blackbox.h"
45 #include "cms/cms_menu_mixer_servo.h"
46 #include "cms/cms_menu_navigation.h"
47 #include "cms/cms_menu_vtx.h"
48 #include "cms/cms_menu_osd.h"
49 #include "cms/cms_menu_ledstrip.h"
50 #include "cms/cms_menu_battery.h"
51 #include "cms/cms_menu_misc.h"
53 // Info
55 static char infoGitRev[GIT_SHORT_REVISION_LENGTH + 1];
56 static char infoTargetName[] = __TARGET__;
58 #include "msp/msp_protocol.h" // XXX for FC identification... not available elsewhere
60 static long cmsx_InfoInit(const OSD_Entry *from)
62 UNUSED(from);
64 int i;
65 for ( i = 0 ; i < GIT_SHORT_REVISION_LENGTH ; i++) {
66 if (shortGitRevision[i] >= 'a' && shortGitRevision[i] <= 'f')
67 infoGitRev[i] = shortGitRevision[i] - 'a' + 'A';
68 else
69 infoGitRev[i] = shortGitRevision[i];
72 infoGitRev[i] = 0x0; // Terminate string
73 return 0;
76 static const OSD_Entry menuInfoEntries[] = {
77 OSD_LABEL_ENTRY("--- INFO ---"),
78 OSD_STRING_ENTRY("FWID", INAV_IDENTIFIER),
79 OSD_STRING_ENTRY("FWVER", FC_VERSION_STRING),
80 OSD_STRING_ENTRY("GITREV", infoGitRev),
81 OSD_STRING_ENTRY("TARGET", infoTargetName),
83 OSD_BACK_AND_END_ENTRY,
86 static const CMS_Menu menuInfo = {
87 #ifdef CMS_MENU_DEBUG
88 .GUARD_text = "MENUINFO",
89 .GUARD_type = OME_MENU,
90 #endif
91 .onEnter = cmsx_InfoInit,
92 .onExit = NULL,
93 .onGlobalExit = NULL,
94 .entries = menuInfoEntries
97 // Features
99 static const OSD_Entry menuFeaturesEntries[] =
101 OSD_LABEL_ENTRY("--- FEATURES ---"),
102 OSD_SUBMENU_ENTRY("BLACKBOX", &cmsx_menuBlackbox),
103 OSD_SUBMENU_ENTRY("MIXER & SERVOS", &cmsx_menuMixerServo),
104 OSD_SUBMENU_ENTRY("NAVIGATION", &cmsx_menuNavigation),
105 #if defined(USE_VTX_CONTROL)
106 OSD_SUBMENU_ENTRY("VTX", &cmsx_menuVtxControl),
107 #endif // VTX_CONTROL
108 #ifdef USE_LED_STRIP
109 OSD_SUBMENU_ENTRY("LED STRIP", &cmsx_menuLedstrip),
110 #endif // LED_STRIP
112 OSD_BACK_AND_END_ENTRY,
115 static const CMS_Menu menuFeatures = {
116 #ifdef CMS_MENU_DEBUG
117 .GUARD_text = "MENUFEATURES",
118 .GUARD_type = OME_MENU,
119 #endif
120 .onEnter = NULL,
121 .onExit = NULL,
122 .onGlobalExit = NULL,
123 .entries = menuFeaturesEntries,
126 // Main
128 static const OSD_Entry menuMainEntries[] =
130 OSD_LABEL_ENTRY("-- MAIN --"),
132 OSD_SUBMENU_ENTRY("PID TUNING", &cmsx_menuImu),
133 OSD_SUBMENU_ENTRY("FEATURES", &menuFeatures),
134 #if defined(USE_OSD) && defined(CMS_MENU_OSD)
135 OSD_SUBMENU_ENTRY("OSD", &cmsx_menuOsd),
136 #endif
137 OSD_SUBMENU_ENTRY("BATTERY", &cmsx_menuBattery),
138 OSD_SUBMENU_ENTRY("FC+FW INFO", &menuInfo),
139 OSD_SUBMENU_ENTRY("MISC", &cmsx_menuMisc),
141 {"SAVE+REBOOT", {.func = cmsMenuExit}, (void*)CMS_EXIT_SAVEREBOOT, OME_OSD_Exit, 0},
142 {"EXIT" , {.func = cmsMenuExit}, (void*)CMS_EXIT, OME_OSD_Exit, 0},
143 #ifdef CMS_MENU_DEBUG
144 OSD_SUBMENU_ENTRY("ERR SAMPLE", &menuInfoEntries[0]),
145 #endif
147 OSD_END_ENTRY,
150 const CMS_Menu menuMain = {
151 #ifdef CMS_MENU_DEBUG
152 .GUARD_text = "MENUMAIN",
153 .GUARD_type = OME_MENU,
154 #endif
155 .onEnter = NULL,
156 .onExit = NULL,
157 .onGlobalExit = NULL,
158 .entries = menuMainEntries,
160 #endif