mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
BUGFIX - pwmReadRawRC was broken in
2d248676f5
. MSP RX ignored rc channel
mapping.
Symptoms: power up FC using parallel PWM or PPM with no receiver
attached. Connect GUI tool to view receiver data. Observe that each
channel has a reading of '2' instead of somewhere near 'midrc'.
Symptoms: rxMsp ignored rc channel map, cli 'map' command had no effect.
This commit re-instates the code that checked to see if an rc channel
value was in the correct range but moved it into computeRC where it
really belongs.
Additionally to the code to remap rc channels was moved from the rx
implementations into the computeRc method. This results in smaller code
size, no duplication of logic avoids having to pass rxConfig to each rx
read method and finally fixes rxMsp so that channel mapping can be used.
Failsafe still works as intended, verified by using parallel PWM, arming
and then pulling out the throttle PWM inpout cable.
This also improves code cleanliness since now each rawRawRc method in
the RX implementations does not have to remap the channels. The methods
now do only what their name says.
This commit is contained in:
parent
35f7ce06f3
commit
3ed979e88c
7 changed files with 35 additions and 21 deletions
|
@ -86,13 +86,19 @@ bool isSerialRxFrameComplete(rxConfig_t *rxConfig)
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8_t calculateChannelRemapping(uint8_t *rcmap, uint8_t channelToRemap) {
|
||||
return rcmap[channelToRemap];
|
||||
}
|
||||
|
||||
void computeRC(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
|
||||
{
|
||||
uint8_t chan;
|
||||
|
||||
if (feature(FEATURE_SERIALRX)) {
|
||||
for (chan = 0; chan < MAX_SUPPORTED_RC_PPM_AND_PWM_CHANNEL_COUNT; chan++)
|
||||
rcData[chan] = rcReadRawFunc(rxConfig, rxRuntimeConfig, chan);
|
||||
for (chan = 0; chan < MAX_SUPPORTED_RC_PPM_AND_PWM_CHANNEL_COUNT; chan++) {
|
||||
uint8_t rawChannel = calculateChannelRemapping(rxConfig->rcmap, chan);
|
||||
rcData[chan] = rcReadRawFunc(rxRuntimeConfig, rawChannel);
|
||||
}
|
||||
} else {
|
||||
static int16_t rcSamples[MAX_SUPPORTED_RC_PPM_AND_PWM_CHANNEL_COUNT][PPM_AND_PWM_SAMPLE_COUNT], rcDataMean[MAX_SUPPORTED_RC_PPM_AND_PWM_CHANNEL_COUNT];
|
||||
static uint8_t rcSampleIndex = 0;
|
||||
|
@ -103,8 +109,16 @@ void computeRC(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
|
|||
|
||||
for (chan = 0; chan < MAX_SUPPORTED_RC_PPM_AND_PWM_CHANNEL_COUNT; chan++) {
|
||||
|
||||
uint8_t rawChannel = calculateChannelRemapping(rxConfig->rcmap, chan);
|
||||
|
||||
// sample the channel
|
||||
rcSamples[chan][currentSampleIndex] = rcReadRawFunc(rxConfig, rxRuntimeConfig, chan);
|
||||
uint16_t sample = rcReadRawFunc(rxRuntimeConfig, rawChannel);
|
||||
|
||||
// validate the range
|
||||
if (sample < 750 || sample > 2250)
|
||||
sample = rxConfig->midrc;
|
||||
|
||||
rcSamples[chan][currentSampleIndex] = sample;
|
||||
|
||||
// compute the average of recent samples
|
||||
rcDataMean[chan] = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue