1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

Merge pull request #6522 from awolf78/LUA_VTX_support

VTX LUA support for external VTX devices
This commit is contained in:
Michael Keller 2018-08-17 00:35:39 +12:00 committed by GitHub
commit 701bcd24da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1337,21 +1337,20 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
case MSP_VTX_CONFIG: case MSP_VTX_CONFIG:
{ {
const vtxDevice_t *vtxDevice = vtxCommonDevice(); const vtxDevice_t *vtxDevice = vtxCommonDevice();
if (vtxDevice) {
uint8_t pitmode=0; uint8_t pitmode=0;
vtxDevType_e vtxType = VTXDEV_UNKNOWN;
if (vtxDevice) {
vtxCommonGetPitMode(vtxDevice, &pitmode); vtxCommonGetPitMode(vtxDevice, &pitmode);
sbufWriteU8(dst, vtxCommonGetDeviceType(vtxDevice)); vtxType = vtxCommonGetDeviceType(vtxDevice);
}
sbufWriteU8(dst, vtxType);
sbufWriteU8(dst, vtxSettingsConfig()->band); sbufWriteU8(dst, vtxSettingsConfig()->band);
sbufWriteU8(dst, vtxSettingsConfig()->channel); sbufWriteU8(dst, vtxSettingsConfig()->channel);
sbufWriteU8(dst, vtxSettingsConfig()->power); sbufWriteU8(dst, vtxSettingsConfig()->power);
sbufWriteU8(dst, pitmode); sbufWriteU8(dst, pitmode);
sbufWriteU16(dst, vtxSettingsConfig()->freq); sbufWriteU16(dst, vtxSettingsConfig()->freq);
// future extensions here... // future extensions here...
} else {
sbufWriteU8(dst, VTXDEV_UNKNOWN); // no VTX detected
} }
}
break; break;
#endif #endif
@ -1972,8 +1971,10 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
case MSP_SET_VTX_CONFIG: case MSP_SET_VTX_CONFIG:
{ {
vtxDevice_t *vtxDevice = vtxCommonDevice(); vtxDevice_t *vtxDevice = vtxCommonDevice();
vtxDevType_e vtxType = VTXDEV_UNKNOWN;
if (vtxDevice) { if (vtxDevice) {
if (vtxCommonGetDeviceType(vtxDevice) != VTXDEV_UNKNOWN) { vtxType = vtxCommonGetDeviceType(vtxDevice);
}
uint16_t newFrequency = sbufReadU16(src); uint16_t newFrequency = sbufReadU16(src);
if (newFrequency <= VTXCOMMON_MSP_BANDCHAN_CHKVAL) { //value is band and channel if (newFrequency <= VTXCOMMON_MSP_BANDCHAN_CHKVAL) { //value is band and channel
const uint8_t newBand = (newFrequency / 8) + 1; const uint8_t newBand = (newFrequency / 8) + 1;
@ -1988,6 +1989,7 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
if (sbufBytesRemaining(src) > 1) { if (sbufBytesRemaining(src) > 1) {
vtxSettingsConfigMutable()->power = sbufReadU8(src); vtxSettingsConfigMutable()->power = sbufReadU8(src);
if (vtxType != VTXDEV_UNKNOWN) {
// Delegate pitmode to vtx directly // Delegate pitmode to vtx directly
const uint8_t newPitmode = sbufReadU8(src); const uint8_t newPitmode = sbufReadU8(src);
uint8_t currentPitmode = 0; uint8_t currentPitmode = 0;
@ -1998,7 +2000,6 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
} }
} }
} }
}
break; break;
#endif #endif