mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Merge pull request #6522 from awolf78/LUA_VTX_support
VTX LUA support for external VTX devices
This commit is contained in:
commit
701bcd24da
1 changed files with 33 additions and 32 deletions
|
@ -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();
|
||||||
|
uint8_t pitmode=0;
|
||||||
|
vtxDevType_e vtxType = VTXDEV_UNKNOWN;
|
||||||
if (vtxDevice) {
|
if (vtxDevice) {
|
||||||
uint8_t pitmode=0;
|
|
||||||
vtxCommonGetPitMode(vtxDevice, &pitmode);
|
vtxCommonGetPitMode(vtxDevice, &pitmode);
|
||||||
sbufWriteU8(dst, vtxCommonGetDeviceType(vtxDevice));
|
vtxType = vtxCommonGetDeviceType(vtxDevice);
|
||||||
sbufWriteU8(dst, vtxSettingsConfig()->band);
|
|
||||||
sbufWriteU8(dst, vtxSettingsConfig()->channel);
|
|
||||||
sbufWriteU8(dst, vtxSettingsConfig()->power);
|
|
||||||
sbufWriteU8(dst, pitmode);
|
|
||||||
sbufWriteU16(dst, vtxSettingsConfig()->freq);
|
|
||||||
// future extensions here...
|
|
||||||
} else {
|
|
||||||
sbufWriteU8(dst, VTXDEV_UNKNOWN); // no VTX detected
|
|
||||||
}
|
}
|
||||||
|
sbufWriteU8(dst, vtxType);
|
||||||
|
sbufWriteU8(dst, vtxSettingsConfig()->band);
|
||||||
|
sbufWriteU8(dst, vtxSettingsConfig()->channel);
|
||||||
|
sbufWriteU8(dst, vtxSettingsConfig()->power);
|
||||||
|
sbufWriteU8(dst, pitmode);
|
||||||
|
sbufWriteU16(dst, vtxSettingsConfig()->freq);
|
||||||
|
// future extensions here...
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1972,29 +1971,31 @@ 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);
|
}
|
||||||
if (newFrequency <= VTXCOMMON_MSP_BANDCHAN_CHKVAL) { //value is band and channel
|
uint16_t newFrequency = sbufReadU16(src);
|
||||||
const uint8_t newBand = (newFrequency / 8) + 1;
|
if (newFrequency <= VTXCOMMON_MSP_BANDCHAN_CHKVAL) { //value is band and channel
|
||||||
const uint8_t newChannel = (newFrequency % 8) + 1;
|
const uint8_t newBand = (newFrequency / 8) + 1;
|
||||||
vtxSettingsConfigMutable()->band = newBand;
|
const uint8_t newChannel = (newFrequency % 8) + 1;
|
||||||
vtxSettingsConfigMutable()->channel = newChannel;
|
vtxSettingsConfigMutable()->band = newBand;
|
||||||
vtxSettingsConfigMutable()->freq = vtx58_Bandchan2Freq(newBand, newChannel);
|
vtxSettingsConfigMutable()->channel = newChannel;
|
||||||
} else { //value is frequency in MHz
|
vtxSettingsConfigMutable()->freq = vtx58_Bandchan2Freq(newBand, newChannel);
|
||||||
vtxSettingsConfigMutable()->band = 0;
|
} else { //value is frequency in MHz
|
||||||
vtxSettingsConfigMutable()->freq = newFrequency;
|
vtxSettingsConfigMutable()->band = 0;
|
||||||
}
|
vtxSettingsConfigMutable()->freq = newFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
if (sbufBytesRemaining(src) > 1) {
|
if (sbufBytesRemaining(src) > 1) {
|
||||||
vtxSettingsConfigMutable()->power = sbufReadU8(src);
|
vtxSettingsConfigMutable()->power = sbufReadU8(src);
|
||||||
// Delegate pitmode to vtx directly
|
if (vtxType != VTXDEV_UNKNOWN) {
|
||||||
const uint8_t newPitmode = sbufReadU8(src);
|
// Delegate pitmode to vtx directly
|
||||||
uint8_t currentPitmode = 0;
|
const uint8_t newPitmode = sbufReadU8(src);
|
||||||
vtxCommonGetPitMode(vtxDevice, ¤tPitmode);
|
uint8_t currentPitmode = 0;
|
||||||
if (currentPitmode != newPitmode) {
|
vtxCommonGetPitMode(vtxDevice, ¤tPitmode);
|
||||||
vtxCommonSetPitMode(vtxDevice, newPitmode);
|
if (currentPitmode != newPitmode) {
|
||||||
}
|
vtxCommonSetPitMode(vtxDevice, newPitmode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue