1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Merge pull request #5000 from martinbudden/bfa_vtx_tidy

Corrected VTX vtables to not use static device handle
This commit is contained in:
Michael Keller 2018-02-02 01:16:54 +13:00 committed by GitHub
commit 666c2980e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 259 additions and 281 deletions

View file

@ -1213,11 +1213,11 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
#if defined(USE_VTX_COMMON)
case MSP_VTX_CONFIG:
{
uint8_t deviceType = vtxCommonGetDeviceType();
if (deviceType != VTXDEV_UNKNOWN) {
const vtxDevice_t *vtxDevice = vtxCommonDevice();
if (vtxDevice) {
uint8_t pitmode=0;
vtxCommonGetPitMode(&pitmode);
sbufWriteU8(dst, deviceType);
vtxCommonGetPitMode(vtxDevice, &pitmode);
sbufWriteU8(dst, vtxCommonGetDeviceType(vtxDevice));
sbufWriteU8(dst, vtxSettingsConfig()->band);
sbufWriteU8(dst, vtxSettingsConfig()->channel);
sbufWriteU8(dst, vtxSettingsConfig()->power);
@ -1730,8 +1730,9 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
#ifdef USE_VTX_COMMON
case MSP_SET_VTX_CONFIG:
{
if (vtxCommonDeviceRegistered()) {
if (vtxCommonGetDeviceType() != VTXDEV_UNKNOWN) {
vtxDevice_t *vtxDevice = vtxCommonDevice();
if (vtxDevice) {
if (vtxCommonGetDeviceType(vtxDevice) != VTXDEV_UNKNOWN) {
uint16_t newFrequency = sbufReadU16(src);
if (newFrequency <= VTXCOMMON_MSP_BANDCHAN_CHKVAL) { //value is band and channel
const uint8_t newBand = (newFrequency / 8) + 1;
@ -1749,9 +1750,9 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
// Delegate pitmode to vtx directly
const uint8_t newPitmode = sbufReadU8(src);
uint8_t currentPitmode = 0;
vtxCommonGetPitMode(&currentPitmode);
vtxCommonGetPitMode(vtxDevice, &currentPitmode);
if (currentPitmode != newPitmode) {
vtxCommonSetPitMode(newPitmode);
vtxCommonSetPitMode(vtxDevice, newPitmode);
}
}
}