Trainer code simplification (#4519)
This commit is contained in:
+10
-10
@@ -41,8 +41,8 @@ void checkTrainerSignalWarning();
|
|||||||
// Needs to be inlined to avoid slow function calls in ISR routines
|
// Needs to be inlined to avoid slow function calls in ISR routines
|
||||||
inline void captureTrainerPulses(uint16_t capture)
|
inline void captureTrainerPulses(uint16_t capture)
|
||||||
{
|
{
|
||||||
static uint16_t lastCapt=0;
|
static uint16_t lastCapt = 0;
|
||||||
static uint8_t channelNumber=0;
|
static int8_t channelNumber = -1;
|
||||||
|
|
||||||
uint16_t val = (uint16_t)(capture - lastCapt) / 2;
|
uint16_t val = (uint16_t)(capture - lastCapt) / 2;
|
||||||
lastCapt = capture;
|
lastCapt = capture;
|
||||||
@@ -52,19 +52,19 @@ inline void captureTrainerPulses(uint16_t capture)
|
|||||||
//
|
//
|
||||||
// G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
// G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
||||||
//
|
//
|
||||||
if (val>4000 && val<19000) {
|
if (val > 4000 && val < 19000) {
|
||||||
channelNumber = 1; // triggered
|
channelNumber = 0; // triggered
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((channelNumber > 0) && (channelNumber <= MAX_TRAINER_CHANNELS)) {
|
if (channelNumber >= 0 && channelNumber < MAX_TRAINER_CHANNELS) {
|
||||||
if (val>800 && val<2200) {
|
if (val > 800 && val < 2200) {
|
||||||
ppmInputValidityTimer = PPM_IN_VALID_TIMEOUT;
|
ppmInputValidityTimer = PPM_IN_VALID_TIMEOUT;
|
||||||
ppmInput[channelNumber++ - 1] =
|
ppmInput[channelNumber++] =
|
||||||
//+-500 != 512, but close enough.
|
// +-500 != 512, but close enough.
|
||||||
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10;
|
(int16_t)(val - 1500) * (g_eeGeneral.PPM_Multiplier+10) / 10;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
channelNumber = 0; // not triggered
|
channelNumber = -1; // not triggered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user