mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Tidy rc_controls.c
This commit is contained in:
parent
e760f73edc
commit
8efdd3bc57
1 changed files with 18 additions and 16 deletions
|
@ -135,8 +135,6 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
|
||||||
// an extra guard for disarming through switch to prevent that one frame can disarm it
|
// an extra guard for disarming through switch to prevent that one frame can disarm it
|
||||||
static uint8_t rcDisarmTicks;
|
static uint8_t rcDisarmTicks;
|
||||||
static bool doNotRepeat;
|
static bool doNotRepeat;
|
||||||
uint8_t stTmp = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
#ifdef CMS
|
#ifdef CMS
|
||||||
if (cmsInMenu) {
|
if (cmsInMenu) {
|
||||||
|
@ -145,16 +143,20 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// checking sticks positions
|
// checking sticks positions
|
||||||
for (i = 0; i < 4; i++) {
|
uint8_t stTmp = 0;
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
stTmp >>= 2;
|
stTmp >>= 2;
|
||||||
if (rcData[i] > rxConfig()->mincheck)
|
if (rcData[i] > rxConfig()->mincheck) {
|
||||||
stTmp |= 0x80; // check for MIN
|
stTmp |= 0x80; // check for MIN
|
||||||
if (rcData[i] < rxConfig()->maxcheck)
|
}
|
||||||
|
if (rcData[i] < rxConfig()->maxcheck) {
|
||||||
stTmp |= 0x40; // check for MAX
|
stTmp |= 0x40; // check for MAX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (stTmp == rcSticks) {
|
if (stTmp == rcSticks) {
|
||||||
if (rcDelayMs <= INT16_MAX - (getTaskDeltaTime(TASK_SELF) / 1000))
|
if (rcDelayMs <= INT16_MAX - (getTaskDeltaTime(TASK_SELF) / 1000)) {
|
||||||
rcDelayMs += getTaskDeltaTime(TASK_SELF) / 1000;
|
rcDelayMs += getTaskDeltaTime(TASK_SELF) / 1000;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rcDelayMs = 0;
|
rcDelayMs = 0;
|
||||||
doNotRepeat = false;
|
doNotRepeat = false;
|
||||||
|
@ -238,15 +240,16 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiple configuration profiles
|
// Multiple configuration profiles
|
||||||
i = 0;
|
int newPidProfile = 0;
|
||||||
if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_LO) // ROLL left -> Profile 1
|
if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_LO) { // ROLL left -> Profile 1
|
||||||
i = 1;
|
newPidProfile = 1;
|
||||||
else if (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_CE) // PITCH up -> Profile 2
|
} else if (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_CE) { // PITCH up -> Profile 2
|
||||||
i = 2;
|
newPidProfile = 2;
|
||||||
else if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_HI) // ROLL right -> Profile 3
|
} else if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_HI) { // ROLL right -> Profile 3
|
||||||
i = 3;
|
newPidProfile = 3;
|
||||||
if (i) {
|
}
|
||||||
changePidProfile(i - 1);
|
if (newPidProfile) {
|
||||||
|
changePidProfile(newPidProfile - 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +272,6 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
|
||||||
|
|
||||||
|
|
||||||
// Accelerometer Trim
|
// Accelerometer Trim
|
||||||
|
|
||||||
rollAndPitchTrims_t accelerometerTrimsDelta;
|
rollAndPitchTrims_t accelerometerTrimsDelta;
|
||||||
memset(&accelerometerTrimsDelta, 0, sizeof(accelerometerTrimsDelta));
|
memset(&accelerometerTrimsDelta, 0, sizeof(accelerometerTrimsDelta));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue