Merge pull request #4314 from martinbudden/bf_rc_controls_tidy

Tidy rc_controls.c
This commit is contained in:
Martin Budden 2017-10-09 23:47:18 +01:00 committed by GitHub
commit a4040caebd
1 changed files with 18 additions and 16 deletions

View File

@ -135,8 +135,6 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
// an extra guard for disarming through switch to prevent that one frame can disarm it
static uint8_t rcDisarmTicks;
static bool doNotRepeat;
uint8_t stTmp = 0;
int i;
#ifdef CMS
if (cmsInMenu) {
@ -145,16 +143,20 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
#endif
// checking sticks positions
for (i = 0; i < 4; i++) {
uint8_t stTmp = 0;
for (int i = 0; i < 4; i++) {
stTmp >>= 2;
if (rcData[i] > rxConfig()->mincheck)
if (rcData[i] > rxConfig()->mincheck) {
stTmp |= 0x80; // check for MIN
if (rcData[i] < rxConfig()->maxcheck)
}
if (rcData[i] < rxConfig()->maxcheck) {
stTmp |= 0x40; // check for MAX
}
}
if (stTmp == rcSticks) {
if (rcDelayMs <= INT16_MAX - (getTaskDeltaTime(TASK_SELF) / 1000))
if (rcDelayMs <= INT16_MAX - (getTaskDeltaTime(TASK_SELF) / 1000)) {
rcDelayMs += getTaskDeltaTime(TASK_SELF) / 1000;
}
} else {
rcDelayMs = 0;
doNotRepeat = false;
@ -238,15 +240,16 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
}
// Multiple configuration profiles
i = 0;
if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_LO) // ROLL left -> Profile 1
i = 1;
else if (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_CE) // PITCH up -> Profile 2
i = 2;
else if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_HI) // ROLL right -> Profile 3
i = 3;
if (i) {
changePidProfile(i - 1);
int newPidProfile = 0;
if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_LO) { // ROLL left -> Profile 1
newPidProfile = 1;
} else if (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_CE) { // PITCH up -> Profile 2
newPidProfile = 2;
} else if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_HI) { // ROLL right -> Profile 3
newPidProfile = 3;
}
if (newPidProfile) {
changePidProfile(newPidProfile - 1);
return;
}
@ -269,7 +272,6 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
// Accelerometer Trim
rollAndPitchTrims_t accelerometerTrimsDelta;
memset(&accelerometerTrimsDelta, 0, sizeof(accelerometerTrimsDelta));