Added delay to rxfail detection

Added a bad pulse counter to all channels.
More than MAX_INVALID_PULS_COUNTS bad pulses required before
starting rxfail substitution.
This should prevent a too aggressive reaction to small dropouts.
This commit is contained in:
ProDrone 2015-10-14 19:20:42 +02:00 committed by borisbstyle
parent 802b2e0ea9
commit 44b751cd5a
1 changed files with 12 additions and 3 deletions

View File

@ -81,7 +81,9 @@ static uint8_t skipRxSamples = 0;
int16_t rcRaw[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
int8_t rcInvalidPulsCounter[MAX_SUPPORTED_RC_CHANNEL_COUNT];
#define MAX_INVALID_PULS_COUNTS 3
#define PPM_AND_PWM_SAMPLE_COUNT 3
#define DELAY_50_HZ (1000000 / 50)
@ -157,6 +159,7 @@ void rxInit(rxConfig_t *rxConfig)
for (i = 0; i < MAX_SUPPORTED_RC_CHANNEL_COUNT; i++) {
rcData[i] = rxConfig->midrc;
rcInvalidPulsCounter[i] = MAX_INVALID_PULS_COUNTS;
}
rcData[THROTTLE] = (feature(FEATURE_3D)) ? rxConfig->midrc : rxConfig->rx_min_usec;
@ -471,11 +474,17 @@ static void detectAndApplySignalLossBehaviour(void)
bool validPulse = isPulseValid(sample);
if (!validPulse) {
sample = getRxfailValue(channel);
if (rcInvalidPulsCounter[channel]) {
rcInvalidPulsCounter[channel]--;
sample = rcData[channel]; // hold channel for MAX_INVALID_PULS_COUNTS
} else {
sample = getRxfailValue(channel); // after that apply rxfail value
rxUpdateFlightChannelStatus(channel, validPulse);
}
} else {
rcInvalidPulsCounter[channel] = MAX_INVALID_PULS_COUNTS;
}
rxUpdateFlightChannelStatus(channel, validPulse);
if (rxIsDataDriven) {
rcData[channel] = sample;
} else {