Split RTC6705 CMS code into separate module

This commit is contained in:
Martin Budden 2017-08-17 15:51:01 +01:00
parent 27b146e274
commit d9b3be0cf7
5 changed files with 138 additions and 72 deletions

View File

@ -131,6 +131,7 @@ FC_SRC = \
cms/cms_menu_ledstrip.c \ cms/cms_menu_ledstrip.c \
cms/cms_menu_misc.c \ cms/cms_menu_misc.c \
cms/cms_menu_osd.c \ cms/cms_menu_osd.c \
cms/cms_menu_vtx_rtc6705.c \
common/colorconversion.c \ common/colorconversion.c \
common/gps_conversion.c \ common/gps_conversion.c \
drivers/display_ug2864hsweg01.c \ drivers/display_ug2864hsweg01.c \

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdint.h>
#include <ctype.h>
#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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "cms/cms.h"
#include "cms/cms_types.h"
extern CMS_Menu cmsx_menuVtxRTC6705;

View File

@ -62,11 +62,11 @@ PG_RESET_TEMPLATE(vtxRTC6705Config_t, vtxRTC6705Config,
#if defined(CMS) || defined(VTX_COMMON) #if defined(CMS) || defined(VTX_COMMON)
#ifdef RTC6705_POWER_PIN #ifdef RTC6705_POWER_PIN
static const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = { const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = {
"---", "25 ", "200", "---", "25 ", "200",
}; };
#else #else
static const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = { const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = {
"25 ", "200", "25 ", "200",
}; };
#endif #endif
@ -92,7 +92,7 @@ bool vtxRTC6705Init(void)
return true; return true;
} }
static void vtxRTC6705Configure(void) void vtxRTC6705Configure(void)
{ {
rtc6705SetRFPower(vtxRTC6705.powerIndex - 1); rtc6705SetRFPower(vtxRTC6705.powerIndex - 1);
rtc6705SetBandAndChannel(vtxRTC6705.band - 1, vtxRTC6705.channel - 1); rtc6705SetBandAndChannel(vtxRTC6705.band - 1, vtxRTC6705.channel - 1);
@ -240,74 +240,5 @@ static vtxVTable_t rtc6705VTable = {
}; };
#endif // VTX_COMMON #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 #endif // VTX_RTC6705

View File

@ -17,6 +17,11 @@
#pragma once #pragma once
#include <stdbool.h>
#include <stdint.h>
#include "config/parameter_group.h"
typedef struct vtxRTC6705Config_s { typedef struct vtxRTC6705Config_s {
uint8_t band; // 1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband uint8_t band; // 1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
uint8_t channel; // 1-8 uint8_t channel; // 1-8
@ -33,5 +38,8 @@ PG_DECLARE(vtxRTC6705Config_t, vtxRTC6705Config);
#define VTX_RTC6705_DEFAULT_POWER 0 #define VTX_RTC6705_DEFAULT_POWER 0
#endif #endif
extern const char * const rtc6705PowerNames[RTC6705_POWER_COUNT];
void vtxRTC6705Configure(void);
bool vtxRTC6705Init(); bool vtxRTC6705Init();