mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Replace individual CMS vtx menus with a single entry that redirects to the correct protocol menu
Instead of having individual menus for RTC6705, SmartAudio, and Tramp, Now there is a single VTX menu that detects the type of active device and redirects to the appropriate protocol menu. Reduces confusion and chances of erroneously using the wrong VTX menu. Fixes a problem where the Tramp menu could be used to change band/channel/power even though the VTX was a SmartAudio device. If the VTX is not configured or not communicating, a more informative message will be presented rather than a partially populated protocol menu. For example: ``` VTX NOT RESPONDING OR NOT CONFIGURED > BACK ``` Extends the CMS menu capabilities by adding an optional `redirectCheck` function that can conditionally return a menu that should be redirected to instead of the current menu. This redirect happens before any processing happens for the original menu. Adds flexibility to make the CMS menus have a more dynamic aspect.
This commit is contained in:
parent
1c8d41b952
commit
5c98726318
19 changed files with 206 additions and 16 deletions
|
@ -138,6 +138,7 @@ COMMON_SRC = \
|
||||||
cms/cms_menu_osd.c \
|
cms/cms_menu_osd.c \
|
||||||
cms/cms_menu_power.c \
|
cms/cms_menu_power.c \
|
||||||
cms/cms_menu_saveexit.c \
|
cms/cms_menu_saveexit.c \
|
||||||
|
cms/cms_menu_vtx_common.c \
|
||||||
cms/cms_menu_vtx_rtc6705.c \
|
cms/cms_menu_vtx_rtc6705.c \
|
||||||
cms/cms_menu_vtx_smartaudio.c \
|
cms/cms_menu_vtx_smartaudio.c \
|
||||||
cms/cms_menu_vtx_tramp.c \
|
cms/cms_menu_vtx_tramp.c \
|
||||||
|
@ -327,6 +328,7 @@ SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
|
||||||
cms/cms_menu_osd.c \
|
cms/cms_menu_osd.c \
|
||||||
cms/cms_menu_power.c \
|
cms/cms_menu_power.c \
|
||||||
cms/cms_menu_saveexit.c \
|
cms/cms_menu_saveexit.c \
|
||||||
|
cms/cms_menu_vtx_common.c \
|
||||||
cms/cms_menu_vtx_rtc6705.c \
|
cms/cms_menu_vtx_rtc6705.c \
|
||||||
cms/cms_menu_vtx_smartaudio.c \
|
cms/cms_menu_vtx_smartaudio.c \
|
||||||
cms/cms_menu_vtx_tramp.c \
|
cms/cms_menu_vtx_tramp.c \
|
||||||
|
|
|
@ -654,6 +654,13 @@ long cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pMenu->checkRedirect) {
|
||||||
|
const CMS_Menu *pRedirectMenu = (const CMS_Menu *)pMenu->checkRedirect();
|
||||||
|
if (pRedirectMenu) {
|
||||||
|
return cmsMenuChange(pDisplay, pRedirectMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menuStack[menuStackIdx++] = currentCtx;
|
menuStack[menuStackIdx++] = currentCtx;
|
||||||
|
|
||||||
currentCtx.menu = pMenu;
|
currentCtx.menu = pMenu;
|
||||||
|
|
|
@ -221,6 +221,7 @@ CMS_Menu cmsx_menuBlackbox = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_Blackbox_onEnter,
|
.onEnter = cmsx_Blackbox_onEnter,
|
||||||
.onExit = cmsx_Blackbox_onExit,
|
.onExit = cmsx_Blackbox_onExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuBlackboxEntries
|
.entries = cmsx_menuBlackboxEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,7 @@
|
||||||
|
|
||||||
// VTX supplied menus
|
// VTX supplied menus
|
||||||
|
|
||||||
#include "cms/cms_menu_vtx_rtc6705.h"
|
#include "cms/cms_menu_vtx_common.h"
|
||||||
#include "cms/cms_menu_vtx_smartaudio.h"
|
|
||||||
#include "cms/cms_menu_vtx_tramp.h"
|
|
||||||
|
|
||||||
#include "drivers/system.h"
|
#include "drivers/system.h"
|
||||||
|
|
||||||
|
@ -98,6 +96,7 @@ static CMS_Menu menuInfo = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_InfoInit,
|
.onEnter = cmsx_InfoInit,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = menuInfoEntries
|
.entries = menuInfoEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,14 +110,8 @@ static const OSD_Entry menuFeaturesEntries[] =
|
||||||
{"BLACKBOX", OME_Submenu, cmsMenuChange, &cmsx_menuBlackbox, 0},
|
{"BLACKBOX", OME_Submenu, cmsMenuChange, &cmsx_menuBlackbox, 0},
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_VTX_CONTROL)
|
#if defined(USE_VTX_CONTROL)
|
||||||
#if defined(USE_VTX_RTC6705)
|
#if defined(USE_VTX_RTC6705) || defined(USE_VTX_SMARTAUDIO) || defined(USE_VTX_TRAMP)
|
||||||
{"VTX", OME_Submenu, cmsMenuChange, &cmsx_menuVtxRTC6705, 0},
|
{"VTX", OME_Submenu, cmsMenuChange, &cmsx_menuVtxRedirect, 0},
|
||||||
#endif // VTX_RTC6705
|
|
||||||
#if defined(USE_VTX_SMARTAUDIO)
|
|
||||||
{"VTX SA", OME_Submenu, cmsMenuChange, &cmsx_menuVtxSmartAudio, 0},
|
|
||||||
#endif
|
|
||||||
#if defined(USE_VTX_TRAMP)
|
|
||||||
{"VTX TR", OME_Submenu, cmsMenuChange, &cmsx_menuVtxTramp, 0},
|
|
||||||
#endif
|
#endif
|
||||||
#endif // VTX_CONTROL
|
#endif // VTX_CONTROL
|
||||||
#ifdef USE_LED_STRIP
|
#ifdef USE_LED_STRIP
|
||||||
|
@ -139,6 +132,7 @@ static CMS_Menu menuFeatures = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = NULL,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = menuFeaturesEntries,
|
.entries = menuFeaturesEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -182,6 +176,7 @@ CMS_Menu menuMain = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = NULL,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = menuMainEntries,
|
.entries = menuMainEntries,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,6 +91,7 @@ CMS_Menu cmsx_menuFailsafe = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_Failsafe_onEnter,
|
.onEnter = cmsx_Failsafe_onEnter,
|
||||||
.onExit = cmsx_Failsafe_onExit,
|
.onExit = cmsx_Failsafe_onExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuFailsafeEntries
|
.entries = cmsx_menuFailsafeEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ CMS_Menu cms_menuGpsRescuePid = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cms_menuGpsRescuePidOnEnter,
|
.onEnter = cms_menuGpsRescuePidOnEnter,
|
||||||
.onExit = cms_menuGpsRescuePidOnExit,
|
.onExit = cms_menuGpsRescuePidOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cms_menuGpsRescuePidEntries,
|
.entries = cms_menuGpsRescuePidEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -198,6 +199,7 @@ CMS_Menu cmsx_menuGpsRescue = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_menuGpsRescueOnEnter,
|
.onEnter = cmsx_menuGpsRescueOnEnter,
|
||||||
.onExit = cmsx_menuGpsRescueOnExit,
|
.onExit = cmsx_menuGpsRescueOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuGpsRescueEntries,
|
.entries = cmsx_menuGpsRescueEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ static CMS_Menu cmsx_menuPid = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_PidOnEnter,
|
.onEnter = cmsx_PidOnEnter,
|
||||||
.onExit = cmsx_PidWriteback,
|
.onExit = cmsx_PidWriteback,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuPidEntries
|
.entries = cmsx_menuPidEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -289,6 +290,7 @@ static CMS_Menu cmsx_menuRateProfile = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_RateProfileOnEnter,
|
.onEnter = cmsx_RateProfileOnEnter,
|
||||||
.onExit = cmsx_RateProfileWriteback,
|
.onExit = cmsx_RateProfileWriteback,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuRateProfileEntries
|
.entries = cmsx_menuRateProfileEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -347,6 +349,7 @@ static CMS_Menu cmsx_menuLaunchControl = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_launchControlOnEnter,
|
.onEnter = cmsx_launchControlOnEnter,
|
||||||
.onExit = cmsx_launchControlOnExit,
|
.onExit = cmsx_launchControlOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuLaunchControlEntries,
|
.entries = cmsx_menuLaunchControlEntries,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -492,6 +495,7 @@ static CMS_Menu cmsx_menuProfileOther = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_profileOtherOnEnter,
|
.onEnter = cmsx_profileOtherOnEnter,
|
||||||
.onExit = cmsx_profileOtherOnExit,
|
.onExit = cmsx_profileOtherOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuProfileOtherEntries,
|
.entries = cmsx_menuProfileOtherEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -559,6 +563,7 @@ static CMS_Menu cmsx_menuFilterGlobal = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_menuGyro_onEnter,
|
.onEnter = cmsx_menuGyro_onEnter,
|
||||||
.onExit = cmsx_menuGyro_onExit,
|
.onExit = cmsx_menuGyro_onExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuFilterGlobalEntries,
|
.entries = cmsx_menuFilterGlobalEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -646,6 +651,7 @@ static CMS_Menu cmsx_menuDynFilt = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_menuDynFilt_onEnter,
|
.onEnter = cmsx_menuDynFilt_onEnter,
|
||||||
.onExit = cmsx_menuDynFilt_onExit,
|
.onExit = cmsx_menuDynFilt_onExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuDynFiltEntries,
|
.entries = cmsx_menuDynFiltEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -706,6 +712,7 @@ static CMS_Menu cmsx_menuFilterPerProfile = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_FilterPerProfileRead,
|
.onEnter = cmsx_FilterPerProfileRead,
|
||||||
.onExit = cmsx_FilterPerProfileWriteback,
|
.onExit = cmsx_FilterPerProfileWriteback,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuFilterPerProfileEntries,
|
.entries = cmsx_menuFilterPerProfileEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -776,6 +783,7 @@ CMS_Menu cmsx_menuCopyProfile = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_menuCopyProfile_onEnter,
|
.onEnter = cmsx_menuCopyProfile_onEnter,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuCopyProfileEntries,
|
.entries = cmsx_menuCopyProfileEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -813,6 +821,7 @@ CMS_Menu cmsx_menuImu = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_menuImu_onEnter,
|
.onEnter = cmsx_menuImu_onEnter,
|
||||||
.onExit = cmsx_menuImu_onExit,
|
.onExit = cmsx_menuImu_onExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuImuEntries,
|
.entries = cmsx_menuImuEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ CMS_Menu cmsx_menuLedstrip = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_Ledstrip_OnEnter,
|
.onEnter = cmsx_Ledstrip_OnEnter,
|
||||||
.onExit = cmsx_Ledstrip_OnExit,
|
.onExit = cmsx_Ledstrip_OnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuLedstripEntries
|
.entries = cmsx_menuLedstripEntries
|
||||||
};
|
};
|
||||||
#endif // LED_STRIP
|
#endif // LED_STRIP
|
||||||
|
|
|
@ -93,6 +93,7 @@ CMS_Menu cmsx_menuRcPreview = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = NULL,
|
||||||
.onExit = cmsx_menuRcConfirmBack,
|
.onExit = cmsx_menuRcConfirmBack,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuRcEntries
|
.entries = cmsx_menuRcEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ CMS_Menu cmsx_menuMisc = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_menuMiscOnEnter,
|
.onEnter = cmsx_menuMiscOnEnter,
|
||||||
.onExit = cmsx_menuMiscOnExit,
|
.onExit = cmsx_menuMiscOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = menuMiscEntries
|
.entries = menuMiscEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,7 @@ CMS_Menu menuOsdActiveElems = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = menuOsdActiveElemsOnEnter,
|
.onEnter = menuOsdActiveElemsOnEnter,
|
||||||
.onExit = menuOsdActiveElemsOnExit,
|
.onExit = menuOsdActiveElemsOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = menuOsdActiveElemsEntries
|
.entries = menuOsdActiveElemsEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,6 +219,7 @@ CMS_Menu menuAlarms = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = menuAlarmsOnEnter,
|
.onEnter = menuAlarmsOnEnter,
|
||||||
.onExit = menuAlarmsOnExit,
|
.onExit = menuAlarmsOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = menuAlarmsEntries,
|
.entries = menuAlarmsEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -270,6 +272,7 @@ CMS_Menu menuTimers = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = menuTimersOnEnter,
|
.onEnter = menuTimersOnEnter,
|
||||||
.onExit = menuTimersOnExit,
|
.onExit = menuTimersOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = menuTimersEntries,
|
.entries = menuTimersEntries,
|
||||||
};
|
};
|
||||||
#endif /* USE_EXTENDED_CMS_MENUS */
|
#endif /* USE_EXTENDED_CMS_MENUS */
|
||||||
|
@ -343,6 +346,7 @@ CMS_Menu cmsx_menuOsd = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_menuOsdOnEnter,
|
.onEnter = cmsx_menuOsdOnEnter,
|
||||||
.onExit = cmsx_menuOsdOnExit,
|
.onExit = cmsx_menuOsdOnExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuOsdEntries
|
.entries = cmsx_menuOsdEntries
|
||||||
};
|
};
|
||||||
#endif // CMS
|
#endif // CMS
|
||||||
|
|
|
@ -126,6 +126,7 @@ CMS_Menu cmsx_menuPower = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_Power_onEnter,
|
.onEnter = cmsx_Power_onEnter,
|
||||||
.onExit = cmsx_Power_onExit,
|
.onExit = cmsx_Power_onExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuPowerEntries
|
.entries = cmsx_menuPowerEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ CMS_Menu cmsx_menuSaveExit = {
|
||||||
.GUARD_text = "MENUSAVE",
|
.GUARD_text = "MENUSAVE",
|
||||||
.GUARD_type = OME_MENU,
|
.GUARD_type = OME_MENU,
|
||||||
#endif
|
#endif
|
||||||
|
.onEnter = NULL,
|
||||||
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuSaveExitEntries
|
.entries = cmsx_menuSaveExitEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,6 +69,9 @@ CMS_Menu cmsx_menuSaveExitReboot = {
|
||||||
.GUARD_text = "MENUSAVE",
|
.GUARD_text = "MENUSAVE",
|
||||||
.GUARD_type = OME_MENU,
|
.GUARD_type = OME_MENU,
|
||||||
#endif
|
#endif
|
||||||
|
.onEnter = NULL,
|
||||||
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuSaveExitRebootEntries
|
.entries = cmsx_menuSaveExitRebootEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
120
src/main/cms/cms_menu_vtx_common.c
Normal file
120
src/main/cms/cms_menu_vtx_common.c
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#if defined(USE_CMS) && defined(USE_VTX_CONTROL) && (defined(USE_VTX_TRAMP) || defined(USE_VTX_SMARTAUDIO) || defined(USE_VTX_RTC6705))
|
||||||
|
|
||||||
|
#include "common/printf.h"
|
||||||
|
|
||||||
|
#include "cms/cms.h"
|
||||||
|
#include "cms/cms_menu_vtx_rtc6705.h"
|
||||||
|
#include "cms/cms_menu_vtx_smartaudio.h"
|
||||||
|
#include "cms/cms_menu_vtx_tramp.h"
|
||||||
|
#include "cms/cms_types.h"
|
||||||
|
|
||||||
|
#include "drivers/vtx_common.h"
|
||||||
|
|
||||||
|
#include "cms_menu_vtx_common.h"
|
||||||
|
|
||||||
|
#define MAX_STATUS_LINE_LENGTH 21
|
||||||
|
|
||||||
|
static char statusLine1[MAX_STATUS_LINE_LENGTH] = "";
|
||||||
|
static char statusLine2[MAX_STATUS_LINE_LENGTH] = "";
|
||||||
|
|
||||||
|
static long setStatusMessage(void)
|
||||||
|
{
|
||||||
|
vtxDevice_t *device = vtxCommonDevice();
|
||||||
|
|
||||||
|
statusLine1[0] = 0;
|
||||||
|
statusLine2[0] = 0;
|
||||||
|
|
||||||
|
if (!device) {
|
||||||
|
tfp_sprintf(&statusLine1[0], "VTX NOT RESPONDING");
|
||||||
|
tfp_sprintf(&statusLine2[0], "OR NOT CONFIGURED");
|
||||||
|
} else {
|
||||||
|
vtxDevType_e vtxType = vtxCommonGetDeviceType(device);
|
||||||
|
if (vtxType == VTXDEV_UNSUPPORTED) {
|
||||||
|
tfp_sprintf(&statusLine1[0], "UNSUPPORTED VTX TYPE");
|
||||||
|
} else {
|
||||||
|
tfp_sprintf(&statusLine1[0], "UNKNOWN VTX TYPE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to the proper menu based on the vtx device type
|
||||||
|
// If device isn't valid or not a supported type then don't
|
||||||
|
// redirect and instead display a local informational menu.
|
||||||
|
static const void *vtxMenuRedirect(void)
|
||||||
|
{
|
||||||
|
vtxDevice_t *device = vtxCommonDevice();
|
||||||
|
|
||||||
|
if (device) {
|
||||||
|
vtxDevType_e vtxType = vtxCommonGetDeviceType(device);
|
||||||
|
|
||||||
|
switch (vtxType) {
|
||||||
|
|
||||||
|
#if defined(USE_VTX_RTC6705)
|
||||||
|
case VTXDEV_RTC6705:
|
||||||
|
return &cmsx_menuVtxRTC6705;
|
||||||
|
#endif
|
||||||
|
#if defined(USE_VTX_SMARTAUDIO)
|
||||||
|
case VTXDEV_SMARTAUDIO:
|
||||||
|
return &cmsx_menuVtxSmartAudio;
|
||||||
|
#endif
|
||||||
|
#if defined(USE_VTX_TRAMP)
|
||||||
|
case VTXDEV_TRAMP:
|
||||||
|
return &cmsx_menuVtxTramp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const OSD_Entry vtxRedirectMenuEntries[] =
|
||||||
|
{
|
||||||
|
{ "", OME_Label, NULL, statusLine1, DYNAMIC },
|
||||||
|
{ "", OME_Label, NULL, statusLine2, DYNAMIC },
|
||||||
|
{ "", OME_Label, NULL, NULL, 0 },
|
||||||
|
{ "BACK", OME_Back, NULL, NULL, 0 },
|
||||||
|
{ NULL, OME_END, NULL, NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
CMS_Menu cmsx_menuVtxRedirect = {
|
||||||
|
#ifdef CMS_MENU_DEBUG
|
||||||
|
.GUARD_text = "XVTXREDIRECT",
|
||||||
|
.GUARD_type = OME_MENU,
|
||||||
|
#endif
|
||||||
|
.onEnter = setStatusMessage,
|
||||||
|
.onExit = NULL,
|
||||||
|
.checkRedirect = vtxMenuRedirect,
|
||||||
|
.entries = vtxRedirectMenuEntries,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
26
src/main/cms/cms_menu_vtx_common.h
Normal file
26
src/main/cms/cms_menu_vtx_common.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cms/cms.h"
|
||||||
|
#include "cms/cms_types.h"
|
||||||
|
|
||||||
|
extern CMS_Menu cmsx_menuVtxRedirect;
|
|
@ -139,6 +139,7 @@ CMS_Menu cmsx_menuVtxRTC6705 = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = cmsx_Vtx_onEnter,
|
.onEnter = cmsx_Vtx_onEnter,
|
||||||
.onExit = cmsx_Vtx_onExit,
|
.onExit = cmsx_Vtx_onExit,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = cmsx_menuVtxEntries
|
.entries = cmsx_menuVtxEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -416,6 +416,7 @@ static CMS_Menu saCmsMenuStats = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = NULL,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = saCmsMenuStatsEntries
|
.entries = saCmsMenuStatsEntries
|
||||||
};
|
};
|
||||||
#endif /* USE_EXTENDED_CMS_MENUS */
|
#endif /* USE_EXTENDED_CMS_MENUS */
|
||||||
|
@ -613,6 +614,7 @@ static CMS_Menu saCmsMenuPORFreq =
|
||||||
#endif
|
#endif
|
||||||
.onEnter = saCmsSetPORFreqOnEnter,
|
.onEnter = saCmsSetPORFreqOnEnter,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = saCmsMenuPORFreqEntries,
|
.entries = saCmsMenuPORFreqEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -635,6 +637,7 @@ static CMS_Menu saCmsMenuUserFreq =
|
||||||
#endif
|
#endif
|
||||||
.onEnter = saCmsSetUserFreqOnEnter,
|
.onEnter = saCmsSetUserFreqOnEnter,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = saCmsMenuUserFreqEntries,
|
.entries = saCmsMenuUserFreqEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -662,6 +665,7 @@ static CMS_Menu saCmsMenuConfig = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = NULL,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = saCmsMenuConfigEntries
|
.entries = saCmsMenuConfigEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -681,6 +685,7 @@ static CMS_Menu saCmsMenuCommence = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = NULL,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = saCmsMenuCommenceEntries,
|
.entries = saCmsMenuCommenceEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -753,6 +758,7 @@ CMS_Menu cmsx_menuVtxSmartAudio = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = sacms_SetupTopMenu,
|
.onEnter = sacms_SetupTopMenu,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = saCmsMenuOfflineEntries,
|
.entries = saCmsMenuOfflineEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,7 @@ static CMS_Menu trampCmsMenuCommence = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = NULL,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = trampCmsMenuCommenceEntries,
|
.entries = trampCmsMenuCommenceEntries,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -270,6 +271,7 @@ CMS_Menu cmsx_menuVtxTramp = {
|
||||||
#endif
|
#endif
|
||||||
.onEnter = trampCmsOnEnter,
|
.onEnter = trampCmsOnEnter,
|
||||||
.onExit = NULL,
|
.onExit = NULL,
|
||||||
|
.checkRedirect = NULL,
|
||||||
.entries = trampMenuEntries,
|
.entries = trampMenuEntries,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -96,6 +96,8 @@ onExit function is called with self:
|
||||||
|
|
||||||
typedef long (*CMSMenuOnExitPtr)(const OSD_Entry *self);
|
typedef long (*CMSMenuOnExitPtr)(const OSD_Entry *self);
|
||||||
|
|
||||||
|
typedef const void * (*CMSMenuCheckRedirectPtr)(void);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
#ifdef CMS_MENU_DEBUG
|
#ifdef CMS_MENU_DEBUG
|
||||||
|
@ -105,6 +107,7 @@ typedef struct
|
||||||
#endif
|
#endif
|
||||||
const CMSMenuFuncPtr onEnter;
|
const CMSMenuFuncPtr onEnter;
|
||||||
const CMSMenuOnExitPtr onExit;
|
const CMSMenuOnExitPtr onExit;
|
||||||
|
const CMSMenuCheckRedirectPtr checkRedirect;
|
||||||
const OSD_Entry *entries;
|
const OSD_Entry *entries;
|
||||||
} CMS_Menu;
|
} CMS_Menu;
|
||||||
|
|
||||||
|
|
|
@ -127,12 +127,13 @@ static OSD_Entry menuMainEntries[] =
|
||||||
};
|
};
|
||||||
CMS_Menu menuMain = {
|
CMS_Menu menuMain = {
|
||||||
#ifdef CMS_MENU_DEBUG
|
#ifdef CMS_MENU_DEBUG
|
||||||
"MENUMAIN",
|
.GUARD_text = "MENUMAIN",
|
||||||
OME_MENU,
|
.GUARD_type = OME_MENU,
|
||||||
#endif
|
#endif
|
||||||
NULL,
|
.onEnter = NULL,
|
||||||
NULL,
|
.onExit = NULL,
|
||||||
menuMainEntries,
|
.checkRedirect = NULL,
|
||||||
|
.entries = menuMainEntries,
|
||||||
};
|
};
|
||||||
uint8_t armingFlags;
|
uint8_t armingFlags;
|
||||||
int16_t debug[4];
|
int16_t debug[4];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue