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/>.
24 #include <drivers/vtx_table.h>
28 #if defined(USE_CMS) && defined(USE_VTX_RTC6705)
30 #include "common/printf.h"
31 #include "common/utils.h"
34 #include "cms/cms_types.h"
36 #include "drivers/vtx_common.h"
38 #include "config/config.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
;
46 static uint8_t cmsx_vtxPit
;
48 static OSD_TAB_t entryVtxBand
;
49 static OSD_TAB_t entryVtxChannel
;
50 static OSD_TAB_t entryVtxPower
;
51 static const char * const cmsxCmsPitNames
[] = {
56 static OSD_TAB_t entryVtxPit
= {&cmsx_vtxPit
, 2, cmsxCmsPitNames
};
58 static void cmsx_Vtx_ConfigRead(void)
60 vtxCommonGetBandAndChannel(vtxCommonDevice(), &cmsx_vtxBand
, &cmsx_vtxChannel
);
61 vtxCommonGetPowerIndex(vtxCommonDevice(), &cmsx_vtxPower
);
63 if (vtxCommonGetStatus(vtxCommonDevice(), &status
)) {
64 cmsx_vtxPit
= status
& VTX_STATUS_PIT_MODE
? 2 : 1;
70 static void cmsx_Vtx_ConfigWriteback(void)
72 // update vtx_ settings
73 vtxSettingsConfigMutable()->band
= cmsx_vtxBand
;
74 vtxSettingsConfigMutable()->channel
= cmsx_vtxChannel
;
75 vtxSettingsConfigMutable()->power
= cmsx_vtxPower
;
76 vtxSettingsConfigMutable()->freq
= vtxCommonLookupFrequency(vtxCommonDevice(), cmsx_vtxBand
, cmsx_vtxChannel
);
78 saveConfigAndNotify();
81 static const void *cmsx_Vtx_onEnter(displayPort_t
*pDisp
)
85 cmsx_Vtx_ConfigRead();
87 entryVtxBand
.val
= &cmsx_vtxBand
;
88 entryVtxBand
.max
= vtxTableBandCount
;
89 entryVtxBand
.names
= vtxTableBandNames
;
91 entryVtxChannel
.val
= &cmsx_vtxChannel
;
92 entryVtxChannel
.max
= vtxTableChannelCount
;
93 entryVtxChannel
.names
= vtxTableChannelNames
;
95 entryVtxPower
.val
= &cmsx_vtxPower
;
96 entryVtxPower
.max
= vtxTablePowerLevels
;
97 entryVtxPower
.names
= vtxTablePowerLabels
;
102 static const void *cmsx_Vtx_onExit(displayPort_t
*pDisp
, const OSD_Entry
*self
)
107 vtxCommonSetPitMode(vtxCommonDevice(), cmsx_vtxPit
);
108 cmsx_Vtx_ConfigWriteback();
113 static const void *cmsx_Vtx_onBandChange(displayPort_t
*pDisp
, const void *self
)
117 if (cmsx_vtxBand
== 0) {
123 static const void *cmsx_Vtx_onChanChange(displayPort_t
*pDisp
, const void *self
)
127 if (cmsx_vtxChannel
== 0) {
133 static const void *cmsx_Vtx_onPowerChange(displayPort_t
*pDisp
, const void *self
)
137 if (cmsx_vtxPower
== 0) {
143 static const void *cmsx_Vtx_onPitChange(displayPort_t
*pDisp
, const void *self
)
147 if (cmsx_vtxPit
== 0) {
153 static const OSD_Entry cmsx_menuVtxEntries
[] = {
154 {"--- VTX ---", OME_Label
, NULL
, NULL
},
155 {"BAND", OME_TAB
, cmsx_Vtx_onBandChange
, &entryVtxBand
},
156 {"CHANNEL", OME_TAB
, cmsx_Vtx_onChanChange
, &entryVtxChannel
},
157 {"POWER", OME_TAB
, cmsx_Vtx_onPowerChange
, &entryVtxPower
},
158 {"PIT", OME_TAB
, cmsx_Vtx_onPitChange
, &entryVtxPit
},
159 {"BACK", OME_Back
, NULL
, NULL
},
160 {NULL
, OME_END
, NULL
, NULL
}
163 CMS_Menu cmsx_menuVtxRTC6705
= {
164 #ifdef CMS_MENU_DEBUG
165 .GUARD_text
= "MENUVTX",
166 .GUARD_type
= OME_MENU
,
168 .onEnter
= cmsx_Vtx_onEnter
,
169 .onExit
= cmsx_Vtx_onExit
,
170 .onDisplayUpdate
= NULL
,
171 .entries
= cmsx_menuVtxEntries