mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 17:55:30 +03:00
[SmartAudio] improved readability of vtxSASetPitMode
This commit is contained in:
parent
1b710ca3c8
commit
7f4ef5f2d6
1 changed files with 15 additions and 16 deletions
|
@ -929,20 +929,19 @@ static void vtxSASetPitMode(vtxDevice_t *vtxDevice, uint8_t onoff)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onoff && saDevice.version>=3 && !saDevice.willBootIntoPitMode) {
|
if(saDevice.version >= 3 && !saDevice.willBootIntoPitMode) {
|
||||||
// enable pitmode using SET_POWER command with 0 dbm.
|
if (onoff) {
|
||||||
// This enables pitmode without causing the device to boot into pitmode next power-up
|
// enable pitmode using SET_POWER command with 0 dbm.
|
||||||
static uint8_t buf[6] = { 0xAA, 0x55, SACMD(SA_CMD_SET_POWER), 1 };
|
// This enables pitmode without causing the device to boot into pitmode next power-up
|
||||||
buf[4] = 0 | 128;
|
static uint8_t buf[6] = { 0xAA, 0x55, SACMD(SA_CMD_SET_POWER), 1 };
|
||||||
buf[5] = CRC8(buf,5);
|
buf[4] = 0 | 128;
|
||||||
saQueueCmd(buf,6);
|
buf[5] = CRC8(buf, 5);
|
||||||
dprintf(("vtxSASetPitMode: set power to 0 dbm\r\n"));
|
saQueueCmd(buf, 6);
|
||||||
return;
|
dprintf(("vtxSASetPitMode: set power to 0 dbm\r\n"));
|
||||||
}
|
} else {
|
||||||
|
saSetMode(SA_MODE_CLR_PITMODE);
|
||||||
if (!onoff && saDevice.version>=3 && !saDevice.willBootIntoPitMode) {
|
dprintf(("vtxSASetPitMode: clear pitmode permanently"));
|
||||||
saSetMode(SA_MODE_CLR_PITMODE);
|
}
|
||||||
dprintf(("sasetpidmode: clear pitmode permanently"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,11 +951,11 @@ static void vtxSASetPitMode(vtxDevice_t *vtxDevice, uint8_t onoff)
|
||||||
newMode |= SA_MODE_SET_OUT_RANGE_PITMODE;
|
newMode |= SA_MODE_SET_OUT_RANGE_PITMODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saDevice.mode & SA_MODE_GET_IN_RANGE_PITMODE || (onoff && !(saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE))) {
|
if ((saDevice.mode & SA_MODE_GET_IN_RANGE_PITMODE) || (onoff && newMode == 0)) {
|
||||||
// ensure when turning on pit mode that pit mode gets actually enabled
|
// ensure when turning on pit mode that pit mode gets actually enabled
|
||||||
newMode |= SA_MODE_SET_IN_RANGE_PITMODE;
|
newMode |= SA_MODE_SET_IN_RANGE_PITMODE;
|
||||||
}
|
}
|
||||||
dprintf(("vtxsasetpitmode %s with stored mode 0x%x por %s, pir %s, newmode 0x%x\r\n", onoff ? "on" : "off", saDevice.mode,
|
dprintf(("vtxSASetPitMode %s with stored mode 0x%x por %s, pir %s, newMode 0x%x\r\n", onoff ? "on" : "off", saDevice.mode,
|
||||||
(saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE) ? "on" : "off",
|
(saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE) ? "on" : "off",
|
||||||
(saDevice.mode & SA_MODE_GET_IN_RANGE_PITMODE) ? "on" : "off" , newMode));
|
(saDevice.mode & SA_MODE_GET_IN_RANGE_PITMODE) ? "on" : "off" , newMode));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue