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)
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/>.
27 #if defined(USE_CMS) && defined(USE_VTX_RTC6705)
29 #include "common/printf.h"
30 #include "common/utils.h"
33 #include "cms/cms_types.h"
35 #include "drivers/vtx_common.h"
37 #include "fc/config.h"
39 #include "io/vtx_string.h"
40 #include "io/vtx_rtc6705.h"
43 static uint8_t cmsx_vtxBand
;
44 static uint8_t cmsx_vtxChannel
;
45 static uint8_t cmsx_vtxPower
;
47 static OSD_TAB_t entryVtxBand
= {&cmsx_vtxBand
, VTX_RTC6705_BAND_COUNT
- 1, &vtx58BandNames
[1]};
48 static OSD_UINT8_t entryVtxChannel
= {&cmsx_vtxChannel
, 1, VTX_SETTINGS_CHANNEL_COUNT
, 1};
49 static OSD_TAB_t entryVtxPower
= {&cmsx_vtxPower
, VTX_RTC6705_POWER_COUNT
- 1 - VTX_RTC6705_MIN_POWER
, &rtc6705PowerNames
[VTX_RTC6705_MIN_POWER
]};
51 static void cmsx_Vtx_ConfigRead(void)
53 cmsx_vtxBand
= vtxSettingsConfig()->band
- 1;
54 cmsx_vtxChannel
= vtxSettingsConfig()->channel
;
55 cmsx_vtxPower
= vtxSettingsConfig()->power
- VTX_RTC6705_MIN_POWER
;
58 static void cmsx_Vtx_ConfigWriteback(void)
60 // update vtx_ settings
61 vtxSettingsConfigMutable()->band
= cmsx_vtxBand
+ 1;
62 vtxSettingsConfigMutable()->channel
= cmsx_vtxChannel
;
63 vtxSettingsConfigMutable()->power
= cmsx_vtxPower
+ VTX_RTC6705_MIN_POWER
;
64 vtxSettingsConfigMutable()->freq
= vtx58_Bandchan2Freq(cmsx_vtxBand
+ 1, cmsx_vtxChannel
);
66 saveConfigAndNotify();
69 static long cmsx_Vtx_onEnter(void)
71 cmsx_Vtx_ConfigRead();
76 static long cmsx_Vtx_onExit(const OSD_Entry
*self
)
80 cmsx_Vtx_ConfigWriteback();
86 static OSD_Entry cmsx_menuVtxEntries
[] =
88 {"--- VTX ---", OME_Label
, NULL
, NULL
, 0},
89 {"BAND", OME_TAB
, NULL
, &entryVtxBand
, 0},
90 {"CHANNEL", OME_UINT8
, NULL
, &entryVtxChannel
, 0},
91 {"POWER", OME_TAB
, NULL
, &entryVtxPower
, 0},
92 {"BACK", OME_Back
, NULL
, NULL
, 0},
93 {NULL
, OME_END
, NULL
, NULL
, 0}
96 CMS_Menu cmsx_menuVtxRTC6705
= {
98 .GUARD_text
= "MENUVTX",
99 .GUARD_type
= OME_MENU
,
101 .onEnter
= cmsx_Vtx_onEnter
,
102 .onExit
= cmsx_Vtx_onExit
,
103 .entries
= cmsx_menuVtxEntries