Merge pull request #4553 from mikeller/fix_rssi_scaling

Fixed scaling of RSSI.
This commit is contained in:
Martin Budden 2017-11-12 05:24:49 +00:00 committed by GitHub
commit 391588958e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -629,7 +629,7 @@ static void updateRSSIPWM(void)
}
// Range of rawPwmRssi is [1000;2000]. rssi should be in [0;1023];
setRssiFiltered((uint16_t)((constrain(pwmRssi - 1000, 0, 1000) / 1000.0f) * 1023.0f));
setRssiFiltered(constrain((uint16_t)(((pwmRssi - 1000) / 1000.0f) * 1024.0f), 0, 1023));
}
static void updateRSSIADC(timeUs_t currentTimeUs)
@ -645,8 +645,8 @@ static void updateRSSIADC(timeUs_t currentTimeUs)
rssiUpdateAt = currentTimeUs + DELAY_50_HZ;
const uint16_t adcRssiSample = adcGetChannel(ADC_RSSI);
unsigned rssiValue = (1024 * adcRssiSample) / (rxConfig()->rssi_scale * 100);
rssiValue = constrain(rssiValue, 0, 1024);
uint16_t rssiValue = (uint16_t)((1024.0f * adcRssiSample) / (rxConfig()->rssi_scale * 100.0f));
rssiValue = constrain(rssiValue, 0, 1023);
// RSSI_Invert option
if (rxConfig()->rssi_invert) {
@ -672,7 +672,7 @@ void setRssiUnfiltered(uint16_t rssiValue)
int16_t rssiMean = sum / RSSI_SAMPLE_COUNT;
setRssiFiltered((uint16_t)((rssiMean / 100.0f) * 1023.0f));
setRssiFiltered(rssiMean);
}
void setRssiMsp(uint8_t newMspRssi)