Tidy of VTX common
This commit is contained in:
parent
39727ce384
commit
3c12367c84
|
@ -50,7 +50,7 @@ static const char * const rtc6705BandNames[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static OSD_TAB_t entryVtxBand = {&cmsx_vtxBand, ARRAYLEN(rtc6705BandNames) - 1, &rtc6705BandNames[0]};
|
static OSD_TAB_t entryVtxBand = {&cmsx_vtxBand, ARRAYLEN(rtc6705BandNames) - 1, &rtc6705BandNames[0]};
|
||||||
static OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, VTX_RTC6705_CHANNEL_COUNT, 1};
|
static OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, VTX_SETTINGS_CHANNEL_COUNT, 1};
|
||||||
static OSD_TAB_t entryVtxPower = {&cmsx_vtxPower, VTX_RTC6705_POWER_COUNT - 1 - VTX_RTC6705_MIN_POWER, &rtc6705PowerNames[VTX_RTC6705_MIN_POWER]};
|
static OSD_TAB_t entryVtxPower = {&cmsx_vtxPower, VTX_RTC6705_POWER_COUNT - 1 - VTX_RTC6705_MIN_POWER, &rtc6705PowerNames[VTX_RTC6705_MIN_POWER]};
|
||||||
|
|
||||||
static void cmsx_Vtx_ConfigRead(void)
|
static void cmsx_Vtx_ConfigRead(void)
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "build/debug.h"
|
|
||||||
#include "common/time.h"
|
|
||||||
#include "drivers/vtx_common.h"
|
|
||||||
#include "fc/config.h"
|
|
||||||
|
|
||||||
#if defined(VTX_COMMON)
|
#if defined(VTX_COMMON)
|
||||||
|
|
||||||
|
#include "common/time.h"
|
||||||
|
#include "drivers/vtx_common.h"
|
||||||
|
|
||||||
|
|
||||||
vtxDevice_t *vtxDevice = NULL;
|
vtxDevice_t *vtxDevice = NULL;
|
||||||
|
|
||||||
void vtxCommonInit(void)
|
void vtxCommonInit(void)
|
||||||
|
@ -48,8 +48,9 @@ bool vtxCommonDeviceRegistered(void)
|
||||||
|
|
||||||
vtxDevType_e vtxCommonGetDeviceType(void)
|
vtxDevType_e vtxCommonGetDeviceType(void)
|
||||||
{
|
{
|
||||||
if (!vtxDevice || !vtxDevice->vTable->getDeviceType)
|
if (!vtxDevice || !vtxDevice->vTable->getDeviceType) {
|
||||||
return VTXDEV_UNKNOWN;
|
return VTXDEV_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
return vtxDevice->vTable->getDeviceType();
|
return vtxDevice->vTable->getDeviceType();
|
||||||
}
|
}
|
||||||
|
@ -83,9 +84,10 @@ void vtxCommonSetPowerByIndex(uint8_t index)
|
||||||
// on = 1, off = 0
|
// on = 1, off = 0
|
||||||
void vtxCommonSetPitMode(uint8_t onoff)
|
void vtxCommonSetPitMode(uint8_t onoff)
|
||||||
{
|
{
|
||||||
if (vtxDevice->vTable->setPitMode)
|
if (vtxDevice->vTable->setPitMode) {
|
||||||
vtxDevice->vTable->setPitMode(onoff);
|
vtxDevice->vTable->setPitMode(onoff);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void vtxCommonSetFrequency(uint16_t freq)
|
void vtxCommonSetFrequency(uint16_t freq)
|
||||||
{
|
{
|
||||||
|
@ -96,33 +98,38 @@ void vtxCommonSetFrequency(uint16_t freq)
|
||||||
|
|
||||||
bool vtxCommonGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
bool vtxCommonGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
||||||
{
|
{
|
||||||
if (vtxDevice->vTable->getBandAndChannel)
|
if (vtxDevice->vTable->getBandAndChannel) {
|
||||||
return vtxDevice->vTable->getBandAndChannel(pBand, pChannel);
|
return vtxDevice->vTable->getBandAndChannel(pBand, pChannel);
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool vtxCommonGetPowerIndex(uint8_t *pIndex)
|
bool vtxCommonGetPowerIndex(uint8_t *pIndex)
|
||||||
{
|
{
|
||||||
if (!vtxDevice)
|
if (!vtxDevice) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtxDevice->vTable->getPowerIndex)
|
if (vtxDevice->vTable->getPowerIndex) {
|
||||||
return vtxDevice->vTable->getPowerIndex(pIndex);
|
return vtxDevice->vTable->getPowerIndex(pIndex);
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool vtxCommonGetPitMode(uint8_t *pOnOff)
|
bool vtxCommonGetPitMode(uint8_t *pOnOff)
|
||||||
{
|
{
|
||||||
if (!vtxDevice)
|
if (!vtxDevice) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtxDevice->vTable->getPitMode)
|
if (vtxDevice->vTable->getPitMode) {
|
||||||
return vtxDevice->vTable->getPitMode(pOnOff);
|
return vtxDevice->vTable->getPitMode(pOnOff);
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool vtxCommonGetFrequency(uint16_t *pFreq)
|
bool vtxCommonGetFrequency(uint16_t *pFreq)
|
||||||
{
|
{
|
||||||
|
@ -138,8 +145,9 @@ bool vtxCommonGetFrequency(uint16_t *pFreq)
|
||||||
|
|
||||||
bool vtxCommonGetDeviceCapability(vtxDeviceCapability_t *pDeviceCapability)
|
bool vtxCommonGetDeviceCapability(vtxDeviceCapability_t *pDeviceCapability)
|
||||||
{
|
{
|
||||||
if (!vtxDevice)
|
if (!vtxDevice) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(pDeviceCapability, &vtxDevice->capability, sizeof(vtxDeviceCapability_t));
|
memcpy(pDeviceCapability, &vtxDevice->capability, sizeof(vtxDeviceCapability_t));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -19,8 +19,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
#include "common/time.h"
|
#include "common/time.h"
|
||||||
#include "io/vtx.h"
|
|
||||||
|
|
||||||
#define VTX_SETTINGS_MIN_BAND 1
|
#define VTX_SETTINGS_MIN_BAND 1
|
||||||
#define VTX_SETTINGS_MAX_BAND 5
|
#define VTX_SETTINGS_MAX_BAND 5
|
||||||
|
@ -94,7 +97,6 @@ typedef enum {
|
||||||
#define VTX_TRAMP_POWER_400 4
|
#define VTX_TRAMP_POWER_400 4
|
||||||
#define VTX_TRAMP_POWER_600 5
|
#define VTX_TRAMP_POWER_600 5
|
||||||
|
|
||||||
struct vtxVTable_s;
|
|
||||||
|
|
||||||
typedef struct vtxDeviceCapability_s {
|
typedef struct vtxDeviceCapability_s {
|
||||||
uint8_t bandCount;
|
uint8_t bandCount;
|
||||||
|
@ -102,29 +104,12 @@ typedef struct vtxDeviceCapability_s {
|
||||||
uint8_t powerCount;
|
uint8_t powerCount;
|
||||||
} vtxDeviceCapability_t;
|
} vtxDeviceCapability_t;
|
||||||
|
|
||||||
typedef struct vtxDevice_s {
|
|
||||||
const struct vtxVTable_s * const vTable;
|
|
||||||
|
|
||||||
vtxDeviceCapability_t capability;
|
|
||||||
|
|
||||||
uint16_t *frequencyTable; // Array of [bandCount][channelCount]
|
|
||||||
char **bandNames; // char *bandNames[bandCount]
|
|
||||||
char **channelNames; // char *channelNames[channelCount]
|
|
||||||
char **powerNames; // char *powerNames[powerCount]
|
|
||||||
|
|
||||||
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}BandAndChannel: band and channel are 1 origin
|
// {set,get}BandAndChannel: band and channel are 1 origin
|
||||||
// {set,get}PowerByIndex: 0 = Power OFF, 1 = device dependent
|
// {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 {
|
typedef struct vtxVTable_s {
|
||||||
void (*process)(uint32_t currentTimeUs);
|
void (*process)(timeUs_t currentTimeUs);
|
||||||
vtxDevType_e (*getDeviceType)(void);
|
vtxDevType_e (*getDeviceType)(void);
|
||||||
bool (*isReady)(void);
|
bool (*isReady)(void);
|
||||||
|
|
||||||
|
@ -139,6 +124,23 @@ typedef struct vtxVTable_s {
|
||||||
bool (*getFrequency)(uint16_t *pFreq);
|
bool (*getFrequency)(uint16_t *pFreq);
|
||||||
} vtxVTable_t;
|
} vtxVTable_t;
|
||||||
|
|
||||||
|
typedef struct vtxDevice_s {
|
||||||
|
const vtxVTable_t * const vTable;
|
||||||
|
|
||||||
|
vtxDeviceCapability_t capability;
|
||||||
|
|
||||||
|
uint16_t *frequencyTable; // Array of [bandCount][channelCount]
|
||||||
|
char **bandNames; // char *bandNames[bandCount]
|
||||||
|
char **channelNames; // char *channelNames[channelCount]
|
||||||
|
char **powerNames; // char *powerNames[powerCount]
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
// 3.1.0
|
// 3.1.0
|
||||||
// PIT mode is defined as LOWEST POSSIBLE RF POWER.
|
// PIT mode is defined as LOWEST POSSIBLE RF POWER.
|
||||||
// - It can be a dedicated mode, or lowest RF power possible.
|
// - It can be a dedicated mode, or lowest RF power possible.
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#include "io/gps.h"
|
#include "io/gps.h"
|
||||||
#include "io/ledstrip.h"
|
#include "io/ledstrip.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
|
#include "io/vtx.h"
|
||||||
#include "io/vtx_control.h"
|
#include "io/vtx_control.h"
|
||||||
#include "io/vtx_rtc6705.h"
|
#include "io/vtx_rtc6705.h"
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,24 @@
|
||||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#if defined(VTX_COMMON)
|
||||||
|
|
||||||
#include "common/time.h"
|
#include "common/time.h"
|
||||||
|
|
||||||
|
#include "config/parameter_group.h"
|
||||||
|
#include "config/parameter_group_ids.h"
|
||||||
|
|
||||||
#include "drivers/vtx_common.h"
|
#include "drivers/vtx_common.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
|
|
||||||
#include "io/vtx.h"
|
#include "io/vtx.h"
|
||||||
#include "io/vtx_string.h"
|
#include "io/vtx_string.h"
|
||||||
|
|
||||||
#if defined(VTX_COMMON)
|
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_TEMPLATE(vtxSettingsConfig_t, vtxSettingsConfig, PG_VTX_SETTINGS_CONFIG, 0);
|
PG_REGISTER_WITH_RESET_TEMPLATE(vtxSettingsConfig_t, vtxSettingsConfig, PG_VTX_SETTINGS_CONFIG, 0);
|
||||||
|
|
||||||
|
@ -64,11 +75,10 @@ void vtxProcess(timeUs_t currentTimeUs)
|
||||||
static uint8_t scheduleIndex;
|
static uint8_t scheduleIndex;
|
||||||
|
|
||||||
if (vtxCommonDeviceRegistered()) {
|
if (vtxCommonDeviceRegistered()) {
|
||||||
uint8_t currentSchedule = vtxParamSchedule[scheduleIndex];
|
const uint8_t currentSchedule = vtxParamSchedule[scheduleIndex];
|
||||||
// Process VTX changes from the parameter group at 10Hz
|
// Process VTX changes from the parameter group at 10Hz
|
||||||
if (currentTimeUs > lastCycleTimeUs + VTX_PARAM_CYCLE_TIME_US) {
|
if (currentTimeUs > lastCycleTimeUs + VTX_PARAM_CYCLE_TIME_US) {
|
||||||
switch (currentSchedule)
|
switch (currentSchedule) {
|
||||||
{
|
|
||||||
case VTX_PARAM_BANDCHAN:
|
case VTX_PARAM_BANDCHAN:
|
||||||
if (vtxSettingsConfig()->band) {
|
if (vtxSettingsConfig()->band) {
|
||||||
uint8_t vtxBand;
|
uint8_t vtxBand;
|
||||||
|
|
|
@ -17,10 +17,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "drivers/vtx_common.h"
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
#include "common/time.h"
|
||||||
#include "config/parameter_group.h"
|
#include "config/parameter_group.h"
|
||||||
#include "config/parameter_group_ids.h"
|
|
||||||
|
|
||||||
typedef struct vtxSettingsConfig_s {
|
typedef struct vtxSettingsConfig_s {
|
||||||
uint8_t band; // 1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
|
uint8_t band; // 1=A, 2=B, 3=E, 4=F(Airwaves/Fatshark), 5=Raceband
|
||||||
|
@ -32,4 +33,4 @@ typedef struct vtxSettingsConfig_s {
|
||||||
PG_DECLARE(vtxSettingsConfig_t, vtxSettingsConfig);
|
PG_DECLARE(vtxSettingsConfig_t, vtxSettingsConfig);
|
||||||
|
|
||||||
void vtxInit(void);
|
void vtxInit(void);
|
||||||
void vtxProcess(uint32_t currentTimeUs);
|
void vtxProcess(timeUs_t currentTimeUs);
|
||||||
|
|
|
@ -62,8 +62,8 @@ const char * const rtc6705PowerNames[VTX_RTC6705_POWER_COUNT] = {
|
||||||
static vtxVTable_t rtc6705VTable; // Forward
|
static vtxVTable_t rtc6705VTable; // Forward
|
||||||
static vtxDevice_t vtxRTC6705 = {
|
static vtxDevice_t vtxRTC6705 = {
|
||||||
.vTable = &rtc6705VTable,
|
.vTable = &rtc6705VTable,
|
||||||
.capability.bandCount = VTX_RTC6705_BAND_COUNT,
|
.capability.bandCount = VTX_SETTINGS_BAND_COUNT,
|
||||||
.capability.channelCount = VTX_RTC6705_CHANNEL_COUNT,
|
.capability.channelCount = VTX_SETTINGS_CHANNEL_COUNT,
|
||||||
.capability.powerCount = VTX_RTC6705_POWER_COUNT,
|
.capability.powerCount = VTX_RTC6705_POWER_COUNT,
|
||||||
.bandNames = (char **)vtx58BandNames,
|
.bandNames = (char **)vtx58BandNames,
|
||||||
.channelNames = (char **)vtx58ChannelNames,
|
.channelNames = (char **)vtx58ChannelNames,
|
||||||
|
|
|
@ -22,13 +22,6 @@
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#define VTX_RTC6705_MIN_BAND 1
|
|
||||||
#define VTX_RTC6705_MAX_BAND 5
|
|
||||||
#define VTX_RTC6705_MIN_CHANNEL 1
|
|
||||||
#define VTX_RTC6705_MAX_CHANNEL 8
|
|
||||||
|
|
||||||
#define VTX_RTC6705_BAND_COUNT (VTX_RTC6705_MAX_BAND - VTX_RTC6705_MIN_BAND + 1)
|
|
||||||
#define VTX_RTC6705_CHANNEL_COUNT (VTX_RTC6705_MAX_CHANNEL - VTX_RTC6705_MIN_CHANNEL + 1)
|
|
||||||
|
|
||||||
#define VTX_RTC6705_POWER_COUNT 3
|
#define VTX_RTC6705_POWER_COUNT 3
|
||||||
#define VTX_RTC6705_DEFAULT_POWER 1
|
#define VTX_RTC6705_DEFAULT_POWER 1
|
||||||
|
|
|
@ -3,15 +3,13 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "drivers/vtx_common.h"
|
||||||
|
|
||||||
#if defined(VTX_COMMON)
|
|
||||||
|
|
||||||
extern const uint16_t vtx58frequencyTable[5][8];
|
extern const uint16_t vtx58frequencyTable[VTX_SETTINGS_BAND_COUNT][VTX_SETTINGS_CHANNEL_COUNT];
|
||||||
extern const char * const vtx58BandNames[];
|
extern const char * const vtx58BandNames[];
|
||||||
extern const char * const vtx58ChannelNames[];
|
extern const char * const vtx58ChannelNames[];
|
||||||
extern const char vtx58BandLetter[];
|
extern const char vtx58BandLetter[];
|
||||||
|
|
||||||
bool vtx58_Freq2Bandchan(uint16_t freq, uint8_t *pBand, uint8_t *pChannel);
|
bool vtx58_Freq2Bandchan(uint16_t freq, uint8_t *pBand, uint8_t *pChannel);
|
||||||
uint16_t vtx58_Bandchan2Freq(uint8_t band, uint8_t channel);
|
uint16_t vtx58_Bandchan2Freq(uint8_t band, uint8_t channel);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "drivers/vtx_common.h"
|
#include "drivers/vtx_common.h"
|
||||||
|
|
||||||
#include "io/serial.h"
|
#include "io/serial.h"
|
||||||
|
#include "io/vtx.h"
|
||||||
#include "io/vtx_string.h"
|
#include "io/vtx_string.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
|
|
Loading…
Reference in New Issue