Merge pull request #2894 from betaflight/vtx-rtc6705-api
Cleanup VTX api for RTC6705 via SPI and SoftSPI and add button support to SPRACINGF3NEO.
This commit is contained in:
commit
7a453bf4d1
7
Makefile
7
Makefile
|
@ -672,6 +672,7 @@ COMMON_SRC = \
|
|||
drivers/bus_i2c_soft.c \
|
||||
drivers/bus_spi.c \
|
||||
drivers/bus_spi_soft.c \
|
||||
drivers/buttons.c \
|
||||
drivers/display.c \
|
||||
drivers/exti.c \
|
||||
drivers/io.c \
|
||||
|
@ -763,7 +764,6 @@ FC_SRC = \
|
|||
cms/cms_menu_ledstrip.c \
|
||||
cms/cms_menu_misc.c \
|
||||
cms/cms_menu_osd.c \
|
||||
cms/cms_menu_vtx.c \
|
||||
common/colorconversion.c \
|
||||
common/gps_conversion.c \
|
||||
drivers/display_ug2864hsweg01.c \
|
||||
|
@ -794,9 +794,10 @@ FC_SRC = \
|
|||
telemetry/ibus_shared.c \
|
||||
sensors/esc_sensor.c \
|
||||
io/vtx_string.c \
|
||||
io/vtx_rtc6705.c \
|
||||
io/vtx_smartaudio.c \
|
||||
io/vtx_tramp.c \
|
||||
io/vtx.c
|
||||
io/vtx_control.c
|
||||
|
||||
COMMON_DEVICE_SRC = \
|
||||
$(CMSIS_SRC) \
|
||||
|
@ -896,7 +897,7 @@ SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
|
|||
cms/cms_menu_ledstrip.c \
|
||||
cms/cms_menu_misc.c \
|
||||
cms/cms_menu_osd.c \
|
||||
cms/cms_menu_vtx.c \
|
||||
io/vtx_rtc6705.c \
|
||||
io/vtx_smartaudio.c \
|
||||
io/vtx_tramp.c
|
||||
endif #F3
|
||||
|
|
|
@ -40,13 +40,13 @@
|
|||
|
||||
#include "cms/cms_menu_imu.h"
|
||||
#include "cms/cms_menu_blackbox.h"
|
||||
#include "cms/cms_menu_vtx.h"
|
||||
#include "cms/cms_menu_osd.h"
|
||||
#include "cms/cms_menu_ledstrip.h"
|
||||
#include "cms/cms_menu_misc.h"
|
||||
|
||||
// User supplied menus
|
||||
|
||||
#include "io/vtx_rtc6705_cms.h"
|
||||
#include "io/vtx_smartaudio_cms.h"
|
||||
#include "io/vtx_tramp.h"
|
||||
|
||||
|
@ -97,10 +97,10 @@ static OSD_Entry menuFeaturesEntries[] =
|
|||
#if defined(BLACKBOX)
|
||||
{"BLACKBOX", OME_Submenu, cmsMenuChange, &cmsx_menuBlackbox, 0},
|
||||
#endif
|
||||
#if defined(VTX) || defined(USE_RTC6705)
|
||||
{"VTX", OME_Submenu, cmsMenuChange, &cmsx_menuVtx, 0},
|
||||
#endif // VTX || USE_RTC6705
|
||||
#if defined(VTX_CONTROL)
|
||||
#if defined(VTX_RTC6705)
|
||||
{"VTX", OME_Submenu, cmsMenuChange, &cmsx_menuVtxRTC6705, 0},
|
||||
#endif // VTX_RTC6705
|
||||
#if defined(VTX_SMARTAUDIO)
|
||||
{"VTX SA", OME_Submenu, cmsMenuChange, &cmsx_menuVtxSmartAudio, 0},
|
||||
#endif
|
||||
|
|
|
@ -113,7 +113,7 @@ OSD_Entry menuOsdActiveElemsEntries[] =
|
|||
{"FLY MODE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_FLYMODE], 0},
|
||||
{"NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_CRAFT_NAME], 0},
|
||||
{"THROTTLE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_THROTTLE_POS], 0},
|
||||
#ifdef VTX
|
||||
#ifdef VTX_CONTROL
|
||||
{"VTX CHAN", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_VTX_CHANNEL], 0},
|
||||
#endif // VTX
|
||||
{"CURRENT (A)", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_CURRENT_DRAW], 0},
|
||||
|
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
|
||||
#if defined(VTX) || defined(USE_RTC6705)
|
||||
|
||||
#include "build/version.h"
|
||||
|
||||
#include "cms/cms.h"
|
||||
#include "cms/cms_types.h"
|
||||
#include "cms/cms_menu_vtx.h"
|
||||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "config/feature.h"
|
||||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
|
||||
#include "io/vtx.h"
|
||||
|
||||
static bool featureRead = false;
|
||||
static uint8_t cmsx_featureVtx = 0;
|
||||
static uint8_t cmsx_vtxBand;
|
||||
static uint8_t cmsx_vtxChannel;
|
||||
#ifdef VTX
|
||||
static uint8_t cmsx_vtxMode;
|
||||
static uint16_t cmsx_vtxMhz;
|
||||
#endif
|
||||
static bool cmsx_vtxPower;
|
||||
|
||||
static long cmsx_Vtx_FeatureRead(void)
|
||||
{
|
||||
if (!featureRead) {
|
||||
cmsx_featureVtx = feature(FEATURE_VTX) ? 1 : 0;
|
||||
featureRead = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long cmsx_Vtx_FeatureWriteback(void)
|
||||
{
|
||||
if (featureRead) {
|
||||
if (cmsx_featureVtx)
|
||||
featureSet(FEATURE_VTX);
|
||||
else
|
||||
featureClear(FEATURE_VTX);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * const vtxBandNames[] = {
|
||||
"BOSCAM A",
|
||||
"BOSCAM B",
|
||||
"BOSCAM E",
|
||||
"FATSHARK",
|
||||
"RACEBAND",
|
||||
};
|
||||
|
||||
static OSD_TAB_t entryVtxBand = {&cmsx_vtxBand,4,&vtxBandNames[0]};
|
||||
static OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, 8, 1};
|
||||
#ifdef VTX
|
||||
static OSD_UINT8_t entryVtxMode = {&cmsx_vtxMode, 0, 2, 1};
|
||||
static OSD_UINT16_t entryVtxMhz = {&cmsx_vtxMhz, 5600, 5950, 1};
|
||||
#endif // VTX
|
||||
|
||||
static void cmsx_Vtx_ConfigRead(void)
|
||||
{
|
||||
#ifdef VTX
|
||||
cmsx_vtxBand = vtxConfig()->vtx_band;
|
||||
cmsx_vtxChannel = vtxConfig()->vtx_channel + 1;
|
||||
cmsx_vtxMode = vtxConfig()->vtx_mode;
|
||||
cmsx_vtxMhz = vtxConfig()->vtx_mhz;
|
||||
#endif // VTX
|
||||
cmsx_vtxPower = vtxConfig()->vtx_power;
|
||||
|
||||
#ifdef USE_RTC6705
|
||||
cmsx_vtxBand = vtxConfig()->vtx_channel / 8;
|
||||
cmsx_vtxChannel = vtxConfig()->vtx_channel % 8 + 1;
|
||||
#endif // USE_RTC6705
|
||||
}
|
||||
|
||||
static void cmsx_Vtx_ConfigWriteback(void)
|
||||
{
|
||||
#ifdef VTX
|
||||
vtxConfigMutable()->vtx_band = cmsx_vtxBand;
|
||||
vtxConfigMutable()->vtx_channel = cmsx_vtxChannel - 1;
|
||||
vtxConfigMutable()->vtx_mode = cmsx_vtxMode;
|
||||
vtxConfigMutable()->vtx_mhz = cmsx_vtxMhz;
|
||||
#endif // VTX
|
||||
vtxConfigMutable()->vtx_power = cmsx_vtxPower;
|
||||
|
||||
#ifdef USE_RTC6705
|
||||
vtxConfigMutable()->vtx_channel = cmsx_vtxBand * 8 + cmsx_vtxChannel - 1;
|
||||
#endif // USE_RTC6705
|
||||
}
|
||||
|
||||
static long cmsx_Vtx_onEnter(void)
|
||||
{
|
||||
cmsx_Vtx_FeatureRead();
|
||||
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},
|
||||
{"ENABLED", OME_Bool, NULL, &cmsx_featureVtx, 0},
|
||||
#ifdef VTX
|
||||
{"VTX MODE", OME_UINT8, NULL, &entryVtxMode, 0},
|
||||
{"VTX MHZ", OME_UINT16, NULL, &entryVtxMhz, 0},
|
||||
#endif // VTX
|
||||
{"BAND", OME_TAB, NULL, &entryVtxBand, 0},
|
||||
{"CHANNEL", OME_UINT8, NULL, &entryVtxChannel, 0},
|
||||
#ifdef USE_RTC6705
|
||||
{"LOW POWER", OME_Bool, NULL, &cmsx_vtxPower, 0},
|
||||
#endif // USE_RTC6705
|
||||
{"BACK", OME_Back, NULL, NULL, 0},
|
||||
{NULL, OME_END, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
CMS_Menu cmsx_menuVtx = {
|
||||
.GUARD_text = "MENUVTX",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = cmsx_Vtx_onEnter,
|
||||
.onExit= cmsx_Vtx_onExit,
|
||||
.onGlobalExit = cmsx_Vtx_FeatureWriteback,
|
||||
.entries = cmsx_menuVtxEntries
|
||||
};
|
||||
|
||||
#endif // VTX || USE_RTC6705
|
||||
#endif // CMS
|
|
@ -83,6 +83,7 @@
|
|||
#define PG_CURRENT_SENSOR_ADC_CONFIG 256
|
||||
#define PG_CURRENT_SENSOR_VIRTUAL_CONFIG 257
|
||||
#define PG_VOLTAGE_SENSOR_ADC_CONFIG 258
|
||||
#define PG_VTX_RTC6705_CONFIG 259
|
||||
|
||||
|
||||
// betaflight specific parameter group ids start at 500
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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 <string.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "drivers/io.h"
|
||||
|
||||
#include "drivers/buttons.h"
|
||||
|
||||
#if defined(BUTTONS)
|
||||
|
||||
#ifdef BUTTON_A_PIN
|
||||
static IO_t buttonAPin = IO_NONE;
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_B_PIN
|
||||
static IO_t buttonBPin = IO_NONE;
|
||||
#endif
|
||||
|
||||
void buttonsInit(void)
|
||||
{
|
||||
#ifdef BUTTON_A_PIN
|
||||
buttonAPin = IOGetByTag(IO_TAG(BUTTON_A_PIN));
|
||||
IOInit(buttonAPin, OWNER_SYSTEM, 0);
|
||||
IOConfigGPIO(buttonAPin, IOCFG_IPU);
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_B_PIN
|
||||
buttonBPin = IOGetByTag(IO_TAG(BUTTON_B_PIN));
|
||||
IOInit(buttonBPin, OWNER_SYSTEM, 0);
|
||||
IOConfigGPIO(buttonBPin, IOCFG_IPU);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BUTTON_A_PIN
|
||||
bool buttonAPressed(void)
|
||||
{
|
||||
return !IORead(buttonAPin);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_B_PIN
|
||||
bool buttonBPressed(void)
|
||||
{
|
||||
return !IORead(buttonBPin);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -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
|
||||
|
||||
void buttonsInit(void);
|
||||
|
||||
bool buttonAPressed(void);
|
||||
bool buttonBPressed(void);
|
|
@ -441,12 +441,14 @@ void max7456Write(uint8_t x, uint8_t y, const char *buff)
|
|||
screenBuffer[y*CHARS_PER_LINE+x+i] = *(buff+i);
|
||||
}
|
||||
|
||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||
bool max7456DmaInProgres(void)
|
||||
bool max7456DmaInProgress(void)
|
||||
{
|
||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||
return dmaTransactionInProgress;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "build/debug.h"
|
||||
|
||||
|
|
|
@ -45,7 +45,4 @@ void max7456WriteChar(uint8_t x, uint8_t y, uint8_t c);
|
|||
void max7456ClearScreen(void);
|
||||
void max7456RefreshAll(void);
|
||||
uint8_t* max7456GetScreenBuffer(void);
|
||||
|
||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||
bool max7456DmaInProgres(void);
|
||||
#endif // MAX7456_DMA_CHANNEL_TX
|
||||
bool max7456DmaInProgress(void);
|
||||
|
|
|
@ -59,17 +59,17 @@ vtxDevType_e vtxCommonGetDeviceType(void)
|
|||
return vtxDevice->vTable->getDeviceType();
|
||||
}
|
||||
|
||||
// band and chan are 1 origin
|
||||
void vtxCommonSetBandChan(uint8_t band, uint8_t chan)
|
||||
// band and channel are 1 origin
|
||||
void vtxCommonSetBandAndChannel(uint8_t band, uint8_t channel)
|
||||
{
|
||||
if (!vtxDevice)
|
||||
return;
|
||||
|
||||
if ((band > vtxDevice->numBand)|| (chan > vtxDevice->numChan))
|
||||
if ((band > vtxDevice->capability.bandCount) || (channel > vtxDevice->capability.channelCount))
|
||||
return;
|
||||
|
||||
if (vtxDevice->vTable->setBandChan)
|
||||
vtxDevice->vTable->setBandChan(band, chan);
|
||||
if (vtxDevice->vTable->setBandAndChannel)
|
||||
vtxDevice->vTable->setBandAndChannel(band, channel);
|
||||
}
|
||||
|
||||
// index is zero origin, zero = power off completely
|
||||
|
@ -78,7 +78,7 @@ void vtxCommonSetPowerByIndex(uint8_t index)
|
|||
if (!vtxDevice)
|
||||
return;
|
||||
|
||||
if (index > vtxDevice->numPower)
|
||||
if (index > vtxDevice->capability.powerCount)
|
||||
return;
|
||||
|
||||
if (vtxDevice->vTable->setPowerByIndex)
|
||||
|
@ -86,22 +86,22 @@ void vtxCommonSetPowerByIndex(uint8_t index)
|
|||
}
|
||||
|
||||
// on = 1, off = 0
|
||||
void vtxCommonSetPitmode(uint8_t onoff)
|
||||
void vtxCommonSetPitMode(uint8_t onoff)
|
||||
{
|
||||
if (!vtxDevice)
|
||||
return;
|
||||
|
||||
if (vtxDevice->vTable->setPitmode)
|
||||
vtxDevice->vTable->setPitmode(onoff);
|
||||
if (vtxDevice->vTable->setPitMode)
|
||||
vtxDevice->vTable->setPitMode(onoff);
|
||||
}
|
||||
|
||||
bool vtxCommonGetBandChan(uint8_t *pBand, uint8_t *pChan)
|
||||
bool vtxCommonGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
||||
{
|
||||
if (!vtxDevice)
|
||||
return false;
|
||||
|
||||
if (vtxDevice->vTable->getBandChan)
|
||||
return vtxDevice->vTable->getBandChan(pBand, pChan);
|
||||
if (vtxDevice->vTable->getBandAndChannel)
|
||||
return vtxDevice->vTable->getBandAndChannel(pBand, pChannel);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -117,14 +117,23 @@ bool vtxCommonGetPowerIndex(uint8_t *pIndex)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool vtxCommonGetPitmode(uint8_t *pOnoff)
|
||||
bool vtxCommonGetPitMode(uint8_t *pOnOff)
|
||||
{
|
||||
if (!vtxDevice)
|
||||
return false;
|
||||
|
||||
if (vtxDevice->vTable->getPitmode)
|
||||
return vtxDevice->vTable->getPitmode(pOnoff);
|
||||
if (vtxDevice->vTable->getPitMode)
|
||||
return vtxDevice->vTable->getPitMode(pOnOff);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool vtxCommonGetDeviceCapability(vtxDeviceCapability_t *pDeviceCapability)
|
||||
{
|
||||
if (!vtxDevice)
|
||||
return false;
|
||||
|
||||
memcpy(pDeviceCapability, &vtxDevice->capability, sizeof(vtxDeviceCapability_t));
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
typedef enum {
|
||||
VTXDEV_UNSUPPORTED = 0, // reserved for MSP
|
||||
// 1 reserved
|
||||
VTXDEV_RTC6705 = 1,
|
||||
// 2 reserved
|
||||
VTXDEV_SMARTAUDIO = 3,
|
||||
VTXDEV_TRAMP = 4,
|
||||
|
@ -28,41 +28,45 @@ typedef enum {
|
|||
|
||||
struct vtxVTable_s;
|
||||
|
||||
typedef struct vtxDeviceCapability_s {
|
||||
uint8_t bandCount;
|
||||
uint8_t channelCount;
|
||||
uint8_t powerCount;
|
||||
} vtxDeviceCapability_t;
|
||||
|
||||
typedef struct vtxDevice_s {
|
||||
const struct vtxVTable_s *vTable;
|
||||
const struct vtxVTable_s const *vTable;
|
||||
|
||||
uint8_t numBand;
|
||||
uint8_t numChan;
|
||||
uint8_t numPower;
|
||||
vtxDeviceCapability_t capability;
|
||||
|
||||
uint16_t *freqTable; // Array of [numBand][numChan]
|
||||
char **bandNames; // char *bandNames[numBand]
|
||||
char **chanNames; // char *chanNames[numChan]
|
||||
char **powerNames; // char *powerNames[numPower]
|
||||
uint16_t *frequencyTable; // Array of [bandCount][channelCount]
|
||||
char **bandNames; // char *bandNames[bandCount]
|
||||
char **channelNames; // char *channelNames[channelCount]
|
||||
char **powerNames; // char *powerNames[powerCount]
|
||||
|
||||
uint8_t curBand;
|
||||
uint8_t curChan;
|
||||
uint8_t curPowerIndex;
|
||||
uint8_t curPitState; // 0 = non-PIT, 1 = PIT
|
||||
uint8_t band; // Band = 1, 1-based
|
||||
uint8_t channel; // CH1 = 1, 1-based
|
||||
uint8_t powerIndex; // Lowest/Off = 0
|
||||
uint8_t pitMode; // 0 = non-PIT, 1 = PIT
|
||||
|
||||
} vtxDevice_t;
|
||||
|
||||
// {set,get}BandChan: band and chan are 1 origin
|
||||
// {set,get}BandAndChannel: band and channel are 1 origin
|
||||
// {set,get}PowerByIndex: 0 = Power OFF, 1 = device dependent
|
||||
// {set,get}Pitmode: 0 = OFF, 1 = ON
|
||||
// {set,get}PitMode: 0 = OFF, 1 = ON
|
||||
|
||||
typedef struct vtxVTable_s {
|
||||
void (*process)(uint32_t currentTimeUs);
|
||||
vtxDevType_e (*getDeviceType)(void);
|
||||
bool (*isReady)(void);
|
||||
|
||||
void (*setBandChan)(uint8_t band, uint8_t chan);
|
||||
void (*setBandAndChannel)(uint8_t band, uint8_t channel);
|
||||
void (*setPowerByIndex)(uint8_t level);
|
||||
void (*setPitmode)(uint8_t onoff);
|
||||
void (*setPitMode)(uint8_t onoff);
|
||||
|
||||
bool (*getBandChan)(uint8_t *pBand, uint8_t *pChan);
|
||||
bool (*getBandAndChannel)(uint8_t *pBand, uint8_t *pChannel);
|
||||
bool (*getPowerIndex)(uint8_t *pIndex);
|
||||
bool (*getPitmode)(uint8_t *pOnoff);
|
||||
bool (*getPitMode)(uint8_t *pOnOff);
|
||||
} vtxVTable_t;
|
||||
|
||||
// 3.1.0
|
||||
|
@ -76,9 +80,10 @@ void vtxCommonRegisterDevice(vtxDevice_t *pDevice);
|
|||
// VTable functions
|
||||
void vtxCommonProcess(uint32_t currentTimeUs);
|
||||
uint8_t vtxCommonGetDeviceType(void);
|
||||
void vtxCommonSetBandChan(uint8_t band, uint8_t chan);
|
||||
void vtxCommonSetBandAndChannel(uint8_t band, uint8_t channel);
|
||||
void vtxCommonSetPowerByIndex(uint8_t level);
|
||||
void vtxCommonSetPitmode(uint8_t onoff);
|
||||
bool vtxCommonGetBandChan(uint8_t *pBand, uint8_t *pChan);
|
||||
void vtxCommonSetPitMode(uint8_t onoff);
|
||||
bool vtxCommonGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel);
|
||||
bool vtxCommonGetPowerIndex(uint8_t *pIndex);
|
||||
bool vtxCommonGetPitmode(uint8_t *pOnoff);
|
||||
bool vtxCommonGetPitMode(uint8_t *pOnOff);
|
||||
bool vtxCommonGetDeviceCapability(vtxDeviceCapability_t *pDeviceCapability);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef VTX
|
||||
#if defined(VTX_RTC6705) && !defined(VTX_RTC6705SOFTSPI)
|
||||
|
||||
#include "common/maths.h"
|
||||
|
||||
|
@ -84,19 +84,39 @@
|
|||
#define RTC6705_SET_WRITE 0x11 //10001b to write to register
|
||||
#define RTC6705_SET_DIVMULT 1000000 //Division value (to fit into a uint32_t) (Hz to MHz)
|
||||
|
||||
#define DISABLE_RTC6705 GPIO_SetBits(RTC6705_CS_GPIO, RTC6705_CS_PIN)
|
||||
#define ENABLE_RTC6705 GPIO_ResetBits(RTC6705_CS_GPIO, RTC6705_CS_PIN)
|
||||
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
static IO_t vtxPowerPin = IO_NONE;
|
||||
static IO_t vtxPowerPin = IO_NONE;
|
||||
#endif
|
||||
static IO_t vtxCSPin = IO_NONE;
|
||||
|
||||
#define DISABLE_RTC6705() IOHi(vtxCSPin)
|
||||
|
||||
#ifdef USE_RTC6705_CLK_HACK
|
||||
static IO_t vtxCLKPin = IO_NONE;
|
||||
// HACK for missing pull up on CLK line - drive the CLK high *before* enabling the CS pin.
|
||||
#define ENABLE_RTC6705() {IOHi(vtxCLKPin); delayMicroseconds(5); IOLo(vtxCSPin); }
|
||||
#else
|
||||
#define ENABLE_RTC6705() IOLo(vtxCSPin)
|
||||
#endif
|
||||
|
||||
#define ENABLE_VTX_POWER IOLo(vtxPowerPin)
|
||||
#define DISABLE_VTX_POWER IOHi(vtxPowerPin)
|
||||
#define DP_5G_MASK 0x7000 // b111000000000000
|
||||
#define PA5G_BS_MASK 0x0E00 // b000111000000000
|
||||
#define PA5G_PW_MASK 0x0180 // b000000110000000
|
||||
#define PD_Q5G_MASK 0x0040 // b000000001000000
|
||||
#define QI_5G_MASK 0x0038 // b000000000111000
|
||||
#define PA_BS_MASK 0x0007 // b000000000000111
|
||||
|
||||
#define PA_CONTROL_DEFAULT 0x4FBD
|
||||
|
||||
#define RTC6705_RW_CONTROL_BIT (1 << 4)
|
||||
#define RTC6705_ADDRESS (0x07)
|
||||
|
||||
#define ENABLE_VTX_POWER() IOLo(vtxPowerPin)
|
||||
#define DISABLE_VTX_POWER() IOHi(vtxPowerPin)
|
||||
|
||||
|
||||
// Define variables
|
||||
static const uint32_t channelArray[RTC6705_BAND_MAX][RTC6705_CHANNEL_MAX] = {
|
||||
static const uint32_t channelArray[RTC6705_BAND_COUNT][RTC6705_CHANNEL_COUNT] = {
|
||||
{ RTC6705_SET_A1, RTC6705_SET_A2, RTC6705_SET_A3, RTC6705_SET_A4, RTC6705_SET_A5, RTC6705_SET_A6, RTC6705_SET_A7, RTC6705_SET_A8 },
|
||||
{ RTC6705_SET_B1, RTC6705_SET_B2, RTC6705_SET_B3, RTC6705_SET_B4, RTC6705_SET_B5, RTC6705_SET_B6, RTC6705_SET_B7, RTC6705_SET_B8 },
|
||||
{ RTC6705_SET_E1, RTC6705_SET_E2, RTC6705_SET_E3, RTC6705_SET_E4, RTC6705_SET_E5, RTC6705_SET_E6, RTC6705_SET_E7, RTC6705_SET_E8 },
|
||||
|
@ -104,20 +124,6 @@ static const uint32_t channelArray[RTC6705_BAND_MAX][RTC6705_CHANNEL_MAX] = {
|
|||
{ RTC6705_SET_R1, RTC6705_SET_R2, RTC6705_SET_R3, RTC6705_SET_R4, RTC6705_SET_R5, RTC6705_SET_R6, RTC6705_SET_R7, RTC6705_SET_R8 },
|
||||
};
|
||||
|
||||
/**
|
||||
* Send a command and return if good
|
||||
* TODO chip detect
|
||||
*/
|
||||
static bool rtc6705IsReady(void)
|
||||
{
|
||||
// Sleep a little bit to make sure it has booted
|
||||
delay(50);
|
||||
|
||||
// TODO Do a read and get current config (note this would be reading on MOSI (data) line)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse a uint32_t (LSB to MSB)
|
||||
* This is easier for when generating the frequency to then
|
||||
|
@ -139,19 +145,29 @@ static uint32_t reverse32(uint32_t in)
|
|||
* Start chip if available
|
||||
*/
|
||||
|
||||
bool rtc6705Init(void)
|
||||
void rtc6705IOInit(void)
|
||||
{
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
|
||||
vtxPowerPin = IOGetByTag(IO_TAG(RTC6705_POWER_PIN));
|
||||
IOInit(vtxPowerPin, OWNER_VTX, 0);
|
||||
IOConfigGPIO(vtxPowerPin, IOCFG_OUT_PP);
|
||||
|
||||
ENABLE_VTX_POWER;
|
||||
DISABLE_VTX_POWER();
|
||||
IOConfigGPIO(vtxPowerPin, IOCFG_OUT_PP);
|
||||
#endif
|
||||
|
||||
DISABLE_RTC6705;
|
||||
spiSetDivisor(RTC6705_SPI_INSTANCE, SPI_CLOCK_SLOW);
|
||||
return rtc6705IsReady();
|
||||
#ifdef USE_RTC6705_CLK_HACK
|
||||
vtxCLKPin = IOGetByTag(IO_TAG(RTC6705_CLK_PIN));
|
||||
// we assume the CLK pin will have been initialised by the SPI code.
|
||||
#endif
|
||||
|
||||
vtxCSPin = IOGetByTag(IO_TAG(RTC6705_CS_PIN));
|
||||
IOInit(vtxCSPin, OWNER_VTX, 0);
|
||||
|
||||
DISABLE_RTC6705();
|
||||
// GPIO bit is enabled so here so the output is not pulled low when the GPIO is set in output mode.
|
||||
// Note: It's critical to ensure that incorrect signals are not sent to the VTX.
|
||||
IOConfigGPIO(vtxCSPin, IOCFG_OUT_PP);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,47 +179,84 @@ static void rtc6705Transfer(uint32_t command)
|
|||
{
|
||||
command = reverse32(command);
|
||||
|
||||
ENABLE_RTC6705;
|
||||
ENABLE_RTC6705();
|
||||
|
||||
spiTransferByte(RTC6705_SPI_INSTANCE, (command >> 24) & 0xFF);
|
||||
spiTransferByte(RTC6705_SPI_INSTANCE, (command >> 16) & 0xFF);
|
||||
spiTransferByte(RTC6705_SPI_INSTANCE, (command >> 8) & 0xFF);
|
||||
spiTransferByte(RTC6705_SPI_INSTANCE, (command >> 0) & 0xFF);
|
||||
|
||||
DISABLE_RTC6705;
|
||||
delayMicroseconds(2);
|
||||
|
||||
DISABLE_RTC6705();
|
||||
|
||||
delayMicroseconds(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a band and channel
|
||||
*/
|
||||
void rtc6705SetChannel(uint8_t band, uint8_t channel)
|
||||
void rtc6705SetBandAndChannel(uint8_t band, uint8_t channel)
|
||||
{
|
||||
band = constrain(band, RTC6705_BAND_MIN, RTC6705_BAND_MAX);
|
||||
channel = constrain(channel, RTC6705_CHANNEL_MIN, RTC6705_CHANNEL_MAX);
|
||||
band = constrain(band, 0, RTC6705_BAND_COUNT - 1);
|
||||
channel = constrain(channel, 0, RTC6705_CHANNEL_COUNT - 1);
|
||||
|
||||
spiSetDivisor(RTC6705_SPI_INSTANCE, SPI_CLOCK_SLOW);
|
||||
|
||||
rtc6705Transfer(RTC6705_SET_HEAD);
|
||||
rtc6705Transfer(channelArray[band-1][channel-1]);
|
||||
rtc6705Transfer(channelArray[band][channel]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a freq in mhz
|
||||
* Formula derived from datasheet
|
||||
*/
|
||||
void rtc6705SetFreq(uint16_t freq)
|
||||
void rtc6705SetFreq(uint16_t frequency)
|
||||
{
|
||||
freq = constrain(freq, RTC6705_FREQ_MIN, RTC6705_FREQ_MAX);
|
||||
frequency = constrain(frequency, RTC6705_FREQ_MIN, RTC6705_FREQ_MAX);
|
||||
|
||||
uint32_t val_hex = 0;
|
||||
|
||||
uint32_t val_a = ((((uint64_t)freq*(uint64_t)RTC6705_SET_DIVMULT*(uint64_t)RTC6705_SET_R)/(uint64_t)RTC6705_SET_DIVMULT) % RTC6705_SET_FDIV) / RTC6705_SET_NDIV; //Casts required to make sure correct math (large numbers)
|
||||
uint32_t val_n = (((uint64_t)freq*(uint64_t)RTC6705_SET_DIVMULT*(uint64_t)RTC6705_SET_R)/(uint64_t)RTC6705_SET_DIVMULT) / RTC6705_SET_FDIV; //Casts required to make sure correct math (large numbers)
|
||||
uint32_t val_a = ((((uint64_t)frequency*(uint64_t)RTC6705_SET_DIVMULT*(uint64_t)RTC6705_SET_R)/(uint64_t)RTC6705_SET_DIVMULT) % RTC6705_SET_FDIV) / RTC6705_SET_NDIV; //Casts required to make sure correct math (large numbers)
|
||||
uint32_t val_n = (((uint64_t)frequency*(uint64_t)RTC6705_SET_DIVMULT*(uint64_t)RTC6705_SET_R)/(uint64_t)RTC6705_SET_DIVMULT) / RTC6705_SET_FDIV; //Casts required to make sure correct math (large numbers)
|
||||
|
||||
val_hex |= RTC6705_SET_WRITE;
|
||||
val_hex |= (val_a << 5);
|
||||
val_hex |= (val_n << 12);
|
||||
|
||||
spiSetDivisor(RTC6705_SPI_INSTANCE, SPI_CLOCK_SLOW);
|
||||
|
||||
rtc6705Transfer(RTC6705_SET_HEAD);
|
||||
delayMicroseconds(10);
|
||||
rtc6705Transfer(val_hex);
|
||||
}
|
||||
|
||||
void rtc6705SetRFPower(uint8_t rf_power)
|
||||
{
|
||||
rf_power = constrain(rf_power, 0, RTC6705_RF_POWER_COUNT - 1);
|
||||
|
||||
spiSetDivisor(RTC6705_SPI_INSTANCE, SPI_CLOCK_SLOW);
|
||||
|
||||
uint32_t val_hex = RTC6705_RW_CONTROL_BIT; // write
|
||||
val_hex |= RTC6705_ADDRESS; // address
|
||||
uint32_t data = rf_power == 0 ? (PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK)) : PA_CONTROL_DEFAULT;
|
||||
val_hex |= data << 5; // 4 address bits and 1 rw bit.
|
||||
|
||||
rtc6705Transfer(val_hex);
|
||||
}
|
||||
|
||||
void rtc6705Disable(void)
|
||||
{
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
DISABLE_VTX_POWER();
|
||||
#endif
|
||||
}
|
||||
|
||||
void rtc6705Enable(void)
|
||||
{
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
ENABLE_VTX_POWER();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,13 +26,18 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define RTC6705_BAND_MIN 1
|
||||
#define RTC6705_BAND_MAX 5
|
||||
#define RTC6705_CHANNEL_MIN 1
|
||||
#define RTC6705_CHANNEL_MAX 8
|
||||
#define RTC6705_FREQ_MIN 5600
|
||||
#define RTC6705_FREQ_MAX 5950
|
||||
#define RTC6705_BAND_COUNT 5
|
||||
#define RTC6705_CHANNEL_COUNT 8
|
||||
#define RTC6705_RF_POWER_COUNT 2
|
||||
|
||||
bool rtc6705Init(void);
|
||||
void rtc6705SetChannel(uint8_t band, uint8_t channel);
|
||||
void rtc6705SetFreq(uint16_t freq);
|
||||
#define RTC6705_FREQ_MIN 5600
|
||||
#define RTC6705_FREQ_MAX 5950
|
||||
|
||||
#define RTC6705_BOOT_DELAY 350 // milliseconds
|
||||
|
||||
void rtc6705IOInit(void);
|
||||
void rtc6705SetBandAndChannel(const uint8_t band, const uint8_t channel);
|
||||
void rtc6705SetFreq(const uint16_t freq);
|
||||
void rtc6705SetRFPower(const uint8_t rf_power);
|
||||
void rtc6705Disable(void);
|
||||
void rtc6705Enable(void);
|
||||
|
|
|
@ -20,14 +20,23 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_RTC6705
|
||||
#if defined(VTX_RTC6705) && defined(VTX_RTC6705SOFTSPI)
|
||||
|
||||
#include "drivers/bus_spi.h"
|
||||
#include "drivers/io.h"
|
||||
#include "drivers/system.h"
|
||||
#include "light_led.h"
|
||||
|
||||
#include "vtx_soft_spi_rtc6705.h"
|
||||
#include "vtx_rtc6705.h"
|
||||
|
||||
#define DP_5G_MASK 0x7000
|
||||
#define PA5G_BS_MASK 0x0E00
|
||||
#define PA5G_PW_MASK 0x0180
|
||||
#define PD_Q5G_MASK 0x0040
|
||||
#define QI_5G_MASK 0x0038
|
||||
#define PA_BS_MASK 0x0007
|
||||
|
||||
#define PA_CONTROL_DEFAULT 0x4FBD
|
||||
|
||||
#define RTC6705_SPICLK_ON IOHi(rtc6705ClkPin)
|
||||
#define RTC6705_SPICLK_OFF IOLo(rtc6705ClkPin)
|
||||
|
@ -47,13 +56,11 @@ const uint16_t vtx_freq[] =
|
|||
5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917, // RaceBand
|
||||
};
|
||||
|
||||
uint16_t current_vtx_channel;
|
||||
|
||||
static IO_t rtc6705DataPin = IO_NONE;
|
||||
static IO_t rtc6705LePin = IO_NONE;
|
||||
static IO_t rtc6705ClkPin = IO_NONE;
|
||||
|
||||
void rtc6705_soft_spi_init(void)
|
||||
void rtc6705IOInit(void)
|
||||
{
|
||||
rtc6705DataPin = IOGetByTag(IO_TAG(RTC6705_SPIDATA_PIN));
|
||||
rtc6705LePin = IOGetByTag(IO_TAG(RTC6705_SPILE_PIN));
|
||||
|
@ -107,10 +114,8 @@ static void rtc6705_write_register(uint8_t addr, uint32_t data)
|
|||
RTC6705_SPILE_ON;
|
||||
}
|
||||
|
||||
|
||||
void rtc6705_soft_spi_set_channel(uint16_t channel_freq)
|
||||
void rtc6705SetFreq(uint16_t channel_freq)
|
||||
{
|
||||
|
||||
uint32_t freq = (uint32_t)channel_freq * 1000;
|
||||
uint32_t N, A;
|
||||
|
||||
|
@ -121,9 +126,31 @@ void rtc6705_soft_spi_set_channel(uint16_t channel_freq)
|
|||
rtc6705_write_register(1, (N << 7) | A);
|
||||
}
|
||||
|
||||
void rtc6705_soft_spi_set_rf_power(uint8_t reduce_power)
|
||||
void rtc6705SetBandAndChannel(const uint8_t band, const uint8_t channel)
|
||||
{
|
||||
// band and channel are 1-based, not 0-based
|
||||
|
||||
// example for raceband/ch8:
|
||||
// (5 - 1) * 8 + (8 - 1)
|
||||
// 4 * 8 + 7
|
||||
// 32 + 7 = 39
|
||||
uint8_t freqIndex = ((band - 1) * RTC6705_BAND_COUNT) + (channel - 1);
|
||||
|
||||
uint16_t freq = vtx_freq[freqIndex];
|
||||
rtc6705SetFreq(freq);
|
||||
}
|
||||
|
||||
void rtc6705SetRFPower(const uint8_t rf_power)
|
||||
{
|
||||
rtc6705_write_register(7, (rf_power ? PA_CONTROL_DEFAULT : (PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK))));
|
||||
}
|
||||
|
||||
void rtc6705Disable(void)
|
||||
{
|
||||
}
|
||||
|
||||
void rtc6705Enable(void)
|
||||
{
|
||||
rtc6705_write_register(7, (reduce_power ? (PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK)) : PA_CONTROL_DEFAULT));
|
||||
}
|
||||
|
||||
#endif
|
|
@ -100,7 +100,8 @@ extern uint8_t __config_end;
|
|||
#include "io/ledstrip.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/vtx.h"
|
||||
#include "io/vtx_rtc6705.h"
|
||||
#include "io/vtx_control.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/spektrum.h"
|
||||
|
@ -864,15 +865,10 @@ static const clivalue_t valueTable[] = {
|
|||
{ "debug_mode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DEBUG }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, debug_mode) },
|
||||
|
||||
// PG_VTX_CONFIG
|
||||
#ifdef VTX
|
||||
{ "vtx_band", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 1, 5 }, PG_VTX_CONFIG, offsetof(vtxConfig_t, vtx_band) },
|
||||
{ "vtx_channel", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 1, 8 }, PG_VTX_CONFIG, offsetof(vtxConfig_t, vtx_channel) },
|
||||
{ "vtx_mode", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 2 }, PG_VTX_CONFIG, offsetof(vtxConfig_t, vtx_mode) },
|
||||
{ "vtx_mhz", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 5600, 5950 }, PG_VTX_CONFIG, offsetof(vtxConfig_t, vtx_mhz) },
|
||||
#endif
|
||||
#if defined(USE_RTC6705)
|
||||
{ "vtx_channel", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 39 }, PG_VTX_CONFIG, offsetof(vtxConfig_t, vtx_channel) },
|
||||
{ "vtx_power", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 1 }, PG_VTX_CONFIG, offsetof(vtxConfig_t, vtx_power) },
|
||||
#ifdef VTX_RTC6705
|
||||
{ "vtx_band", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 1, 5 }, PG_VTX_RTC6705_CONFIG, offsetof(vtxRTC6705Config_t, band) },
|
||||
{ "vtx_channel", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 1, 8 }, PG_VTX_RTC6705_CONFIG, offsetof(vtxRTC6705Config_t, channel) },
|
||||
{ "vtx_power", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, RTC6705_POWER_COUNT - 1 }, PG_VTX_RTC6705_CONFIG, offsetof(vtxRTC6705Config_t, power) },
|
||||
#endif
|
||||
|
||||
// PG_VCD_CONFIG
|
||||
|
@ -965,7 +961,10 @@ static systemConfig_t systemConfigCopy;
|
|||
static beeperDevConfig_t beeperDevConfigCopy;
|
||||
static beeperConfig_t beeperConfigCopy;
|
||||
#endif
|
||||
#if defined(USE_RTC6705) || defined(VTX)
|
||||
#ifdef VTX_RTC6705
|
||||
static vtxRTC6705Config_t vtxRTC6705ConfigCopy;
|
||||
#endif
|
||||
#ifdef VTX_CONTROL
|
||||
static vtxConfig_t vtxConfigCopy;
|
||||
#endif
|
||||
#ifdef USE_MAX7456
|
||||
|
@ -1336,7 +1335,13 @@ static const cliCurrentAndDefaultConfig_t *getCurrentAndDefaultConfigs(pgn_t pgn
|
|||
ret.defaultConfig = beeperDevConfig();
|
||||
break;
|
||||
#endif
|
||||
#ifdef VTX
|
||||
#ifdef VTX_RTC6705
|
||||
case PG_VTX_RTC6705_CONFIG:
|
||||
ret.currentConfig = &vtxRTC6705ConfigCopy;
|
||||
ret.defaultConfig = vtxRTC6705Config();
|
||||
break;
|
||||
#endif
|
||||
#ifdef VTX_CONTROL
|
||||
case PG_VTX_CONFIG:
|
||||
ret.currentConfig = &vtxConfigCopy;
|
||||
ret.defaultConfig = vtxConfig();
|
||||
|
@ -2810,7 +2815,7 @@ static void cliFlashRead(char *cmdline)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_RTC6705) || defined(VTX)
|
||||
#ifdef VTX_CONTROL
|
||||
static void printVtx(uint8_t dumpMask, const vtxConfig_t *vtxConfig, const vtxConfig_t *vtxConfigDefault)
|
||||
{
|
||||
// print out vtx channel settings
|
||||
|
@ -2845,7 +2850,12 @@ static void printVtx(uint8_t dumpMask, const vtxConfig_t *vtxConfig, const vtxCo
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef VTX
|
||||
// FIXME remove these and use the VTX API
|
||||
#define VTX_BAND_MIN 1
|
||||
#define VTX_BAND_MAX 5
|
||||
#define VTX_CHANNEL_MIN 1
|
||||
#define VTX_CHANNEL_MAX 8
|
||||
|
||||
static void cliVtx(char *cmdline)
|
||||
{
|
||||
int i, val = 0;
|
||||
|
@ -2870,6 +2880,7 @@ static void cliVtx(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
// FIXME Use VTX API to get min/max
|
||||
if (val >= VTX_BAND_MIN && val <= VTX_BAND_MAX) {
|
||||
cac->band = val;
|
||||
validArgumentCount++;
|
||||
|
@ -2878,6 +2889,7 @@ static void cliVtx(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
// FIXME Use VTX API to get min/max
|
||||
if (val >= VTX_CHANNEL_MIN && val <= VTX_CHANNEL_MAX) {
|
||||
cac->channel = val;
|
||||
validArgumentCount++;
|
||||
|
@ -2893,8 +2905,8 @@ static void cliVtx(char *cmdline)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // VTX
|
||||
#endif
|
||||
|
||||
#endif // VTX_CONTROL
|
||||
|
||||
static void printName(uint8_t dumpMask, const systemConfig_t *systemConfig)
|
||||
{
|
||||
|
@ -4140,7 +4152,7 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
cliPrintHashLine("rxrange");
|
||||
printRxRange(dumpMask, rxChannelRangeConfigsCopy, rxChannelRangeConfigs(0));
|
||||
|
||||
#if defined(USE_RTC6705) || defined(VTX)
|
||||
#ifdef VTX_CONTROL
|
||||
cliPrintHashLine("vtx");
|
||||
printVtx(dumpMask, &vtxConfigCopy, vtxConfig());
|
||||
#endif
|
||||
|
@ -4311,7 +4323,7 @@ const clicmd_t cmdTable[] = {
|
|||
CLI_COMMAND_DEF("tasks", "show task stats", NULL, cliTasks),
|
||||
#endif
|
||||
CLI_COMMAND_DEF("version", "show version", NULL, cliVersion),
|
||||
#ifdef VTX
|
||||
#ifdef VTX_CONTROL
|
||||
CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL, cliVtx),
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
#include "io/osd.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/servos.h"
|
||||
#include "io/vtx.h"
|
||||
#include "io/vtx_control.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/rx_spi.h"
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef enum {
|
|||
FEATURE_TRANSPONDER = 1 << 21,
|
||||
FEATURE_AIRMODE = 1 << 22,
|
||||
FEATURE_SDCARD_UNUSED = 1 << 23,
|
||||
FEATURE_VTX = 1 << 24,
|
||||
//FEATURE_VTX = 1 << 24,
|
||||
FEATURE_RX_SPI = 1 << 25,
|
||||
FEATURE_SOFTSPI = 1 << 26,
|
||||
FEATURE_ESC_SENSOR = 1 << 27,
|
||||
|
|
|
@ -63,8 +63,7 @@
|
|||
#include "io/serial.h"
|
||||
#include "io/statusindicator.h"
|
||||
#include "io/transponder_ir.h"
|
||||
#include "io/vtx.h"
|
||||
|
||||
#include "io/vtx_control.h"
|
||||
#include "rx/rx.h"
|
||||
|
||||
#include "scheduler/scheduler.h"
|
||||
|
@ -82,6 +81,13 @@
|
|||
|
||||
// June 2013 V2.2-dev
|
||||
|
||||
#ifdef VTX_RTC6705
|
||||
bool canUpdateVTX(void);
|
||||
#define VTX_IF_READY if (canUpdateVTX())
|
||||
#else
|
||||
#define VTX_IF_READY
|
||||
#endif
|
||||
|
||||
enum {
|
||||
ALIGN_GYRO = 0,
|
||||
ALIGN_ACCEL = 1,
|
||||
|
@ -469,8 +475,12 @@ void processRx(timeUs_t currentTimeUs)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef VTX
|
||||
#ifdef VTX_CONTROL
|
||||
vtxUpdateActivatedChannel();
|
||||
|
||||
VTX_IF_READY {
|
||||
handleVTXControlButton();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "drivers/adc.h"
|
||||
#include "drivers/bus_i2c.h"
|
||||
#include "drivers/bus_spi.h"
|
||||
#include "drivers/buttons.h"
|
||||
#include "drivers/inverter.h"
|
||||
#include "drivers/flash_m25p16.h"
|
||||
#include "drivers/sonar_hcsr04.h"
|
||||
|
@ -62,7 +63,9 @@
|
|||
#include "drivers/usb_io.h"
|
||||
#include "drivers/transponder_ir.h"
|
||||
#include "drivers/exti.h"
|
||||
#include "drivers/vtx_soft_spi_rtc6705.h"
|
||||
#include "drivers/max7456.h"
|
||||
#include "drivers/vtx_rtc6705.h"
|
||||
#include "drivers/vtx_common.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
#include "fc/fc_init.h"
|
||||
|
@ -92,7 +95,8 @@
|
|||
#include "io/osd.h"
|
||||
#include "io/osd_slave.h"
|
||||
#include "io/displayport_msp.h"
|
||||
#include "io/vtx.h"
|
||||
#include "io/vtx_rtc6705.h"
|
||||
#include "io/vtx_control.h"
|
||||
#include "io/vtx_smartaudio.h"
|
||||
#include "io/vtx_tramp.h"
|
||||
|
||||
|
@ -156,6 +160,18 @@ void processLoopback(void)
|
|||
}
|
||||
|
||||
|
||||
#ifdef VTX_RTC6705
|
||||
bool canUpdateVTX(void)
|
||||
{
|
||||
#if defined(MAX7456_SPI_INSTANCE) && defined(RTC6705_SPI_INSTANCE) && defined(SPI_SHARED_MAX7456_AND_RTC6705)
|
||||
if (feature(FEATURE_OSD)) {
|
||||
return !max7456DmaInProgress();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BUS_SWITCH_PIN
|
||||
void busSwitchInit(void)
|
||||
{
|
||||
|
@ -217,17 +233,8 @@ void init(void)
|
|||
#endif
|
||||
|
||||
#if defined(BUTTONS)
|
||||
#ifdef BUTTON_A_PIN
|
||||
IO_t buttonAPin = IOGetByTag(IO_TAG(BUTTON_A_PIN));
|
||||
IOInit(buttonAPin, OWNER_SYSTEM, 0);
|
||||
IOConfigGPIO(buttonAPin, IOCFG_IPU);
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_B_PIN
|
||||
IO_t buttonBPin = IOGetByTag(IO_TAG(BUTTON_B_PIN));
|
||||
IOInit(buttonBPin, OWNER_SYSTEM, 0);
|
||||
IOConfigGPIO(buttonBPin, IOCFG_IPU);
|
||||
#endif
|
||||
buttonsInit();
|
||||
|
||||
// Check status of bind plug and exit if not active
|
||||
delayMicroseconds(10); // allow configuration to settle
|
||||
|
@ -238,7 +245,7 @@ void init(void)
|
|||
uint8_t secondsRemaining = 5;
|
||||
bool bothButtonsHeld;
|
||||
do {
|
||||
bothButtonsHeld = !IORead(buttonAPin) && !IORead(buttonBPin);
|
||||
bothButtonsHeld = buttonAPressed() && buttonBPressed();
|
||||
if (bothButtonsHeld) {
|
||||
if (--secondsRemaining == 0) {
|
||||
resetEEPROM();
|
||||
|
@ -375,8 +382,8 @@ void init(void)
|
|||
updateHardwareRevision();
|
||||
#endif
|
||||
|
||||
#ifdef VTX
|
||||
vtxInit();
|
||||
#ifdef VTX_RTC6705
|
||||
rtc6705IOInit();
|
||||
#endif
|
||||
|
||||
#if defined(SONAR_SOFTSERIAL2_EXCLUSIVE) && defined(SONAR) && defined(USE_SOFTSERIAL2)
|
||||
|
@ -439,19 +446,6 @@ void init(void)
|
|||
|
||||
rxInit();
|
||||
|
||||
/*
|
||||
* VTX
|
||||
*/
|
||||
|
||||
#ifdef USE_RTC6705
|
||||
if (feature(FEATURE_VTX)) {
|
||||
rtc6705_soft_spi_init();
|
||||
current_vtx_channel = vtxConfig()->vtx_channel;
|
||||
rtc6705_soft_spi_set_channel(vtx_freq[current_vtx_channel]);
|
||||
rtc6705_soft_spi_set_rf_power(vtxConfig()->vtx_power);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CMS, display devices and OSD
|
||||
*/
|
||||
|
@ -568,13 +562,25 @@ void init(void)
|
|||
#endif
|
||||
|
||||
#ifdef VTX_CONTROL
|
||||
vtxControlInit();
|
||||
|
||||
vtxCommonInit();
|
||||
|
||||
#ifdef VTX_SMARTAUDIO
|
||||
smartAudioInit();
|
||||
vtxSmartAudioInit();
|
||||
#endif
|
||||
|
||||
#ifdef VTX_TRAMP
|
||||
trampInit();
|
||||
vtxTrampInit();
|
||||
#endif
|
||||
|
||||
#ifdef VTX_RTC6705
|
||||
#ifdef VTX_RTC6705OPTIONAL
|
||||
if (!vtxCommonDeviceRegistered()) // external VTX takes precedence when configured.
|
||||
#endif
|
||||
{
|
||||
vtxRTC6705Init();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // VTX_CONTROL
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#include "drivers/system.h"
|
||||
#include "drivers/vcd.h"
|
||||
#include "drivers/vtx_common.h"
|
||||
#include "drivers/vtx_soft_spi_rtc6705.h"
|
||||
#include "drivers/transponder_ir.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
#include "fc/controlrate_profile.h"
|
||||
|
@ -82,7 +82,7 @@
|
|||
#include "io/serial_4way.h"
|
||||
#include "io/servos.h"
|
||||
#include "io/transponder_ir.h"
|
||||
#include "io/vtx.h"
|
||||
#include "io/vtx_control.h"
|
||||
|
||||
#include "msp/msp.h"
|
||||
#include "msp/msp_protocol.h"
|
||||
|
@ -1300,13 +1300,13 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
if (deviceType != VTXDEV_UNKNOWN) {
|
||||
|
||||
uint8_t band=0, channel=0;
|
||||
vtxCommonGetBandChan(&band,&channel);
|
||||
vtxCommonGetBandAndChannel(&band,&channel);
|
||||
|
||||
uint8_t powerIdx=0; // debug
|
||||
vtxCommonGetPowerIndex(&powerIdx);
|
||||
|
||||
uint8_t pitmode=0;
|
||||
vtxCommonGetPitmode(&pitmode);
|
||||
vtxCommonGetPitMode(&pitmode);
|
||||
|
||||
sbufWriteU8(dst, deviceType);
|
||||
sbufWriteU8(dst, band);
|
||||
|
@ -1717,27 +1717,18 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#if defined(USE_RTC6705) || defined(VTX_COMMON)
|
||||
#ifdef VTX_COMMON
|
||||
case MSP_SET_VTX_CONFIG:
|
||||
{
|
||||
uint16_t tmp = sbufReadU16(src);
|
||||
#if defined(USE_RTC6705)
|
||||
if (tmp < 40)
|
||||
vtxConfigMutable()->vtx_channel = tmp;
|
||||
if (current_vtx_channel != vtxConfig()->vtx_channel) {
|
||||
current_vtx_channel = vtxConfig()->vtx_channel;
|
||||
rtc6705_soft_spi_set_channel(vtx_freq[current_vtx_channel]);
|
||||
}
|
||||
#else
|
||||
const uint16_t tmp = sbufReadU16(src);
|
||||
const uint8_t band = (tmp / 8) + 1;
|
||||
const uint8_t channel = (tmp % 8) + 1;
|
||||
|
||||
if (vtxCommonGetDeviceType() != VTXDEV_UNKNOWN) {
|
||||
|
||||
uint8_t band = (tmp / 8) + 1;
|
||||
uint8_t channel = (tmp % 8) + 1;
|
||||
|
||||
uint8_t current_band=0, current_channel=0;
|
||||
vtxCommonGetBandChan(¤t_band,¤t_channel);
|
||||
vtxCommonGetBandAndChannel(¤t_band,¤t_channel);
|
||||
if ((current_band != band) || (current_channel != channel))
|
||||
vtxCommonSetBandChan(band,channel);
|
||||
vtxCommonSetBandAndChannel(band,channel);
|
||||
|
||||
if (sbufBytesRemaining(src) < 2)
|
||||
break;
|
||||
|
@ -1750,11 +1741,10 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
|
||||
uint8_t pitmode = sbufReadU8(src);
|
||||
uint8_t current_pitmode = 0;
|
||||
vtxCommonGetPitmode(¤t_pitmode);
|
||||
vtxCommonGetPitMode(¤t_pitmode);
|
||||
if (current_pitmode != pitmode)
|
||||
vtxCommonSetPitmode(pitmode);
|
||||
vtxCommonSetPitMode(pitmode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -339,7 +339,7 @@ void fcTasksInit(void)
|
|||
setTaskEnabled(TASK_STACK_CHECK, true);
|
||||
#endif
|
||||
#ifdef VTX_CONTROL
|
||||
#if defined(VTX_SMARTAUDIO) || defined(VTX_TRAMP)
|
||||
#if defined(VTX_RTC6705) || defined(VTX_SMARTAUDIO) || defined(VTX_TRAMP)
|
||||
setTaskEnabled(TASK_VTXCTRL, true);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "io/gps.h"
|
||||
#include "io/beeper.h"
|
||||
#include "io/motors.h"
|
||||
#include "io/vtx.h"
|
||||
#include "io/vtx_control.h"
|
||||
#include "io/dashboard.h"
|
||||
|
||||
#include "sensors/barometer.h"
|
||||
|
@ -60,7 +60,6 @@
|
|||
#include "flight/navigation.h"
|
||||
#include "flight/failsafe.h"
|
||||
|
||||
|
||||
static pidProfile_t *pidProfile;
|
||||
|
||||
// true if arming is done via the sticks (as opposed to a switch)
|
||||
|
@ -294,7 +293,7 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef VTX
|
||||
#ifdef VTX_CONTROL
|
||||
if (rcSticks == THR_HI + YAW_LO + PIT_CE + ROL_HI) {
|
||||
vtxIncrementBand();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "io/beeper.h"
|
||||
#include "io/statusindicator.h"
|
||||
#include "io/vtx.h"
|
||||
#include "io/vtx_control.h"
|
||||
|
||||
#ifdef GPS
|
||||
#include "io/gps.h"
|
||||
|
|
|
@ -100,11 +100,7 @@ static int writeChar(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c
|
|||
static bool isTransferInProgress(const displayPort_t *displayPort)
|
||||
{
|
||||
UNUSED(displayPort);
|
||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||
return max7456DmaInProgres();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return max7456DmaInProgress();
|
||||
}
|
||||
|
||||
static void resync(displayPort_t *displayPort)
|
||||
|
|
|
@ -55,18 +55,14 @@
|
|||
#include "drivers/max7456_symbols.h"
|
||||
#include "drivers/display.h"
|
||||
#include "drivers/system.h"
|
||||
#ifdef USE_RTC6705
|
||||
#include "drivers/vtx_soft_spi_rtc6705.h"
|
||||
#include "drivers/vtx_soft_spi_rtc6705.h"
|
||||
#elif defined(VTX)
|
||||
#include "drivers/vtx_rtc6705.h"
|
||||
#endif
|
||||
#include "drivers/vtx_common.h"
|
||||
|
||||
#include "io/asyncfatfs/asyncfatfs.h"
|
||||
#include "io/flashfs.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/vtx.h"
|
||||
#include "io/vtx_rtc6705.h"
|
||||
#include "io/vtx_control.h"
|
||||
#include "io/vtx_string.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
|
@ -318,20 +314,21 @@ static void osdDrawSingleElement(uint8_t item)
|
|||
break;
|
||||
}
|
||||
|
||||
#if defined(VTX) || defined(USE_RTC6705)
|
||||
#if defined(VTX_COMMON)
|
||||
case OSD_VTX_CHANNEL:
|
||||
{
|
||||
// FIXME cleanup this when the VTX API is aligned for software vs hardware support of the RTC6705 - See SPRACINGF3NEO/SINGULARITY/SIRINFPV targets.
|
||||
#if defined(VTX)
|
||||
const char vtxBandLetter = vtx58BandLetter[vtxConfig()->vtx_band + 1];
|
||||
const char *vtxChannelName = vtx58ChannelNames[vtxConfig()->vtx_channel + 1];
|
||||
tfp_sprintf(buff, "%c:%s", vtxBandLetter, vtxChannelName);
|
||||
#elif defined(USE_RTC6705)
|
||||
tfp_sprintf(buff, "CH:%d", current_vtx_channel % CHANNELS_PER_BAND + 1);
|
||||
#endif
|
||||
uint8_t band=0, channel=0;
|
||||
vtxCommonGetBandAndChannel(&band,&channel);
|
||||
|
||||
uint8_t power = 0;
|
||||
vtxCommonGetPowerIndex(&power);
|
||||
|
||||
const char vtxBandLetter = vtx58BandLetter[band];
|
||||
const char *vtxChannelName = vtx58ChannelNames[channel];
|
||||
sprintf(buff, "%c:%s:%d", vtxBandLetter, vtxChannelName, power);
|
||||
break;
|
||||
}
|
||||
#endif // VTX
|
||||
#endif
|
||||
|
||||
case OSD_CROSSHAIRS:
|
||||
elemPosX = 14 - 1; // Offset for 1 char to the left
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
|
||||
// Get target build configuration
|
||||
#include "platform.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
|
||||
#include "config/config_eeprom.h"
|
||||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "drivers/vtx_rtc6705.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "io/beeper.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/vtx.h"
|
||||
|
||||
#if defined(USE_RTC6705) || defined(VTX)
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(vtxConfig_t, vtxConfig, PG_VTX_CONFIG, 0);
|
||||
|
||||
PG_RESET_TEMPLATE(vtxConfig_t, vtxConfig,
|
||||
.vtx_band = 4, //Fatshark/Airwaves
|
||||
.vtx_channel = 1, //CH1
|
||||
.vtx_mode = 0, //CH+BAND mode
|
||||
.vtx_mhz = 5740 //F0
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef VTX
|
||||
|
||||
static uint8_t locked = 0;
|
||||
|
||||
void vtxInit(void)
|
||||
{
|
||||
rtc6705Init();
|
||||
if (vtxConfig()->vtx_mode == 0) {
|
||||
rtc6705SetChannel(vtxConfig()->vtx_band, vtxConfig()->vtx_channel);
|
||||
} else if (vtxConfig()->vtx_mode == 1) {
|
||||
rtc6705SetFreq(vtxConfig()->vtx_mhz);
|
||||
}
|
||||
}
|
||||
|
||||
static void setChannelSaveAndNotify(uint8_t *bandOrChannel, uint8_t step, int32_t min, int32_t max)
|
||||
{
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
locked = 1;
|
||||
}
|
||||
|
||||
if (vtxConfig()->vtx_mode == 0 && !locked) {
|
||||
uint8_t temp = (*bandOrChannel) + step;
|
||||
temp = constrain(temp, min, max);
|
||||
*bandOrChannel = temp;
|
||||
|
||||
rtc6705SetChannel(vtxConfig()->vtx_band, vtxConfig()->vtx_channel);
|
||||
writeEEPROM();
|
||||
readEEPROM();
|
||||
beeperConfirmationBeeps(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void vtxIncrementBand(void)
|
||||
{
|
||||
setChannelSaveAndNotify(&(vtxConfigMutable()->vtx_band), 1, RTC6705_BAND_MIN, RTC6705_BAND_MAX);
|
||||
}
|
||||
|
||||
void vtxDecrementBand(void)
|
||||
{
|
||||
setChannelSaveAndNotify(&(vtxConfigMutable()->vtx_band), -1, RTC6705_BAND_MIN, RTC6705_BAND_MAX);
|
||||
}
|
||||
|
||||
void vtxIncrementChannel(void)
|
||||
{
|
||||
setChannelSaveAndNotify(&(vtxConfigMutable()->vtx_channel), 1, RTC6705_CHANNEL_MIN, RTC6705_CHANNEL_MAX);
|
||||
}
|
||||
|
||||
void vtxDecrementChannel(void)
|
||||
{
|
||||
setChannelSaveAndNotify(&(vtxConfigMutable()->vtx_channel), -1, RTC6705_CHANNEL_MIN, RTC6705_CHANNEL_MAX);
|
||||
}
|
||||
|
||||
void vtxUpdateActivatedChannel(void)
|
||||
{
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
locked = 1;
|
||||
}
|
||||
|
||||
if (vtxConfig()->vtx_mode == 2 && !locked) {
|
||||
static uint8_t lastIndex = -1;
|
||||
|
||||
for (uint8_t index = 0; index < MAX_CHANNEL_ACTIVATION_CONDITION_COUNT; index++) {
|
||||
const vtxChannelActivationCondition_t *vtxChannelActivationCondition = &vtxConfig()->vtxChannelActivationConditions[index];
|
||||
|
||||
if (isRangeActive(vtxChannelActivationCondition->auxChannelIndex, &vtxChannelActivationCondition->range)
|
||||
&& index != lastIndex) {
|
||||
lastIndex = index;
|
||||
rtc6705SetChannel(vtxChannelActivationCondition->band, vtxChannelActivationCondition->channel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
|
||||
// Get target build configuration
|
||||
#include "platform.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
|
||||
#include "config/config_eeprom.h"
|
||||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "drivers/vtx_common.h"
|
||||
#include "drivers/buttons.h"
|
||||
#include "drivers/light_led.h"
|
||||
#include "drivers/system.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "io/beeper.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/vtx_control.h"
|
||||
|
||||
|
||||
#if defined(VTX_CONTROL) && defined(VTX_COMMON)
|
||||
|
||||
PG_REGISTER(vtxConfig_t, vtxConfig, PG_VTX_CONFIG, 1);
|
||||
|
||||
static uint8_t locked = 0;
|
||||
|
||||
void vtxControlInit(void)
|
||||
{
|
||||
// NOTHING TO DO
|
||||
}
|
||||
|
||||
static void vtxUpdateBandAndChannel(uint8_t bandStep, uint8_t channelStep)
|
||||
{
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
locked = 1;
|
||||
}
|
||||
|
||||
if (!locked) {
|
||||
uint8_t band = 0, channel = 0;
|
||||
vtxCommonGetBandAndChannel(&band, &channel);
|
||||
vtxCommonSetBandAndChannel(band + bandStep, channel + channelStep);
|
||||
}
|
||||
}
|
||||
|
||||
void vtxIncrementBand(void)
|
||||
{
|
||||
vtxUpdateBandAndChannel(+1, 0);
|
||||
}
|
||||
|
||||
void vtxDecrementBand(void)
|
||||
{
|
||||
vtxUpdateBandAndChannel(-1, 0);
|
||||
}
|
||||
|
||||
void vtxIncrementChannel(void)
|
||||
{
|
||||
vtxUpdateBandAndChannel(0, +1);
|
||||
}
|
||||
|
||||
void vtxDecrementChannel(void)
|
||||
{
|
||||
vtxUpdateBandAndChannel(0, -1);
|
||||
}
|
||||
|
||||
void vtxUpdateActivatedChannel(void)
|
||||
{
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
locked = 1;
|
||||
}
|
||||
|
||||
if (!locked) {
|
||||
static uint8_t lastIndex = -1;
|
||||
|
||||
for (uint8_t index = 0; index < MAX_CHANNEL_ACTIVATION_CONDITION_COUNT; index++) {
|
||||
const vtxChannelActivationCondition_t *vtxChannelActivationCondition = &vtxConfig()->vtxChannelActivationConditions[index];
|
||||
|
||||
if (isRangeActive(vtxChannelActivationCondition->auxChannelIndex, &vtxChannelActivationCondition->range)
|
||||
&& index != lastIndex) {
|
||||
lastIndex = index;
|
||||
|
||||
vtxCommonSetBandAndChannel(vtxChannelActivationCondition->band, vtxChannelActivationCondition->channel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vtxCycleBandOrChannel(const uint8_t bandStep, const uint8_t channelStep)
|
||||
{
|
||||
uint8_t band = 0, channel = 0;
|
||||
vtxDeviceCapability_t capability;
|
||||
|
||||
bool haveAllNeededInfo = vtxCommonGetBandAndChannel(&band, &channel) && vtxCommonGetDeviceCapability(&capability);
|
||||
if (!haveAllNeededInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newChannel = channel + channelStep;
|
||||
if (newChannel > capability.channelCount) {
|
||||
newChannel = 1;
|
||||
} else if (newChannel < 1) {
|
||||
newChannel = capability.channelCount;
|
||||
}
|
||||
|
||||
int newBand = band + bandStep;
|
||||
if (newBand > capability.bandCount) {
|
||||
newBand = 1;
|
||||
} else if (newBand < 1) {
|
||||
newBand = capability.bandCount;
|
||||
}
|
||||
|
||||
vtxCommonSetBandAndChannel(newBand, newChannel);
|
||||
}
|
||||
|
||||
void vtxCyclePower(const uint8_t powerStep)
|
||||
{
|
||||
uint8_t power = 0;
|
||||
vtxDeviceCapability_t capability;
|
||||
|
||||
bool haveAllNeededInfo = vtxCommonGetPowerIndex(&power) && vtxCommonGetDeviceCapability(&capability);
|
||||
if (!haveAllNeededInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newPower = power + powerStep;
|
||||
if (newPower >= capability.powerCount) {
|
||||
newPower = 0;
|
||||
} else if (newPower < 0) {
|
||||
newPower = capability.powerCount;
|
||||
}
|
||||
|
||||
vtxCommonSetPowerByIndex(newPower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow VTX channel/band/rf power/on-off and save via a single button.
|
||||
*
|
||||
* The LED1 flashes a set number of times, followed by a short pause, one per second. The amount of flashes decreases over time while
|
||||
* the button is held to indicate the action that will be performed upon release.
|
||||
* The actions are ordered by most-frequently used action. i.e. you change channel more frequently than band.
|
||||
*
|
||||
* The vtx settings can be changed while the VTX is OFF.
|
||||
* If the VTX is OFF when the settings are saved the VTX will be OFF on the next boot, likewise
|
||||
* If the VTX is ON when the settings are saved the VTX will be ON on the next boot.
|
||||
*
|
||||
* Future: It would be nice to re-use the code in statusindicator.c and blink-codes but target a different LED instead of the simple timed
|
||||
* behaviour of the LED1 here.
|
||||
*
|
||||
* Future: Blink out the state after changing it.
|
||||
*/
|
||||
void handleVTXControlButton(void)
|
||||
{
|
||||
#if defined(VTX_RTC6705) && defined(BUTTON_A_PIN)
|
||||
bool buttonHeld;
|
||||
bool buttonWasPressed = false;
|
||||
uint32_t start = millis();
|
||||
uint32_t ledToggleAt = start;
|
||||
bool ledEnabled = false;
|
||||
uint8_t flashesDone = 0;
|
||||
|
||||
uint8_t actionCounter = 0;
|
||||
while ((buttonHeld = buttonAPressed())) {
|
||||
uint32_t end = millis();
|
||||
|
||||
int32_t diff = cmp32(end, start);
|
||||
if (diff > 25 && diff <= 1000) {
|
||||
actionCounter = 4;
|
||||
} else if (diff > 1000 && diff <= 3000) {
|
||||
actionCounter = 3;
|
||||
} else if (diff > 3000 && diff <= 5000) {
|
||||
actionCounter = 2;
|
||||
} else if (diff > 5000) {
|
||||
actionCounter = 1;
|
||||
}
|
||||
|
||||
if (actionCounter) {
|
||||
|
||||
diff = cmp32(ledToggleAt, end);
|
||||
|
||||
if (diff < 0) {
|
||||
ledEnabled = !ledEnabled;
|
||||
|
||||
const uint8_t updateDuration = 60;
|
||||
|
||||
ledToggleAt = end + updateDuration;
|
||||
|
||||
if (ledEnabled) {
|
||||
LED1_ON;
|
||||
} else {
|
||||
LED1_OFF;
|
||||
flashesDone++;
|
||||
}
|
||||
|
||||
if (flashesDone == actionCounter) {
|
||||
ledToggleAt += (1000 - ((flashesDone * updateDuration) * 2));
|
||||
flashesDone = 0;
|
||||
}
|
||||
}
|
||||
buttonWasPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!buttonWasPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
LED1_OFF;
|
||||
|
||||
switch(actionCounter) {
|
||||
case 4:
|
||||
vtxCycleBandOrChannel(0, +1);
|
||||
break;
|
||||
case 3:
|
||||
vtxCycleBandOrChannel(+1, 0);
|
||||
break;
|
||||
case 2:
|
||||
vtxCyclePower(+1);
|
||||
break;
|
||||
case 1:
|
||||
saveConfigAndNotify();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -19,10 +19,6 @@
|
|||
|
||||
#include "fc/rc_controls.h"
|
||||
|
||||
#define VTX_BAND_MIN 1
|
||||
#define VTX_BAND_MAX 5
|
||||
#define VTX_CHANNEL_MIN 1
|
||||
#define VTX_CHANNEL_MAX 8
|
||||
#define MAX_CHANNEL_ACTIVATION_CONDITION_COUNT 10
|
||||
|
||||
typedef struct vtxChannelActivationCondition_s {
|
||||
|
@ -33,20 +29,21 @@ typedef struct vtxChannelActivationCondition_s {
|
|||
} vtxChannelActivationCondition_t;
|
||||
|
||||
typedef struct vtxConfig_s {
|
||||
uint8_t vtx_power;
|
||||
uint8_t vtx_channel; //1-8
|
||||
uint8_t vtx_band; //1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
|
||||
uint8_t vtx_mode; //0=ch+band 1=mhz
|
||||
uint16_t vtx_mhz; //5740
|
||||
vtxChannelActivationCondition_t vtxChannelActivationConditions[MAX_CHANNEL_ACTIVATION_CONDITION_COUNT];
|
||||
} vtxConfig_t;
|
||||
|
||||
PG_DECLARE(vtxConfig_t, vtxConfig);
|
||||
|
||||
void vtxInit(void);
|
||||
void vtxControlInit(void);
|
||||
|
||||
void vtxIncrementBand(void);
|
||||
void vtxDecrementBand(void);
|
||||
void vtxIncrementChannel(void);
|
||||
void vtxDecrementChannel(void);
|
||||
|
||||
void vtxCyclePower(const uint8_t powerStep);
|
||||
void vtxCycleBandOrChannel(const uint8_t bandStep, const uint8_t channelStep);
|
||||
|
||||
void vtxUpdateActivatedChannel(void);
|
||||
|
||||
void handleVTXControlButton(void);
|
|
@ -0,0 +1,313 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* Created by jflyper */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#if defined(VTX_RTC6705) && defined(VTX_CONTROL)
|
||||
#include "build/build_config.h"
|
||||
|
||||
#include "cms/cms.h"
|
||||
#include "cms/cms_types.h"
|
||||
|
||||
#include "common/printf.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
#include "drivers/vtx_common.h"
|
||||
#include "drivers/vtx_rtc6705.h"
|
||||
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "io/vtx_rtc6705.h"
|
||||
#include "io/vtx_string.h"
|
||||
|
||||
#include "build/debug.h"
|
||||
|
||||
bool canUpdateVTX(void);
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(vtxRTC6705Config_t, vtxRTC6705Config, PG_VTX_RTC6705_CONFIG, 0);
|
||||
|
||||
PG_RESET_TEMPLATE(vtxRTC6705Config_t, vtxRTC6705Config,
|
||||
.band = 4, //Fatshark/Airwaves
|
||||
.channel = 1, //CH1
|
||||
.power = VTX_RTC6705_DEFAULT_POWER
|
||||
);
|
||||
|
||||
#define WAIT_FOR_VTX while (!canUpdateVTX()) {}
|
||||
|
||||
#if defined(CMS) || defined(VTX_COMMON)
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
static const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = {
|
||||
"---", "25 ", "200",
|
||||
};
|
||||
#else
|
||||
static const char * const rtc6705PowerNames[RTC6705_POWER_COUNT] = {
|
||||
"25 ", "200",
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VTX_COMMON
|
||||
static vtxVTable_t rtc6705VTable; // Forward
|
||||
static vtxDevice_t vtxRTC6705 = {
|
||||
.vTable = &rtc6705VTable,
|
||||
.capability.bandCount = 5,
|
||||
.capability.channelCount = 8,
|
||||
.capability.powerCount = RTC6705_POWER_COUNT,
|
||||
.bandNames = (char **)vtx58BandNames,
|
||||
.channelNames = (char **)vtx58ChannelNames,
|
||||
.powerNames = (char **)rtc6705PowerNames,
|
||||
};
|
||||
#endif
|
||||
|
||||
bool vtxRTC6705Init(void)
|
||||
{
|
||||
vtxCommonRegisterDevice(&vtxRTC6705);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void vtxRTC6705Configure(void)
|
||||
{
|
||||
rtc6705SetRFPower(vtxRTC6705.powerIndex - 1);
|
||||
rtc6705SetBandAndChannel(vtxRTC6705.band - 1, vtxRTC6705.channel - 1);
|
||||
}
|
||||
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
static void vtxRTC6705EnableAndConfigure(void)
|
||||
{
|
||||
WAIT_FOR_VTX;
|
||||
|
||||
rtc6705Enable();
|
||||
|
||||
delay(RTC6705_BOOT_DELAY);
|
||||
|
||||
vtxRTC6705Configure();
|
||||
}
|
||||
#endif
|
||||
|
||||
void vtxRTC6705Process(uint32_t now)
|
||||
{
|
||||
UNUSED(now);
|
||||
|
||||
static bool configured = false;
|
||||
if (!configured) {
|
||||
vtxRTC6705.band = vtxRTC6705Config()->band;
|
||||
vtxRTC6705.channel = vtxRTC6705Config()->channel;
|
||||
vtxRTC6705.powerIndex = vtxRTC6705Config()->power;
|
||||
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
if (vtxRTC6705.powerIndex > 0) {
|
||||
vtxRTC6705EnableAndConfigure();
|
||||
} else {
|
||||
rtc6705Disable();
|
||||
}
|
||||
#else
|
||||
vtxRTC6705Configure();
|
||||
#endif
|
||||
|
||||
configured = true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VTX_COMMON
|
||||
// Interface to common VTX API
|
||||
|
||||
vtxDevType_e vtxRTC6705GetDeviceType(void)
|
||||
{
|
||||
return VTXDEV_RTC6705;
|
||||
}
|
||||
|
||||
bool vtxRTC6705IsReady(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void vtxRTC6705SetBandAndChannel(uint8_t band, uint8_t channel)
|
||||
{
|
||||
WAIT_FOR_VTX;
|
||||
|
||||
if (band && channel) {
|
||||
if (vtxRTC6705.powerIndex > 0) {
|
||||
rtc6705SetBandAndChannel(band - 1, channel - 1);
|
||||
}
|
||||
|
||||
vtxRTC6705.band = band;
|
||||
vtxRTC6705.channel = channel;
|
||||
|
||||
vtxRTC6705ConfigMutable()->band = band;
|
||||
vtxRTC6705ConfigMutable()->channel = channel;
|
||||
}
|
||||
}
|
||||
|
||||
void vtxRTC6705SetPowerByIndex(uint8_t index)
|
||||
{
|
||||
WAIT_FOR_VTX;
|
||||
|
||||
vtxRTC6705ConfigMutable()->power = index;
|
||||
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
if (index == 0) {
|
||||
// power device off
|
||||
|
||||
if (vtxRTC6705.powerIndex > 0) {
|
||||
// on, power it off
|
||||
vtxRTC6705.powerIndex = index;
|
||||
rtc6705Disable();
|
||||
return;
|
||||
} else {
|
||||
// already off
|
||||
}
|
||||
} else {
|
||||
// change rf power and maybe turn the device on first
|
||||
if (vtxRTC6705.powerIndex == 0) {
|
||||
// if it's powered down, power it up, wait and configure channel, band and power.
|
||||
vtxRTC6705.powerIndex = index;
|
||||
vtxRTC6705EnableAndConfigure();
|
||||
return;
|
||||
} else {
|
||||
// if it's powered up, just set the rf power
|
||||
vtxRTC6705.powerIndex = index;
|
||||
rtc6705SetRFPower(index);
|
||||
}
|
||||
}
|
||||
#else
|
||||
vtxRTC6705.powerIndex = index;
|
||||
rtc6705SetRFPower(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
void vtxRTC6705SetPitMode(uint8_t onoff)
|
||||
{
|
||||
UNUSED(onoff);
|
||||
return;
|
||||
}
|
||||
|
||||
bool vtxRTC6705GetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
||||
{
|
||||
*pBand = vtxRTC6705.band;
|
||||
*pChannel = vtxRTC6705.channel;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool vtxRTC6705GetPowerIndex(uint8_t *pIndex)
|
||||
{
|
||||
*pIndex = vtxRTC6705.powerIndex;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool vtxRTC6705GetPitMode(uint8_t *pOnOff)
|
||||
{
|
||||
UNUSED(pOnOff);
|
||||
return false;
|
||||
}
|
||||
|
||||
static vtxVTable_t rtc6705VTable = {
|
||||
.process = vtxRTC6705Process,
|
||||
.getDeviceType = vtxRTC6705GetDeviceType,
|
||||
.isReady = vtxRTC6705IsReady,
|
||||
.setBandAndChannel = vtxRTC6705SetBandAndChannel,
|
||||
.setPowerByIndex = vtxRTC6705SetPowerByIndex,
|
||||
.setPitMode = vtxRTC6705SetPitMode,
|
||||
.getBandAndChannel = vtxRTC6705GetBandAndChannel,
|
||||
.getPowerIndex = vtxRTC6705GetPowerIndex,
|
||||
.getPitMode = vtxRTC6705GetPitMode,
|
||||
};
|
||||
#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
|
|
@ -17,22 +17,21 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define DP_5G_MASK 0x7000
|
||||
#define PA5G_BS_MASK 0x0E00
|
||||
#define PA5G_PW_MASK 0x0180
|
||||
#define PD_Q5G_MASK 0x0040
|
||||
#define QI_5G_MASK 0x0038
|
||||
#define PA_BS_MASK 0x0007
|
||||
typedef struct vtxRTC6705Config_s {
|
||||
uint8_t band; // 1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
|
||||
uint8_t channel; // 1-8
|
||||
uint8_t power; // 0 = lowest
|
||||
} vtxRTC6705Config_t;
|
||||
|
||||
#define PA_CONTROL_DEFAULT 0x4FBD
|
||||
PG_DECLARE(vtxRTC6705Config_t, vtxRTC6705Config);
|
||||
|
||||
#define CHANNELS_PER_BAND 8
|
||||
#define BANDS_NUMBER 5
|
||||
#ifdef RTC6705_POWER_PIN
|
||||
#define RTC6705_POWER_COUNT 3
|
||||
#define VTX_RTC6705_DEFAULT_POWER 1
|
||||
#else
|
||||
#define RTC6705_POWER_COUNT 2
|
||||
#define VTX_RTC6705_DEFAULT_POWER 0
|
||||
#endif
|
||||
|
||||
extern uint16_t const vtx_freq[];
|
||||
extern uint16_t current_vtx_channel;
|
||||
|
||||
void rtc6705_soft_spi_init(void);
|
||||
void rtc6705_soft_spi_set_channel(uint16_t channel_freq);
|
||||
void rtc6705_soft_spi_set_rf_power(uint8_t reduce_power);
|
||||
bool vtxRTC6705Init();
|
||||
|
|
@ -17,4 +17,4 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
extern CMS_Menu cmsx_menuVtx;
|
||||
extern CMS_Menu cmsx_menuVtxRTC6705;
|
|
@ -25,7 +25,6 @@
|
|||
#include "platform.h"
|
||||
|
||||
#if defined(VTX_SMARTAUDIO) && defined(VTX_CONTROL)
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#include "cms/cms.h"
|
||||
|
@ -82,14 +81,14 @@ static const char * const saPowerNames[] = {
|
|||
#endif
|
||||
|
||||
#ifdef VTX_COMMON
|
||||
static vtxVTable_t saVTable; // Forward
|
||||
static const vtxVTable_t saVTable; // Forward
|
||||
static vtxDevice_t vtxSmartAudio = {
|
||||
.vTable = &saVTable,
|
||||
.numBand = 5,
|
||||
.numChan = 8,
|
||||
.numPower = 4,
|
||||
.capability.bandCount = 5,
|
||||
.capability.channelCount = 8,
|
||||
.capability.powerCount = 4,
|
||||
.bandNames = (char **)vtx58BandNames,
|
||||
.chanNames = (char **)vtx58ChannelNames,
|
||||
.channelNames = (char **)vtx58ChannelNames,
|
||||
.powerNames = (char **)saPowerNames,
|
||||
};
|
||||
#endif
|
||||
|
@ -172,7 +171,7 @@ static saPowerTable_t saPowerTable[] = {
|
|||
|
||||
typedef struct smartAudioDevice_s {
|
||||
int8_t version;
|
||||
int8_t chan;
|
||||
int8_t channel;
|
||||
int8_t power;
|
||||
int8_t mode;
|
||||
uint16_t freq;
|
||||
|
@ -181,7 +180,7 @@ typedef struct smartAudioDevice_s {
|
|||
|
||||
static smartAudioDevice_t saDevice = {
|
||||
.version = 0,
|
||||
.chan = -1,
|
||||
.channel = -1,
|
||||
.power = -1,
|
||||
.mode = 0,
|
||||
.freq = 0,
|
||||
|
@ -240,7 +239,7 @@ static void saPrintSettings(void)
|
|||
dprintf((" outb=%s", (saDevice.mode & 8) ? "on " : "off"));
|
||||
dprintf((" lock=%s", (saDevice.mode & 16) ? "unlocked" : "locked"));
|
||||
dprintf((" deferred=%s\r\n", (saDevice.mode & 32) ? "on" : "off"));
|
||||
dprintf((" chan: %d ", saDevice.chan));
|
||||
dprintf((" channel: %d ", saDevice.channel));
|
||||
dprintf(("freq: %d ", saDevice.freq));
|
||||
dprintf(("power: %d ", saDevice.power));
|
||||
dprintf(("pitfreq: %d ", saDevice.orfreq));
|
||||
|
@ -340,14 +339,14 @@ static void saProcessResponse(uint8_t *buf, int len)
|
|||
break;
|
||||
|
||||
saDevice.version = (buf[0] == SA_CMD_GET_SETTINGS) ? 1 : 2;
|
||||
saDevice.chan = buf[2];
|
||||
saDevice.channel = buf[2];
|
||||
saDevice.power = buf[3];
|
||||
saDevice.mode = buf[4];
|
||||
saDevice.freq = (buf[5] << 8)|buf[6];
|
||||
|
||||
#ifdef SMARTAUDIO_DEBUG_MONITOR
|
||||
debug[0] = saDevice.version * 100 + saDevice.mode;
|
||||
debug[1] = saDevice.chan;
|
||||
debug[1] = saDevice.channel;
|
||||
debug[2] = saDevice.freq;
|
||||
debug[3] = saDevice.power;
|
||||
#endif
|
||||
|
@ -629,11 +628,11 @@ static void saGetPitFreq(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void saSetBandChan(uint8_t band, uint8_t chan)
|
||||
void saSetBandAndChannel(uint8_t band, uint8_t channel)
|
||||
{
|
||||
static uint8_t buf[6] = { 0xAA, 0x55, SACMD(SA_CMD_SET_CHAN), 1 };
|
||||
|
||||
buf[4] = band * 8 + chan;
|
||||
buf[4] = band * 8 + channel;
|
||||
buf[5] = CRC8(buf, 5);
|
||||
|
||||
saQueueCmd(buf, 6);
|
||||
|
@ -668,7 +667,7 @@ void saSetPowerByIndex(uint8_t index)
|
|||
saQueueCmd(buf, 6);
|
||||
}
|
||||
|
||||
bool smartAudioInit()
|
||||
bool vtxSmartAudioInit()
|
||||
{
|
||||
#ifdef SMARTAUDIO_DPRINTF
|
||||
// Setup debugSerialPort
|
||||
|
@ -689,7 +688,6 @@ bool smartAudioInit()
|
|||
return false;
|
||||
}
|
||||
|
||||
vtxSmartAudio.vTable = &saVTable;
|
||||
vtxCommonRegisterDevice(&vtxSmartAudio);
|
||||
|
||||
return true;
|
||||
|
@ -746,7 +744,7 @@ void vtxSAProcess(uint32_t now)
|
|||
static uint8_t monChan;
|
||||
static uint8_t monPower;
|
||||
|
||||
vtxCommonGetBandChan(&monBand, &monChan);
|
||||
vtxCommonGetBandAndChannel(&monBand, &monChan);
|
||||
vtxCommonGetPowerIndex(&monPower);
|
||||
debug[0] = monBand;
|
||||
debug[1] = monChan;
|
||||
|
@ -768,10 +766,10 @@ bool vtxSAIsReady(void)
|
|||
return !(saDevice.version == 0);
|
||||
}
|
||||
|
||||
void vtxSASetBandChan(uint8_t band, uint8_t chan)
|
||||
void vtxSASetBandAndChannel(uint8_t band, uint8_t channel)
|
||||
{
|
||||
if (band && chan)
|
||||
saSetBandChan(band - 1, chan - 1);
|
||||
if (band && channel)
|
||||
saSetBandAndChannel(band - 1, channel - 1);
|
||||
}
|
||||
|
||||
void vtxSASetPowerByIndex(uint8_t index)
|
||||
|
@ -784,7 +782,7 @@ void vtxSASetPowerByIndex(uint8_t index)
|
|||
saSetPowerByIndex(index - 1);
|
||||
}
|
||||
|
||||
void vtxSASetPitmode(uint8_t onoff)
|
||||
void vtxSASetPitMode(uint8_t onoff)
|
||||
{
|
||||
if (!(vtxSAIsReady() && (saDevice.version == 2)))
|
||||
return;
|
||||
|
@ -807,13 +805,13 @@ void vtxSASetPitmode(uint8_t onoff)
|
|||
return;
|
||||
}
|
||||
|
||||
bool vtxSAGetBandChan(uint8_t *pBand, uint8_t *pChan)
|
||||
bool vtxSAGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
||||
{
|
||||
if (!vtxSAIsReady())
|
||||
return false;
|
||||
|
||||
*pBand = (saDevice.chan / 8) + 1;
|
||||
*pChan = (saDevice.chan % 8) + 1;
|
||||
*pBand = (saDevice.channel / 8) + 1;
|
||||
*pChannel = (saDevice.channel % 8) + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -826,25 +824,25 @@ bool vtxSAGetPowerIndex(uint8_t *pIndex)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vtxSAGetPitmode(uint8_t *pOnoff)
|
||||
bool vtxSAGetPitMode(uint8_t *pOnOff)
|
||||
{
|
||||
if (!(vtxSAIsReady() && (saDevice.version == 2)))
|
||||
return false;
|
||||
|
||||
*pOnoff = (saDevice.mode & SA_MODE_GET_PITMODE) ? 1 : 0;
|
||||
*pOnOff = (saDevice.mode & SA_MODE_GET_PITMODE) ? 1 : 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static vtxVTable_t saVTable = {
|
||||
static const vtxVTable_t saVTable = {
|
||||
.process = vtxSAProcess,
|
||||
.getDeviceType = vtxSAGetDeviceType,
|
||||
.isReady = vtxSAIsReady,
|
||||
.setBandChan = vtxSASetBandChan,
|
||||
.setBandAndChannel = vtxSASetBandAndChannel,
|
||||
.setPowerByIndex = vtxSASetPowerByIndex,
|
||||
.setPitmode = vtxSASetPitmode,
|
||||
.getBandChan = vtxSAGetBandChan,
|
||||
.setPitMode = vtxSASetPitMode,
|
||||
.getBandAndChannel = vtxSAGetBandAndChannel,
|
||||
.getPowerIndex = vtxSAGetPowerIndex,
|
||||
.getPitmode = vtxSAGetPitmode,
|
||||
.getPitMode = vtxSAGetPitMode,
|
||||
};
|
||||
#endif // VTX_COMMON
|
||||
|
||||
|
@ -871,7 +869,7 @@ uint8_t saCmsBand = 0;
|
|||
uint8_t saCmsChan = 0;
|
||||
uint8_t saCmsPower = 0;
|
||||
|
||||
// Frequency derived from channel table (used for reference in band/chan mode)
|
||||
// Frequency derived from channel table (used for reference in band/channel mode)
|
||||
uint16_t saCmsFreqRef = 0;
|
||||
|
||||
uint16_t saCmsDeviceFreq = 0;
|
||||
|
@ -897,11 +895,11 @@ void saCmsUpdate(void)
|
|||
|
||||
saCmsFselMode = (saDevice.mode & SA_MODE_GET_FREQ_BY_FREQ) ? 1 : 0;
|
||||
|
||||
saCmsBand = (saDevice.chan / 8) + 1;
|
||||
saCmsChan = (saDevice.chan % 8) + 1;
|
||||
saCmsFreqRef = vtx58FreqTable[saDevice.chan / 8][saDevice.chan % 8];
|
||||
saCmsBand = (saDevice.channel / 8) + 1;
|
||||
saCmsChan = (saDevice.channel % 8) + 1;
|
||||
saCmsFreqRef = vtx58frequencyTable[saDevice.channel / 8][saDevice.channel % 8];
|
||||
|
||||
saCmsDeviceFreq = vtx58FreqTable[saDevice.chan / 8][saDevice.chan % 8];
|
||||
saCmsDeviceFreq = vtx58frequencyTable[saDevice.channel / 8][saDevice.channel % 8];
|
||||
|
||||
if ((saDevice.mode & SA_MODE_GET_PITMODE) == 0) {
|
||||
saCmsRFState = SACMS_TXMODE_ACTIVE;
|
||||
|
@ -952,8 +950,8 @@ else
|
|||
saCmsStatusString[0] = "-FR"[saCmsOpmodel];
|
||||
|
||||
if (saCmsFselMode == 0) {
|
||||
saCmsStatusString[2] = "ABEFR"[saDevice.chan / 8];
|
||||
saCmsStatusString[3] = '1' + (saDevice.chan % 8);
|
||||
saCmsStatusString[2] = "ABEFR"[saDevice.channel / 8];
|
||||
saCmsStatusString[3] = '1' + (saDevice.channel % 8);
|
||||
} else {
|
||||
saCmsStatusString[2] = 'U';
|
||||
saCmsStatusString[3] = 'F';
|
||||
|
@ -966,7 +964,7 @@ else
|
|||
tfp_sprintf(&saCmsStatusString[5], "%4d", saDevice.freq);
|
||||
else
|
||||
tfp_sprintf(&saCmsStatusString[5], "%4d",
|
||||
vtx58FreqTable[saDevice.chan / 8][saDevice.chan % 8]);
|
||||
vtx58frequencyTable[saDevice.channel / 8][saDevice.channel % 8]);
|
||||
|
||||
saCmsStatusString[9] = ' ';
|
||||
|
||||
|
@ -1002,9 +1000,9 @@ static long saCmsConfigBandByGvar(displayPort_t *pDisp, const void *self)
|
|||
}
|
||||
|
||||
if ((saCmsOpmodel == SACMS_OPMODEL_FREE) && !saDeferred)
|
||||
saSetBandChan(saCmsBand - 1, saCmsChan - 1);
|
||||
saSetBandAndChannel(saCmsBand - 1, saCmsChan - 1);
|
||||
|
||||
saCmsFreqRef = vtx58FreqTable[saCmsBand - 1][saCmsChan - 1];
|
||||
saCmsFreqRef = vtx58frequencyTable[saCmsBand - 1][saCmsChan - 1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1027,9 +1025,9 @@ static long saCmsConfigChanByGvar(displayPort_t *pDisp, const void *self)
|
|||
}
|
||||
|
||||
if ((saCmsOpmodel == SACMS_OPMODEL_FREE) && !saDeferred)
|
||||
saSetBandChan(saCmsBand - 1, saCmsChan - 1);
|
||||
saSetBandAndChannel(saCmsBand - 1, saCmsChan - 1);
|
||||
|
||||
saCmsFreqRef = vtx58FreqTable[saCmsBand - 1][saCmsChan - 1];
|
||||
saCmsFreqRef = vtx58frequencyTable[saCmsBand - 1][saCmsChan - 1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1180,7 +1178,7 @@ static long saCmsConfigFreqModeByGvar(displayPort_t *pDisp, const void *self)
|
|||
|
||||
if (saCmsFselMode == 0) {
|
||||
// CHAN
|
||||
saSetBandChan(saCmsBand - 1, saCmsChan - 1);
|
||||
saSetBandAndChannel(saCmsBand - 1, saCmsChan - 1);
|
||||
} else {
|
||||
// USER: User frequency mode is only available in FREE opmodel.
|
||||
if (saCmsOpmodel == SACMS_OPMODEL_FREE) {
|
||||
|
@ -1205,7 +1203,7 @@ static long saCmsCommence(displayPort_t *pDisp, const void *self)
|
|||
// Race model
|
||||
// Setup band, freq and power.
|
||||
|
||||
saSetBandChan(saCmsBand - 1, saCmsChan - 1);
|
||||
saSetBandAndChannel(saCmsBand - 1, saCmsChan - 1);
|
||||
|
||||
// If in pit mode, cancel it.
|
||||
|
||||
|
@ -1217,7 +1215,7 @@ static long saCmsCommence(displayPort_t *pDisp, const void *self)
|
|||
// Freestyle model
|
||||
// Setup band and freq / user freq
|
||||
if (saCmsFselMode == 0)
|
||||
saSetBandChan(saCmsBand - 1, saCmsChan - 1);
|
||||
saSetBandAndChannel(saCmsBand - 1, saCmsChan - 1);
|
||||
else
|
||||
saSetFreq(saCmsUserFreq);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
// For generic API use, but here for now
|
||||
|
||||
bool smartAudioInit();
|
||||
void smartAudioProcess(uint32_t);
|
||||
bool vtxSmartAudioInit();
|
||||
|
||||
#if 0
|
||||
#ifdef CMS
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#if defined(VTX_COMMON)
|
||||
|
||||
const uint16_t vtx58FreqTable[5][8] =
|
||||
const uint16_t vtx58frequencyTable[5][8] =
|
||||
{
|
||||
{ 5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725 }, // Boscam A
|
||||
{ 5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866 }, // Boscam B
|
||||
|
@ -51,25 +51,25 @@ const char * const vtx58ChannelNames[] = {
|
|||
"-", "1", "2", "3", "4", "5", "6", "7", "8",
|
||||
};
|
||||
|
||||
bool vtx58_Freq2Bandchan(uint16_t freq, uint8_t *pBand, uint8_t *pChan)
|
||||
bool vtx58_Freq2Bandchan(uint16_t freq, uint8_t *pBand, uint8_t *pChannel)
|
||||
{
|
||||
int8_t band;
|
||||
uint8_t chan;
|
||||
uint8_t channel;
|
||||
|
||||
// Use reverse lookup order so that 5880Mhz
|
||||
// get Raceband 7 instead of Fatshark 8.
|
||||
for (band = 4 ; band >= 0 ; band--) {
|
||||
for (chan = 0 ; chan < 8 ; chan++) {
|
||||
if (vtx58FreqTable[band][chan] == freq) {
|
||||
for (channel = 0 ; channel < 8 ; channel++) {
|
||||
if (vtx58frequencyTable[band][channel] == freq) {
|
||||
*pBand = band + 1;
|
||||
*pChan = chan + 1;
|
||||
*pChannel = channel + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pBand = 0;
|
||||
*pChan = 0;
|
||||
*pChannel = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
#if defined(VTX_COMMON)
|
||||
|
||||
extern const uint16_t vtx58FreqTable[5][8];
|
||||
extern const uint16_t vtx58frequencyTable[5][8];
|
||||
extern const char * const vtx58BandNames[];
|
||||
extern const char * const vtx58ChannelNames[];
|
||||
extern const char vtx58BandLetter[];
|
||||
|
||||
bool vtx58_Freq2Bandchan(uint16_t freq, uint8_t *pBand, uint8_t *pChan);
|
||||
bool vtx58_Freq2Bandchan(uint16_t freq, uint8_t *pBand, uint8_t *pChannel);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,13 +51,14 @@ static const char * const trampPowerNames[] = {
|
|||
#endif
|
||||
|
||||
#if defined(VTX_COMMON)
|
||||
static const vtxVTable_t trampVTable; // forward
|
||||
static vtxDevice_t vtxTramp = {
|
||||
.vTable = NULL,
|
||||
.numBand = 5,
|
||||
.numChan = 8,
|
||||
.numPower = sizeof(trampPowerTable),
|
||||
.vTable = &trampVTable,
|
||||
.capability.bandCount = 5,
|
||||
.capability.channelCount = 8,
|
||||
.capability.powerCount = sizeof(trampPowerTable),
|
||||
.bandNames = (char **)vtx58BandNames,
|
||||
.chanNames = (char **)vtx58ChannelNames,
|
||||
.channelNames = (char **)vtx58ChannelNames,
|
||||
.powerNames = (char **)trampPowerNames,
|
||||
};
|
||||
#endif
|
||||
|
@ -82,12 +83,12 @@ uint32_t trampRFFreqMax;
|
|||
uint32_t trampRFPowerMax;
|
||||
|
||||
uint32_t trampCurFreq = 0;
|
||||
uint8_t trampCurBand = 0;
|
||||
uint8_t trampCurChan = 0;
|
||||
uint16_t trampCurPower = 0; // Actual transmitting power
|
||||
uint16_t trampCurConfigPower = 0; // Configured transmitting power
|
||||
int16_t trampCurTemp = 0;
|
||||
uint8_t trampCurPitmode = 0;
|
||||
uint8_t trampBand = 0;
|
||||
uint8_t trampChannel = 0;
|
||||
uint16_t trampPower = 0; // Actual transmitting power
|
||||
uint16_t trampConfiguredPower = 0; // Configured transmitting power
|
||||
int16_t trampTemperature = 0;
|
||||
uint8_t trampPitMode = 0;
|
||||
|
||||
// Maximum number of requests sent to try a config change
|
||||
#define TRAMP_MAX_RETRIES 2
|
||||
|
@ -143,15 +144,15 @@ void trampSendFreq(uint16_t freq)
|
|||
trampCmdU16('F', freq);
|
||||
}
|
||||
|
||||
void trampSetBandChan(uint8_t band, uint8_t chan)
|
||||
void trampSetBandAndChannel(uint8_t band, uint8_t channel)
|
||||
{
|
||||
trampSetFreq(vtx58FreqTable[band - 1][chan - 1]);
|
||||
trampSetFreq(vtx58frequencyTable[band - 1][channel - 1]);
|
||||
}
|
||||
|
||||
void trampSetRFPower(uint16_t level)
|
||||
{
|
||||
trampConfPower = level;
|
||||
if(trampConfPower != trampCurPower)
|
||||
if(trampConfPower != trampPower)
|
||||
trampPowerRetries = TRAMP_MAX_RETRIES;
|
||||
}
|
||||
|
||||
|
@ -170,7 +171,7 @@ bool trampCommitChanges()
|
|||
return true;
|
||||
}
|
||||
|
||||
void trampSetPitmode(uint8_t onoff)
|
||||
void trampSetPitMode(uint8_t onoff)
|
||||
{
|
||||
trampCmdU16('I', onoff ? 0 : 1);
|
||||
}
|
||||
|
@ -200,13 +201,13 @@ char trampHandleResponse(void)
|
|||
uint16_t freq = trampRespBuffer[2]|(trampRespBuffer[3] << 8);
|
||||
if(freq != 0) {
|
||||
trampCurFreq = freq;
|
||||
trampCurConfigPower = trampRespBuffer[4]|(trampRespBuffer[5] << 8);
|
||||
trampCurPitmode = trampRespBuffer[7];
|
||||
trampCurPower = trampRespBuffer[8]|(trampRespBuffer[9] << 8);
|
||||
vtx58_Freq2Bandchan(trampCurFreq, &trampCurBand, &trampCurChan);
|
||||
trampConfiguredPower = trampRespBuffer[4]|(trampRespBuffer[5] << 8);
|
||||
trampPitMode = trampRespBuffer[7];
|
||||
trampPower = trampRespBuffer[8]|(trampRespBuffer[9] << 8);
|
||||
vtx58_Freq2Bandchan(trampCurFreq, &trampBand, &trampChannel);
|
||||
|
||||
if(trampConfFreq == 0) trampConfFreq = trampCurFreq;
|
||||
if(trampConfPower == 0) trampConfPower = trampCurPower;
|
||||
if(trampConfPower == 0) trampConfPower = trampPower;
|
||||
return 'v';
|
||||
}
|
||||
|
||||
|
@ -218,7 +219,7 @@ char trampHandleResponse(void)
|
|||
{
|
||||
uint16_t temp = (int16_t)(trampRespBuffer[6]|(trampRespBuffer[7] << 8));
|
||||
if(temp != 0) {
|
||||
trampCurTemp = temp;
|
||||
trampTemperature = temp;
|
||||
return 's';
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +383,7 @@ void vtxTrampProcess(uint32_t currentTimeUs)
|
|||
#endif
|
||||
done = false;
|
||||
}
|
||||
else if (trampConfPower && trampPowerRetries && (trampConfPower != trampCurConfigPower)) {
|
||||
else if (trampConfPower && trampPowerRetries && (trampConfPower != trampConfiguredPower)) {
|
||||
trampSendRFPower(trampConfPower);
|
||||
trampPowerRetries--;
|
||||
#ifdef TRAMP_DEBUG
|
||||
|
@ -402,7 +403,7 @@ void vtxTrampProcess(uint32_t currentTimeUs)
|
|||
trampStatus = TRAMP_STATUS_ONLINE;
|
||||
// reset configuration value in case it failed (no more retries)
|
||||
trampConfFreq = trampCurFreq;
|
||||
trampConfPower = trampCurPower;
|
||||
trampConfPower = trampPower;
|
||||
trampFreqRetries = trampPowerRetries = 0;
|
||||
}
|
||||
}
|
||||
|
@ -443,8 +444,8 @@ static void trampCmsUpdateStatusString(void)
|
|||
{
|
||||
trampCmsStatusString[0] = '*';
|
||||
trampCmsStatusString[1] = ' ';
|
||||
trampCmsStatusString[2] = vtx58BandLetter[trampCurBand];
|
||||
trampCmsStatusString[3] = vtx58ChannelNames[trampCurChan][0];
|
||||
trampCmsStatusString[2] = vtx58BandLetter[trampBand];
|
||||
trampCmsStatusString[3] = vtx58ChannelNames[trampChannel][0];
|
||||
trampCmsStatusString[4] = ' ';
|
||||
|
||||
if (trampCurFreq)
|
||||
|
@ -452,14 +453,14 @@ static void trampCmsUpdateStatusString(void)
|
|||
else
|
||||
tfp_sprintf(&trampCmsStatusString[5], "----");
|
||||
|
||||
if (trampCurPower) {
|
||||
tfp_sprintf(&trampCmsStatusString[9], " %c%3d", (trampCurPower == trampCurConfigPower) ? ' ' : '*', trampCurPower);
|
||||
if (trampPower) {
|
||||
tfp_sprintf(&trampCmsStatusString[9], " %c%3d", (trampPower == trampConfiguredPower) ? ' ' : '*', trampPower);
|
||||
}
|
||||
else
|
||||
tfp_sprintf(&trampCmsStatusString[9], " ----");
|
||||
}
|
||||
|
||||
uint8_t trampCmsPitmode = 0;
|
||||
uint8_t trampCmsPitMode = 0;
|
||||
uint8_t trampCmsBand = 1;
|
||||
uint8_t trampCmsChan = 1;
|
||||
uint16_t trampCmsFreqRef;
|
||||
|
@ -477,7 +478,7 @@ static OSD_TAB_t trampCmsEntPower = { &trampCmsPower, 5, trampPowerNames };
|
|||
static void trampCmsUpdateFreqRef(void)
|
||||
{
|
||||
if (trampCmsBand > 0 && trampCmsChan > 0)
|
||||
trampCmsFreqRef = vtx58FreqTable[trampCmsBand - 1][trampCmsChan - 1];
|
||||
trampCmsFreqRef = vtx58frequencyTable[trampCmsBand - 1][trampCmsChan - 1];
|
||||
}
|
||||
|
||||
static long trampCmsConfigBand(displayPort_t *pDisp, const void *self)
|
||||
|
@ -520,24 +521,24 @@ static long trampCmsConfigPower(displayPort_t *pDisp, const void *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_INT16_t trampCmsEntTemp = { &trampCurTemp, -100, 300, 0 };
|
||||
static OSD_INT16_t trampCmsEntTemp = { &trampTemperature, -100, 300, 0 };
|
||||
|
||||
static const char * const trampCmsPitmodeNames[] = {
|
||||
static const char * const trampCmsPitModeNames[] = {
|
||||
"---", "OFF", "ON "
|
||||
};
|
||||
|
||||
static OSD_TAB_t trampCmsEntPitmode = { &trampCmsPitmode, 2, trampCmsPitmodeNames };
|
||||
static OSD_TAB_t trampCmsEntPitMode = { &trampCmsPitMode, 2, trampCmsPitModeNames };
|
||||
|
||||
static long trampCmsSetPitmode(displayPort_t *pDisp, const void *self)
|
||||
static long trampCmsSetPitMode(displayPort_t *pDisp, const void *self)
|
||||
{
|
||||
UNUSED(pDisp);
|
||||
UNUSED(self);
|
||||
|
||||
if (trampCmsPitmode == 0) {
|
||||
if (trampCmsPitMode == 0) {
|
||||
// Bouce back
|
||||
trampCmsPitmode = 1;
|
||||
trampCmsPitMode = 1;
|
||||
} else {
|
||||
trampSetPitmode(trampCmsPitmode - 1);
|
||||
trampSetPitMode(trampCmsPitMode - 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -548,7 +549,7 @@ static long trampCmsCommence(displayPort_t *pDisp, const void *self)
|
|||
UNUSED(pDisp);
|
||||
UNUSED(self);
|
||||
|
||||
trampSetBandChan(trampCmsBand, trampCmsChan);
|
||||
trampSetBandAndChannel(trampCmsBand, trampCmsChan);
|
||||
trampSetRFPower(trampPowerTable[trampCmsPower-1]);
|
||||
|
||||
// If it fails, the user should retry later
|
||||
|
@ -560,15 +561,15 @@ static long trampCmsCommence(displayPort_t *pDisp, const void *self)
|
|||
|
||||
static void trampCmsInitSettings()
|
||||
{
|
||||
if(trampCurBand > 0) trampCmsBand = trampCurBand;
|
||||
if(trampCurChan > 0) trampCmsChan = trampCurChan;
|
||||
if(trampBand > 0) trampCmsBand = trampBand;
|
||||
if(trampChannel > 0) trampCmsChan = trampChannel;
|
||||
|
||||
trampCmsUpdateFreqRef();
|
||||
trampCmsPitmode = trampCurPitmode + 1;
|
||||
trampCmsPitMode = trampPitMode + 1;
|
||||
|
||||
if (trampCurConfigPower > 0) {
|
||||
if (trampConfiguredPower > 0) {
|
||||
for (uint8_t i = 0; i < sizeof(trampPowerTable); i++) {
|
||||
if (trampCurConfigPower <= trampPowerTable[i]) {
|
||||
if (trampConfiguredPower <= trampPowerTable[i]) {
|
||||
trampCmsPower = i + 1;
|
||||
break;
|
||||
}
|
||||
|
@ -603,7 +604,7 @@ static OSD_Entry trampMenuEntries[] =
|
|||
{ "- TRAMP -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
{ "", OME_Label, NULL, trampCmsStatusString, DYNAMIC },
|
||||
{ "PIT", OME_TAB, trampCmsSetPitmode, &trampCmsEntPitmode, 0 },
|
||||
{ "PIT", OME_TAB, trampCmsSetPitMode, &trampCmsEntPitMode, 0 },
|
||||
{ "BAND", OME_TAB, trampCmsConfigBand, &trampCmsEntBand, 0 },
|
||||
{ "CHAN", OME_TAB, trampCmsConfigChan, &trampCmsEntChan, 0 },
|
||||
{ "(FREQ)", OME_UINT16, NULL, &trampCmsEntFreqRef, DYNAMIC },
|
||||
|
@ -639,10 +640,10 @@ bool vtxTrampIsReady(void)
|
|||
return trampStatus > TRAMP_STATUS_OFFLINE;
|
||||
}
|
||||
|
||||
void vtxTrampSetBandChan(uint8_t band, uint8_t chan)
|
||||
void vtxTrampSetBandAndChannel(uint8_t band, uint8_t channel)
|
||||
{
|
||||
if (band && chan) {
|
||||
trampSetBandChan(band, chan);
|
||||
if (band && channel) {
|
||||
trampSetBandAndChannel(band, channel);
|
||||
trampCommitChanges();
|
||||
}
|
||||
}
|
||||
|
@ -655,18 +656,18 @@ void vtxTrampSetPowerByIndex(uint8_t index)
|
|||
}
|
||||
}
|
||||
|
||||
void vtxTrampSetPitmode(uint8_t onoff)
|
||||
void vtxTrampSetPitMode(uint8_t onoff)
|
||||
{
|
||||
trampSetPitmode(onoff);
|
||||
trampSetPitMode(onoff);
|
||||
}
|
||||
|
||||
bool vtxTrampGetBandChan(uint8_t *pBand, uint8_t *pChan)
|
||||
bool vtxTrampGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
||||
{
|
||||
if (!vtxTrampIsReady())
|
||||
return false;
|
||||
|
||||
*pBand = trampCurBand;
|
||||
*pChan = trampCurChan;
|
||||
*pBand = trampBand;
|
||||
*pChannel = trampChannel;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -675,9 +676,9 @@ bool vtxTrampGetPowerIndex(uint8_t *pIndex)
|
|||
if (!vtxTrampIsReady())
|
||||
return false;
|
||||
|
||||
if (trampCurConfigPower > 0) {
|
||||
if (trampConfiguredPower > 0) {
|
||||
for (uint8_t i = 0; i < sizeof(trampPowerTable); i++) {
|
||||
if (trampCurConfigPower <= trampPowerTable[i]) {
|
||||
if (trampConfiguredPower <= trampPowerTable[i]) {
|
||||
*pIndex = i + 1;
|
||||
break;
|
||||
}
|
||||
|
@ -687,30 +688,30 @@ bool vtxTrampGetPowerIndex(uint8_t *pIndex)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vtxTrampGetPitmode(uint8_t *pOnoff)
|
||||
bool vtxTrampGetPitMode(uint8_t *pOnOff)
|
||||
{
|
||||
if (!vtxTrampIsReady())
|
||||
return false;
|
||||
|
||||
*pOnoff = trampCurPitmode;
|
||||
*pOnOff = trampPitMode;
|
||||
return true;
|
||||
}
|
||||
|
||||
static vtxVTable_t trampVTable = {
|
||||
static const vtxVTable_t trampVTable = {
|
||||
.process = vtxTrampProcess,
|
||||
.getDeviceType = vtxTrampGetDeviceType,
|
||||
.isReady = vtxTrampIsReady,
|
||||
.setBandChan = vtxTrampSetBandChan,
|
||||
.setBandAndChannel = vtxTrampSetBandAndChannel,
|
||||
.setPowerByIndex = vtxTrampSetPowerByIndex,
|
||||
.setPitmode = vtxTrampSetPitmode,
|
||||
.getBandChan = vtxTrampGetBandChan,
|
||||
.setPitMode = vtxTrampSetPitMode,
|
||||
.getBandAndChannel = vtxTrampGetBandAndChannel,
|
||||
.getPowerIndex = vtxTrampGetPowerIndex,
|
||||
.getPitmode = vtxTrampGetPitmode,
|
||||
.getPitMode = vtxTrampGetPitMode,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
bool trampInit()
|
||||
bool vtxTrampInit(void)
|
||||
{
|
||||
serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_VTX_TRAMP);
|
||||
|
||||
|
@ -723,7 +724,6 @@ bool trampInit()
|
|||
}
|
||||
|
||||
#if defined(VTX_COMMON)
|
||||
vtxTramp.vTable = &trampVTable;
|
||||
vtxCommonRegisterDevice(&vtxTramp);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
#if defined(VTX_TRAMP) && defined(VTX_CONTROL)
|
||||
|
||||
bool trampInit();
|
||||
void trampProcess(uint32_t currentTimeUs);
|
||||
bool vtxTrampInit();
|
||||
|
||||
#ifdef CMS
|
||||
#include "cms/cms.h"
|
||||
|
|
|
@ -116,7 +116,8 @@
|
|||
#define SDCARD_DMA_CHANNEL DMA_Channel_0
|
||||
|
||||
// *************** RTC6705 *************************
|
||||
#define USE_RTC6705
|
||||
#define VTX_RTC6705
|
||||
#define VTX_RTC6705SOFTSPI
|
||||
#define RTC6705_SPILE_PIN PB3
|
||||
#define RTC6705_SPICLK_PIN PB4
|
||||
#define RTC6705_SPIDATA_PIN PB5
|
||||
|
@ -127,7 +128,7 @@
|
|||
#define RSSI_ADC_PIN PC1
|
||||
|
||||
// *************** FEATURES ************************
|
||||
#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_VTX)
|
||||
#define DEFAULT_FEATURES (FEATURE_OSD)
|
||||
#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
|
||||
#define SERIALRX_PROVIDER SERIALRX_SBUS
|
||||
#define SERIALRX_UART SERIAL_PORT_USART3
|
||||
|
|
|
@ -5,4 +5,4 @@ TARGET_SRC = \
|
|||
drivers/accgyro/accgyro_spi_mpu6500.c \
|
||||
drivers/accgyro/accgyro_mpu6500.c \
|
||||
drivers/max7456.c \
|
||||
drivers/vtx_soft_spi_rtc6705.c
|
||||
drivers/vtx_rtc6705_soft_spi.c
|
||||
|
|
|
@ -72,9 +72,9 @@
|
|||
#define USE_SPI_DEVICE_1 // PA4, 5, 6, 7
|
||||
#define USE_SPI_DEVICE_2 // PB12,13,14,15 on AF5
|
||||
|
||||
#define VTX
|
||||
#define RTC6705_CS_GPIO GPIOA
|
||||
#define RTC6705_CS_PIN GPIO_Pin_4
|
||||
#define VTX_RTC6705
|
||||
|
||||
#define RTC6705_CS_PIN PA4
|
||||
#define RTC6705_SPI_INSTANCE SPI1
|
||||
|
||||
#define M25P16_CS_GPIO GPIOB
|
||||
|
|
|
@ -107,7 +107,9 @@
|
|||
#define MAX7456_DMA_CHANNEL_RX DMA2_Channel1
|
||||
#define MAX7456_DMA_IRQ_HANDLER_ID DMA2_CH1_HANDLER
|
||||
|
||||
#define USE_RTC6705
|
||||
#define VTX_RTC6705
|
||||
#define VTX_RTC6705SOFTSPI
|
||||
|
||||
#define RTC6705_SPIDATA_PIN PC15
|
||||
#define RTC6705_SPILE_PIN PC14
|
||||
#define RTC6705_SPICLK_PIN PC13
|
||||
|
@ -150,7 +152,7 @@
|
|||
#define SPEKTRUM_BIND_PIN UART3_RX_PIN
|
||||
|
||||
#define DEFAULT_RX_FEATURE FEATURE_RX_PPM
|
||||
#define DEFAULT_FEATURES (FEATURE_RX_SERIAL | FEATURE_OSD | FEATURE_VTX)
|
||||
#define DEFAULT_FEATURES (FEATURE_RX_SERIAL | FEATURE_OSD)
|
||||
|
||||
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@ TARGET_SRC = \
|
|||
drivers/compass/compass_ak8975.c \
|
||||
drivers/compass/compass_hmc5883l.c \
|
||||
drivers/flash_m25p16.c \
|
||||
drivers/vtx_soft_spi_rtc6705.c \
|
||||
drivers/vtx_rtc6705_soft_spi.c \
|
||||
drivers/max7456.c
|
||||
|
|
|
@ -101,13 +101,19 @@
|
|||
#define SPI3_MISO_PIN PB4
|
||||
#define SPI3_MOSI_PIN PB5
|
||||
|
||||
#define VTX
|
||||
#define RTC6705_CS_GPIO GPIOF
|
||||
#define RTC6705_CS_PIN GPIO_Pin_4
|
||||
#define RTC6705_SPI_INSTANCE SPI3
|
||||
#define VTX_RTC6705
|
||||
#define VTX_RTC6705_OPTIONAL // VTX/OSD board is OPTIONAL
|
||||
|
||||
#undef VTX_SMARTAUDIO // Disabled due to flash size
|
||||
#undef VTX_TRAMP // Disabled due to flash size
|
||||
|
||||
#define RTC6705_CS_PIN PF4
|
||||
#define RTC6705_SPI_INSTANCE SPI3
|
||||
#define RTC6705_POWER_PIN PC3
|
||||
|
||||
#define USE_RTC6705_CLK_HACK
|
||||
#define RTC6705_CLK_PIN SPI3_SCK_PIN
|
||||
|
||||
#define USE_MAX7456
|
||||
#define MAX7456_SPI_INSTANCE SPI3
|
||||
#define MAX7456_SPI_CS_PIN PA15
|
||||
|
@ -116,6 +122,8 @@
|
|||
#define MAX7456_DMA_CHANNEL_RX DMA2_Channel1
|
||||
#define MAX7456_DMA_IRQ_HANDLER_ID DMA2_CH1_HANDLER
|
||||
|
||||
#define SPI_SHARED_MAX7456_AND_RTC6705
|
||||
|
||||
#define USE_SDCARD
|
||||
#define USE_SDCARD_SPI2
|
||||
|
||||
|
|
|
@ -10,6 +10,4 @@ TARGET_SRC = \
|
|||
drivers/compass/compass_ak8975.c \
|
||||
drivers/compass/compass_hmc5883l.c \
|
||||
drivers/max7456.c \
|
||||
drivers/vtx_rtc6705.c \
|
||||
io/osd.c \
|
||||
io/vtx.c
|
||||
drivers/vtx_rtc6705.c
|
||||
|
|
|
@ -118,6 +118,12 @@
|
|||
#define SPI3_MISO_PIN PB4 // NC
|
||||
#define SPI3_MOSI_PIN PB5 // NC
|
||||
|
||||
#define VTX_RTC6705
|
||||
#define VTX_RTC6705_OPTIONAL // SPI3 on an F4 EVO may be used for RTC6705 VTX control.
|
||||
|
||||
#define RTC6705_CS_PIN SPI3_NSS_PIN
|
||||
#define RTC6705_SPI_INSTANCE SPI3
|
||||
|
||||
#define USE_SDCARD
|
||||
#define USE_SDCARD_SPI2
|
||||
|
||||
|
|
|
@ -9,10 +9,6 @@ TARGET_SRC = \
|
|||
drivers/compass/compass_ak8975.c \
|
||||
drivers/compass/compass_hmc5883l.c \
|
||||
drivers/max7456.c \
|
||||
drivers/transponder_ir.c \
|
||||
drivers/vtx_rtc6705.c \
|
||||
io/osd.c \
|
||||
io/transponder_ir.c \
|
||||
io/vtx.c
|
||||
drivers/vtx_rtc6705.c
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
#pragma once
|
||||
|
||||
// Targets with built-in vtx do not need external vtx
|
||||
#if defined(VTX) || defined(USE_RTC6705)
|
||||
# undef VTX_CONTROL
|
||||
#if defined(VTX_RTC6705) && !defined(VTX_RTC6705_OPTIONAL)
|
||||
# undef VTX_SMARTAUDIO
|
||||
# undef VTX_TRAMP
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue