1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 00:05:28 +03:00

some minor cleanups

This commit is contained in:
Pawel Spychalski (DzikuVx) 2018-05-19 21:32:01 +02:00
parent 7c37d7b287
commit 43c44c78dd
3 changed files with 6 additions and 9 deletions

View file

@ -1972,6 +1972,9 @@ static bool adjustPositionFromRCInput(void)
} }
else { else {
const int16_t rcPitchAdjustment = applyDeadband(rcCommand[PITCH], rcControlsConfig()->pos_hold_deadband);
const int16_t rcRollAdjustment = applyDeadband(rcCommand[ROLL], rcControlsConfig()->pos_hold_deadband);
/* /*
* Process states only for POSHOLD. In any other case we go back to old routines * Process states only for POSHOLD. In any other case we go back to old routines
*/ */
@ -1984,9 +1987,6 @@ static bool adjustPositionFromRCInput(void)
NAV_Status.state == MW_NAV_STATE_HOLD_INFINIT NAV_Status.state == MW_NAV_STATE_HOLD_INFINIT
) )
) { ) {
const int16_t rcPitchAdjustment = applyDeadband(rcCommand[PITCH], rcControlsConfig()->pos_hold_deadband);
const int16_t rcRollAdjustment = applyDeadband(rcCommand[ROLL], rcControlsConfig()->pos_hold_deadband);
/* /*
* Case one, when we order to brake (sticks to the center) and we are moving above threshold * Case one, when we order to brake (sticks to the center) and we are moving above threshold
* Speed is above 1m/s and sticks are centered * Speed is above 1m/s and sticks are centered
@ -2077,7 +2077,7 @@ static bool adjustPositionFromRCInput(void)
} }
retValue = adjustMulticopterPositionFromRCInput(); retValue = adjustMulticopterPositionFromRCInput(rcPitchAdjustment, rcRollAdjustment);
} }
return retValue; return retValue;

View file

@ -274,11 +274,8 @@ void resetMulticopterPositionController(void)
} }
} }
bool adjustMulticopterPositionFromRCInput(void) bool adjustMulticopterPositionFromRCInput(int16_t rcPitchAdjustment, int16_t rcRollAdjustment)
{ {
const int16_t rcPitchAdjustment = applyDeadband(rcCommand[PITCH], rcControlsConfig()->pos_hold_deadband);
const int16_t rcRollAdjustment = applyDeadband(rcCommand[ROLL], rcControlsConfig()->pos_hold_deadband);
if (rcPitchAdjustment || rcRollAdjustment) { if (rcPitchAdjustment || rcRollAdjustment) {
// If mode is GPS_CRUISE, move target position, otherwise POS controller will passthru the RC input to ANGLE PID // If mode is GPS_CRUISE, move target position, otherwise POS controller will passthru the RC input to ANGLE PID
if (navConfig()->general.flags.user_control_mode == NAV_GPS_CRUISE) { if (navConfig()->general.flags.user_control_mode == NAV_GPS_CRUISE) {

View file

@ -390,7 +390,7 @@ void resetMulticopterHeadingController(void);
bool adjustMulticopterAltitudeFromRCInput(void); bool adjustMulticopterAltitudeFromRCInput(void);
bool adjustMulticopterHeadingFromRCInput(void); bool adjustMulticopterHeadingFromRCInput(void);
bool adjustMulticopterPositionFromRCInput(void); bool adjustMulticopterPositionFromRCInput(int16_t rcPitchAdjustment, int16_t rcRollAdjustment);
void applyMulticopterNavigationController(navigationFSMStateFlags_t navStateFlags, timeUs_t currentTimeUs); void applyMulticopterNavigationController(navigationFSMStateFlags_t navStateFlags, timeUs_t currentTimeUs);