40 #include "vtxsettings.h"
63 #define STACK_SIZE_BYTES 560
64 #define TASK_PRIORITY PIOS_THREAD_PRIO_LOW
67 #define TBS_MIN_BAUD 4600
68 #define TBS_MAX_BAUD 5100
72 static const uint16_t
BAND_5G8_A_FREQS[VTXSETTINGS_BAND_5G8_A_FREQUENCY_MAXOPTVAL + 1] = {
73 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH15865] = 5865,
74 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH25845] = 5845,
75 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH35825] = 5825,
76 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH45805] = 5805,
77 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH55785] = 5785,
78 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH65765] = 5765,
79 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH75745] = 5745,
80 [VTXSETTINGS_BAND_5G8_A_FREQUENCY_CH85725] = 5725
83 static const uint16_t
BAND_5G8_B_FREQS[VTXSETTINGS_BAND_5G8_B_FREQUENCY_MAXOPTVAL + 1] = {
84 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH15733] = 5733,
85 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH25752] = 5752,
86 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH35771] = 5771,
87 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH45790] = 5790,
88 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH55809] = 5809,
89 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH65828] = 5828,
90 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH75847] = 5847,
91 [VTXSETTINGS_BAND_5G8_B_FREQUENCY_CH85866] = 5866
94 static const uint16_t
BAND_5G8_E_FREQS[VTXSETTINGS_BAND_5G8_E_FREQUENCY_MAXOPTVAL + 1] = {
95 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH15705] = 5705,
96 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH25685] = 5685,
97 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH35665] = 5665,
98 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH45645] = 5645,
99 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH55885] = 5885,
100 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH65905] = 5905,
101 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH75925] = 5925,
102 [VTXSETTINGS_BAND_5G8_E_FREQUENCY_CH85945] = 5945
105 static const uint16_t
AIRWAVE_FREQS[VTXSETTINGS_AIRWAVE_FREQUENCY_MAXOPTVAL + 1] = {
106 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH15740] = 5740,
107 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH25760] = 5760,
108 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH35780] = 5780,
109 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH45800] = 5800,
110 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH55820] = 5820,
111 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH65840] = 5840,
112 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH75860] = 5860,
113 [VTXSETTINGS_AIRWAVE_FREQUENCY_CH85880] = 5880
116 static const uint16_t
RACEBAND_FREQS[VTXSETTINGS_RACEBAND_FREQUENCY_MAXOPTVAL + 1] = {
117 [VTXSETTINGS_RACEBAND_FREQUENCY_CH15658] = 5658,
118 [VTXSETTINGS_RACEBAND_FREQUENCY_CH25695] = 5695,
119 [VTXSETTINGS_RACEBAND_FREQUENCY_CH35732] = 5732,
120 [VTXSETTINGS_RACEBAND_FREQUENCY_CH45769] = 5769,
121 [VTXSETTINGS_RACEBAND_FREQUENCY_CH55806] = 5806,
122 [VTXSETTINGS_RACEBAND_FREQUENCY_CH65843] = 5843,
123 [VTXSETTINGS_RACEBAND_FREQUENCY_CH75880] = 5880,
124 [VTXSETTINGS_RACEBAND_FREQUENCY_CH85917] = 5917
127 static const uint16_t
VTX_POWER[VTXSETTINGS_POWER_GLOBAL_MAXOPTVAL + 1] = {
128 [VTXSETTINGS_POWER_25] = 25,
129 [VTXSETTINGS_POWER_200] = 200,
130 [VTXSETTINGS_POWER_500] = 500,
131 [VTXSETTINGS_POWER_800] = 800,
144 #if defined(PIOS_INCLUDE_TBSVTXCONFIG)
176 #if defined(PIOS_INCLUDE_TBSVTXCONFIG)
190 VTXSettingsInitialize();
216 bool update_vtx =
false;
218 VTXSettingsGet(&settings);
234 VTXSettingsGet(&settings);
242 info.State = VTXINFO_STATE_CONNECTED;
254 memset((
void*)&info, 0,
sizeof(info));
255 info.State = VTXINFO_STATE_DISCONNECTED;
262 if ((settings.Mode == VTXSETTINGS_MODE_ACTIVE) && update_vtx) {
266 switch (settings.Band) {
267 case VTXSETTINGS_BAND_BAND5G8A:
270 case VTXSETTINGS_BAND_BAND5G8B:
273 case VTXSETTINGS_BAND_BAND5G8E:
276 case VTXSETTINGS_BAND_AIRWAVE:
279 case VTXSETTINGS_BAND_RACEBAND:
287 if (frequency != info.Frequency) {
297 if ((info.Power != 0) && (
VTX_POWER[settings.Power] != info.Power)) {
static const uint16_t BAND_5G8_A_FREQS[VTXSETTINGS_BAND_5G8_A_FREQUENCY_MAXOPTVAL+1]
static uint32_t vtxConfigPort
static struct pios_thread * vtxConfigTaskHandle
int32_t VTXConfigInitialize(void)
static void vtxConfigTask(void *parameters)
bool PIOS_Modules_IsEnabled(enum pios_modules module)
uintptr_t pios_com_tbsvtxconfig_id
void UAVObjCbSetFlag(const UAVObjEvent *objEv, void *ctx, void *obj, int len)
static const uint16_t RACEBAND_FREQS[VTXSETTINGS_RACEBAND_FREQUENCY_MAXOPTVAL+1]
int32_t tbsvtx_set_freq(uintptr_t usart_id, uint16_t frequency)
static const uint16_t AIRWAVE_FREQS[VTXSETTINGS_AIRWAVE_FREQUENCY_MAXOPTVAL+1]
static const uint16_t VTX_POWER[VTXSETTINGS_POWER_GLOBAL_MAXOPTVAL+1]
static bool module_enabled
static enum VTXTYPE vtx_type
static volatile FlightStatsSettingsData settings
int32_t tbsvtx_set_power(uintptr_t usart_id, uint16_t power)
struct pios_thread * PIOS_Thread_Create(void(*fp)(void *), const char *namep, size_t stack_bytes, void *argp, enum pios_thread_prio_e prio)
This module configures the video transmitter.
int32_t TaskMonitorAdd(TaskInfoRunningElem task, struct pios_thread *threadp)
int32_t VTXConfigStart(void)
void PIOS_Thread_Sleep(uint32_t time_ms)
Includes PiOS and core architecture components.
MODULE_INITCALL(VTXConfigInitialize, VTXConfigStart)
static const uint16_t BAND_5G8_E_FREQS[VTXSETTINGS_BAND_5G8_E_FREQUENCY_MAXOPTVAL+1]
static volatile bool settings_updated
static const uint16_t BAND_5G8_B_FREQS[VTXSETTINGS_BAND_5G8_B_FREQUENCY_MAXOPTVAL+1]
int32_t tbsvtx_get_state(uintptr_t usart_id, VTXInfoData *info)
int32_t PIOS_COM_ChangeBaud(uintptr_t com_id, uint32_t baud)