mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Cleaned up the RX handler some.
This commit is contained in:
parent
6a6fd23742
commit
d13e83b91b
10 changed files with 50 additions and 35 deletions
|
@ -160,32 +160,19 @@ static void taskUpdateAccelerometer(timeUs_t currentTimeUs)
|
|||
|
||||
static void taskUpdateRxMain(timeUs_t currentTimeUs)
|
||||
{
|
||||
static timeUs_t lastRxTimeUs;
|
||||
|
||||
if (!processRx(currentTimeUs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
timeDelta_t frameAgeUs;
|
||||
timeDelta_t refreshRateUs = rxGetFrameDelta(&frameAgeUs);
|
||||
if (!refreshRateUs || cmpTimeUs(currentTimeUs, lastRxTimeUs) <= frameAgeUs) {
|
||||
if (!rxTryGetFrameDeltaOrZero(&refreshRateUs)) {
|
||||
refreshRateUs = cmpTimeUs(currentTimeUs, lastRxTimeUs); // calculate a delta here if not supplied by the protocol
|
||||
}
|
||||
}
|
||||
lastRxTimeUs = currentTimeUs;
|
||||
currentRxRefreshRate = constrain(refreshRateUs, 1000, 30000);
|
||||
isRXDataNew = true;
|
||||
// updateRcCommands sets rcCommand, which is needed by updateAltHoldState and updateSonarAltHoldState
|
||||
updateRcCommands();
|
||||
updateArmingStatus();
|
||||
|
||||
#ifdef USE_USB_CDC_HID
|
||||
if (!ARMING_FLAG(ARMED)) {
|
||||
sendRcDataToHid();
|
||||
}
|
||||
#endif
|
||||
|
||||
// updateRcCommands sets rcCommand, which is needed by updateAltHoldState and updateSonarAltHoldState
|
||||
updateRcCommands();
|
||||
updateArmingStatus();
|
||||
}
|
||||
|
||||
#ifdef USE_BARO
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue