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

Move the receiver inter-frame measurements down into the protocol layer

Adds accuracy to the frame rate measurements used to configure RC smoothing. Prevents looptime delays and jitter from affecting the calculations. Significantly improves the accuracy of the measurement in cases where CPU load is high.

Implemented so that each protocol can individually provide the functionality if appropriate. If a protocol doesn't support the more granular measurement then the system will fallback to the original measurement calculated in the RX task.
This commit is contained in:
Bruce Luckcuck 2019-11-18 10:42:12 -05:00
parent 881a256980
commit 79dd6b6bcc
5 changed files with 44 additions and 6 deletions

View file

@ -166,8 +166,12 @@ static void taskUpdateRxMain(timeUs_t currentTimeUs)
return;
}
currentRxRefreshRate = constrain(currentTimeUs - lastRxTimeUs, 1000, 30000);
timeDelta_t rxFrameDeltaUs;
if (!rxGetFrameDelta(&rxFrameDeltaUs)) {
rxFrameDeltaUs = cmpTimeUs(currentTimeUs, lastRxTimeUs); // calculate a delta here if not supplied by the protocol
}
lastRxTimeUs = currentTimeUs;
currentRxRefreshRate = constrain(rxFrameDeltaUs, 1000, 30000);
isRXDataNew = true;
#ifdef USE_USB_CDC_HID