Merge pull request #6688 from mikeller/dont_skip_serial_frames

Remove skipping of frames after suspension for serial RX.
This commit is contained in:
Michael Keller 2018-09-08 16:37:33 +12:00 committed by GitHub
commit 0c265773dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 17 deletions

View File

@ -512,7 +512,7 @@ void validateAndFixGyroConfig(void)
bool readEEPROM(void)
{
suspendRxSignal();
suspendRxPwmPpmSignal();
// Sanity check, read flash
bool success = loadEEPROM();
@ -521,7 +521,7 @@ bool readEEPROM(void)
activateConfig();
resumeRxSignal();
resumeRxPwmPpmSignal();
return success;
}
@ -530,11 +530,11 @@ void writeEEPROM(void)
{
validateAndFixConfig();
suspendRxSignal();
suspendRxPwmPpmSignal();
writeConfigToEEPROM();
resumeRxSignal();
resumeRxPwmPpmSignal();
}
void writeEEPROMWithFeatures(uint32_t features)

View File

@ -295,7 +295,7 @@ void rxInit(void)
#endif
#if defined(USE_PWM) || defined(USE_PPM)
if (featureIsEnabled(FEATURE_RX_PPM) || featureIsEnabled(FEATURE_RX_PARALLEL_PWM)) {
if (featureIsEnabled(FEATURE_RX_PPM | FEATURE_RX_PARALLEL_PWM)) {
rxPwmInit(rxConfig(), &rxRuntimeConfig);
}
#endif
@ -322,18 +322,26 @@ bool rxAreFlightChannelsValid(void)
return rxFlightChannelsValid;
}
void suspendRxSignal(void)
void suspendRxPwmPpmSignal(void)
{
suspendRxSignalUntil = micros() + SKIP_RC_ON_SUSPEND_PERIOD;
skipRxSamples = SKIP_RC_SAMPLES_ON_RESUME;
failsafeOnRxSuspend(SKIP_RC_ON_SUSPEND_PERIOD);
#if defined(USE_PWM) || defined(USE_PPM)
if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM)) {
suspendRxSignalUntil = micros() + SKIP_RC_ON_SUSPEND_PERIOD;
skipRxSamples = SKIP_RC_SAMPLES_ON_RESUME;
failsafeOnRxSuspend(SKIP_RC_ON_SUSPEND_PERIOD);
}
#endif
}
void resumeRxSignal(void)
void resumeRxPwmPpmSignal(void)
{
suspendRxSignalUntil = micros();
skipRxSamples = SKIP_RC_SAMPLES_ON_RESUME;
failsafeOnRxResume();
#if defined(USE_PWM) || defined(USE_PPM)
if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM)) {
suspendRxSignalUntil = micros();
skipRxSamples = SKIP_RC_SAMPLES_ON_RESUME;
failsafeOnRxResume();
}
#endif
}
bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime)
@ -397,6 +405,7 @@ bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime)
return rxDataProcessingRequired || auxiliaryProcessingRequired; // data driven or 50Hz
}
#if defined(USE_PWM) || defined(USE_PPM)
static uint16_t calculateChannelMovingAverage(uint8_t chan, uint16_t sample)
{
static int16_t rcSamples[MAX_SUPPORTED_RX_PARALLEL_PWM_OR_PPM_CHANNEL_COUNT][PPM_AND_PWM_SAMPLE_COUNT];
@ -422,6 +431,7 @@ static uint16_t calculateChannelMovingAverage(uint8_t chan, uint16_t sample)
}
return rcDataMean[chan] / PPM_AND_PWM_SAMPLE_COUNT;
}
#endif
static uint16_t getRxfailValue(uint8_t channel)
{
@ -510,10 +520,13 @@ static void detectAndApplySignalLossBehaviour(void)
}
}
}
#if defined(USE_PWM) || defined(USE_PPM)
if (featureIsEnabled(FEATURE_RX_PARALLEL_PWM | FEATURE_RX_PPM)) {
// smooth output for PWM and PPM
rcData[channel] = calculateChannelMovingAverage(channel, sample);
} else {
} else
#endif
{
rcData[channel] = sample;
}
}
@ -544,7 +557,7 @@ bool calculateRxChannelsAndUpdateFailsafe(timeUs_t currentTimeUs)
rxNextUpdateAtUs = currentTimeUs + DELAY_33_HZ;
// only proceed when no more samples to skip and suspend period is over
if (skipRxSamples) {
if (skipRxSamples || currentTimeUs <= suspendRxSignalUntil) {
if (currentTimeUs > suspendRxSignalUntil) {
skipRxSamples--;
}

View File

@ -169,7 +169,7 @@ uint8_t getRssiPercent(void);
void resetAllRxChannelRangeConfigurations(rxChannelRangeConfig_t *rxChannelRangeConfig);
void suspendRxSignal(void);
void resumeRxSignal(void);
void suspendRxPwmPpmSignal(void);
void resumeRxPwmPpmSignal(void);
uint16_t rxGetRefreshRate(void);