update serTcpOpen declaration to fix compile errors (#14113)
[betaflight.git] / src / main / cms / cms_menu_vtx_common.c
blobb0dd4a02ceb47798a3513a051f7e63d5e27cd8f0
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <ctype.h>
25 #include "platform.h"
27 #if defined(USE_CMS) && defined(USE_VTX_CONTROL) && (defined(USE_VTX_TRAMP) || defined(USE_VTX_SMARTAUDIO) || defined(USE_VTX_RTC6705) || defined(USE_VTX_MSP))
29 #include "common/printf.h"
31 #include "cms/cms.h"
32 #include "cms/cms_menu_vtx_rtc6705.h"
33 #include "cms/cms_menu_vtx_smartaudio.h"
34 #include "cms/cms_menu_vtx_tramp.h"
35 #include "cms/cms_menu_vtx_msp.h"
36 #include "cms/cms_types.h"
38 #include "drivers/vtx_common.h"
40 #include "cms_menu_vtx_common.h"
42 #define MAX_STATUS_LINE_LENGTH 21
44 static char statusLine1[MAX_STATUS_LINE_LENGTH] = "";
45 static char statusLine2[MAX_STATUS_LINE_LENGTH] = "";
47 static const void *setStatusMessage(displayPort_t *pDisp)
49 UNUSED(pDisp);
51 vtxDevice_t *device = vtxCommonDevice();
53 statusLine1[0] = 0;
54 statusLine2[0] = 0;
56 if (!device) {
57 tfp_sprintf(&statusLine1[0], "VTX NOT RESPONDING");
58 tfp_sprintf(&statusLine2[0], "OR NOT CONFIGURED");
59 } else {
60 vtxDevType_e vtxType = vtxCommonGetDeviceType(device);
61 if (vtxType == VTXDEV_UNSUPPORTED) {
62 tfp_sprintf(&statusLine1[0], "UNSUPPORTED VTX TYPE");
63 } else {
64 tfp_sprintf(&statusLine1[0], "UNKNOWN VTX TYPE");
67 return NULL;
70 static const OSD_Entry vtxErrorMenuEntries[] =
72 { "", OME_Label | DYNAMIC, NULL, statusLine1 },
73 { "", OME_Label | DYNAMIC, NULL, statusLine2 },
74 { "", OME_Label, NULL, NULL },
75 { "BACK", OME_Back, NULL, NULL },
76 { NULL, OME_END, NULL, NULL }
79 static CMS_Menu cmsx_menuVtxError = {
80 #ifdef CMS_MENU_DEBUG
81 .GUARD_text = "XVTXERROR",
82 .GUARD_type = OME_MENU,
83 #endif
84 .onEnter = setStatusMessage,
85 .onExit = NULL,
86 .onDisplayUpdate = NULL,
87 .entries = vtxErrorMenuEntries,
90 // Redirect to the proper menu based on the vtx device type
91 // If device isn't valid or not a supported type then don't
92 // redirect and instead display a local informational menu.
93 const void *cmsSelectVtx(displayPort_t *pDisplay, const void *ptr)
95 UNUSED(ptr);
97 vtxDevice_t *device = vtxCommonDevice();
99 if (device) {
100 vtxDevType_e vtxType = vtxCommonGetDeviceType(device);
102 switch (vtxType) {
104 #if defined(USE_VTX_RTC6705)
105 case VTXDEV_RTC6705:
106 cmsMenuChange(pDisplay, &cmsx_menuVtxRTC6705);
108 break;
109 #endif
110 #if defined(USE_VTX_SMARTAUDIO)
111 case VTXDEV_SMARTAUDIO:
112 cmsMenuChange(pDisplay, &cmsx_menuVtxSmartAudio);
114 break;
115 #endif
116 #if defined(USE_VTX_TRAMP)
117 case VTXDEV_TRAMP:
118 cmsMenuChange(pDisplay, &cmsx_menuVtxTramp);
120 break;
121 #endif
122 #if defined(USE_VTX_MSP)
123 case VTXDEV_MSP:
124 cmsMenuChange(pDisplay, &cmsx_menuVtxMsp);
126 break;
127 #endif
128 default:
129 cmsMenuChange(pDisplay, &cmsx_menuVtxError);
131 break;
133 } else {
134 cmsMenuChange(pDisplay, &cmsx_menuVtxError);
137 return NULL;
139 #endif