mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 14:55:21 +03:00
Made LQ calculation comply with coding standards.
This commit is contained in:
parent
b729c3cc99
commit
945ee706b9
1 changed files with 15 additions and 15 deletions
|
@ -411,8 +411,12 @@ void rxSetRfMode(uint8_t rfModeValue)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void setLinkQuality(bool validFrame, timeDelta_t currentDeltaTime)
|
static void setLinkQuality(bool validFrame, timeDelta_t currentDeltaTimeUs)
|
||||||
{
|
{
|
||||||
|
static uint16_t rssiSum = 0;
|
||||||
|
static uint16_t rssiCount = 0;
|
||||||
|
static timeDelta_t resampleTimeUs = 0;
|
||||||
|
|
||||||
#ifdef USE_RX_LINK_QUALITY_INFO
|
#ifdef USE_RX_LINK_QUALITY_INFO
|
||||||
if (linkQualitySource != LQ_SOURCE_RX_PROTOCOL_CRSF) {
|
if (linkQualitySource != LQ_SOURCE_RX_PROTOCOL_CRSF) {
|
||||||
// calculate new sample mean
|
// calculate new sample mean
|
||||||
|
@ -421,19 +425,15 @@ static void setLinkQuality(bool validFrame, timeDelta_t currentDeltaTime)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (rssiSource == RSSI_SOURCE_FRAME_ERRORS) {
|
if (rssiSource == RSSI_SOURCE_FRAME_ERRORS) {
|
||||||
static uint16_t tot_rssi = 0;
|
resampleTimeUs += currentDeltaTimeUs;
|
||||||
static uint16_t cnt_rssi = 0;
|
rssiSum += validFrame ? RSSI_MAX_VALUE : 0;
|
||||||
static timeDelta_t resample_time = 0;
|
rssiCount++;
|
||||||
|
|
||||||
resample_time += currentDeltaTime;
|
if (resampleTimeUs >= FRAME_ERR_RESAMPLE_US) {
|
||||||
tot_rssi += validFrame ? RSSI_MAX_VALUE : 0;
|
setRssi(rssiSum / rssiCount, rssiSource);
|
||||||
cnt_rssi++;
|
rssiSum = 0;
|
||||||
|
rssiCount = 0;
|
||||||
if (resample_time >= FRAME_ERR_RESAMPLE_US) {
|
resampleTimeUs -= FRAME_ERR_RESAMPLE_US;
|
||||||
setRssi(tot_rssi / cnt_rssi, rssiSource);
|
|
||||||
tot_rssi = 0;
|
|
||||||
cnt_rssi = 0;
|
|
||||||
resample_time -= FRAME_ERR_RESAMPLE_US;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ void setLinkQualityDirect(uint16_t linkqualityValue)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime)
|
bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs)
|
||||||
{
|
{
|
||||||
bool signalReceived = false;
|
bool signalReceived = false;
|
||||||
bool useDataDrivenProcessing = true;
|
bool useDataDrivenProcessing = true;
|
||||||
|
@ -489,7 +489,7 @@ bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime)
|
||||||
needRxSignalBefore = currentTimeUs + needRxSignalMaxDelayUs;
|
needRxSignalBefore = currentTimeUs + needRxSignalMaxDelayUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLinkQuality(signalReceived, currentDeltaTime);
|
setLinkQuality(signalReceived, currentDeltaTimeUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frameStatus & RX_FRAME_PROCESSING_REQUIRED) {
|
if (frameStatus & RX_FRAME_PROCESSING_REQUIRED) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue