diff --git a/make/source.mk b/make/source.mk index 1a08a027f..c40235a75 100644 --- a/make/source.mk +++ b/make/source.mk @@ -131,6 +131,7 @@ FC_SRC = \ cms/cms_menu_ledstrip.c \ cms/cms_menu_misc.c \ cms/cms_menu_osd.c \ + cms/cms_menu_vtx_rtc6705.c \ common/colorconversion.c \ common/gps_conversion.c \ drivers/display_ug2864hsweg01.c \ diff --git a/src/main/cms/cms_menu_vtx_rtc6705.c b/src/main/cms/cms_menu_vtx_rtc6705.c new file mode 100644 index 000000000..5b12bd1eb --- /dev/null +++ b/src/main/cms/cms_menu_vtx_rtc6705.c @@ -0,0 +1,103 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it 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 is distributed in the hope that it 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 Cleanflight. If not, see . + */ + +#include +#include +#include + +#include "platform.h" + +#ifdef CMS + +#include "common/printf.h" +#include "common/utils.h" + +#include "cms/cms.h" +#include "cms/cms_types.h" + +#include "io/vtx_string.h" +#include "io/vtx_rtc6705.h" + + +static uint8_t cmsx_vtxBand; +static uint8_t cmsx_vtxChannel; +static uint8_t cmsx_vtxPower; + +static const char * const rtc6705BandNames[] = { + "BOSCAM A", + "BOSCAM B", + "BOSCAM E", + "FATSHARK", + "RACEBAND", +}; + +static OSD_TAB_t entryVtxBand = {&cmsx_vtxBand, ARRAYLEN(rtc6705BandNames) - 1, &rtc6705BandNames[0]}; +static OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, 8, 1}; +static OSD_TAB_t entryVtxPower = {&cmsx_vtxPower, RTC6705_POWER_COUNT - 1, &rtc6705PowerNames[0]}; + +static void cmsx_Vtx_ConfigRead(void) +{ + cmsx_vtxBand = vtxRTC6705Config()->band - 1; + cmsx_vtxChannel = vtxRTC6705Config()->channel; + cmsx_vtxPower = vtxRTC6705Config()->power; +} + +static void cmsx_Vtx_ConfigWriteback(void) +{ + vtxRTC6705ConfigMutable()->band = cmsx_vtxBand + 1; + vtxRTC6705ConfigMutable()->channel = cmsx_vtxChannel; + vtxRTC6705ConfigMutable()->power = cmsx_vtxPower; +} + +static long cmsx_Vtx_onEnter(void) +{ + cmsx_Vtx_ConfigRead(); + + return 0; +} + +static long cmsx_Vtx_onExit(const OSD_Entry *self) +{ + UNUSED(self); + + cmsx_Vtx_ConfigWriteback(); + + return 0; +} + + +static OSD_Entry cmsx_menuVtxEntries[] = +{ + {"--- VTX ---", OME_Label, NULL, NULL, 0}, + {"BAND", OME_TAB, NULL, &entryVtxBand, 0}, + {"CHANNEL", OME_UINT8, NULL, &entryVtxChannel, 0}, + {"POWER", OME_TAB, NULL, &entryVtxPower, 0}, + {"BACK", OME_Back, NULL, NULL, 0}, + {NULL, OME_END, NULL, NULL, 0} +}; + +CMS_Menu cmsx_menuVtxRTC6705 = { + .GUARD_text = "MENUVTX", + .GUARD_type = OME_MENU, + .onEnter = cmsx_Vtx_onEnter, + .onExit= cmsx_Vtx_onExit, + .onGlobalExit = NULL, + .entries = cmsx_menuVtxEntries +}; + +#endif // CMS + diff --git a/src/main/cms/cms_menu_vtx_rtc6705.h b/src/main/cms/cms_menu_vtx_rtc6705.h new file mode 100644 index 000000000..6b356a86a --- /dev/null +++ b/src/main/cms/cms_menu_vtx_rtc6705.h @@ -0,0 +1,23 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it 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 is distributed in the hope that it 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 Cleanflight. If not, see . + */ + +#pragma once + +#include "cms/cms.h" +#include "cms/cms_types.h" + +extern CMS_Menu cmsx_menuVtxRTC6705; diff --git a/src/main/io/vtx_rtc6705.c b/src/main/io/vtx_rtc6705.c index b05d399e4..f79e164e1 100644 --- a/src/main/io/vtx_rtc6705.c +++ b/src/main/io/vtx_rtc6705.c @@ -62,11 +62,11 @@ PG_RESET_TEMPLATE(vtxRTC6705Config_t, vtxRTC6705Config, #if defined(CMS) || defined(VTX_COMMON) #ifdef RTC6705_POWER_PIN -static const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = { +const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = { "---", "25 ", "200", }; #else -static const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = { +const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = { "25 ", "200", }; #endif @@ -92,7 +92,7 @@ bool vtxRTC6705Init(void) return true; } -static void vtxRTC6705Configure(void) +void vtxRTC6705Configure(void) { rtc6705SetRFPower(vtxRTC6705.powerIndex - 1); rtc6705SetBandAndChannel(vtxRTC6705.band - 1, vtxRTC6705.channel - 1); @@ -240,74 +240,5 @@ static vtxVTable_t rtc6705VTable = { }; #endif // VTX_COMMON -#ifdef CMS - -static uint8_t cmsx_vtxBand; -static uint8_t cmsx_vtxChannel; -static uint8_t cmsx_vtxPower; - -static const char * const rtc6705BandNames[] = { - "BOSCAM A", - "BOSCAM B", - "BOSCAM E", - "FATSHARK", - "RACEBAND", -}; - -static OSD_TAB_t entryVtxBand = {&cmsx_vtxBand, ARRAYLEN(rtc6705BandNames) - 1, &rtc6705BandNames[0]}; -static OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, 8, 1}; -static OSD_TAB_t entryVtxPower = {&cmsx_vtxPower, RTC6705_POWER_COUNT - 1, &rtc6705PowerNames[0]}; - -static void cmsx_Vtx_ConfigRead(void) -{ - cmsx_vtxBand = vtxRTC6705Config()->band - 1; - cmsx_vtxChannel = vtxRTC6705Config()->channel; - cmsx_vtxPower = vtxRTC6705Config()->power; -} - -static void cmsx_Vtx_ConfigWriteback(void) -{ - vtxRTC6705ConfigMutable()->band = cmsx_vtxBand + 1; - vtxRTC6705ConfigMutable()->channel = cmsx_vtxChannel; - vtxRTC6705ConfigMutable()->power = cmsx_vtxPower; -} - -static long cmsx_Vtx_onEnter(void) -{ - cmsx_Vtx_ConfigRead(); - - return 0; -} - -static long cmsx_Vtx_onExit(const OSD_Entry *self) -{ - UNUSED(self); - - cmsx_Vtx_ConfigWriteback(); - - return 0; -} - - -static OSD_Entry cmsx_menuVtxEntries[] = -{ - {"--- VTX ---", OME_Label, NULL, NULL, 0}, - {"BAND", OME_TAB, NULL, &entryVtxBand, 0}, - {"CHANNEL", OME_UINT8, NULL, &entryVtxChannel, 0}, - {"POWER", OME_TAB, NULL, &entryVtxPower, 0}, - {"BACK", OME_Back, NULL, NULL, 0}, - {NULL, OME_END, NULL, NULL, 0} -}; - -CMS_Menu cmsx_menuVtxRTC6705 = { - .GUARD_text = "MENUVTX", - .GUARD_type = OME_MENU, - .onEnter = cmsx_Vtx_onEnter, - .onExit= cmsx_Vtx_onExit, - .onGlobalExit = NULL, - .entries = cmsx_menuVtxEntries -}; - -#endif // CMS #endif // VTX_RTC6705 diff --git a/src/main/io/vtx_rtc6705.h b/src/main/io/vtx_rtc6705.h index 41646d31a..47dd336d8 100644 --- a/src/main/io/vtx_rtc6705.h +++ b/src/main/io/vtx_rtc6705.h @@ -17,6 +17,11 @@ #pragma once +#include +#include + +#include "config/parameter_group.h" + typedef struct vtxRTC6705Config_s { uint8_t band; // 1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband uint8_t channel; // 1-8 @@ -33,5 +38,8 @@ PG_DECLARE(vtxRTC6705Config_t, vtxRTC6705Config); #define VTX_RTC6705_DEFAULT_POWER 0 #endif +extern const char * const rtc6705PowerNames[RTC6705_POWER_COUNT]; + +void vtxRTC6705Configure(void); bool vtxRTC6705Init();