diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index b0d626cca2..ec8296e03d 100755 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -723,7 +723,7 @@ static const clivalue_t valueTable[] = { { "alt_hold_fast_change", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RC_CONTROLS_CONFIG, offsetof(rcControlsConfig_t, alt_hold_fast_change) }, { "deadband", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 32 }, PG_RC_CONTROLS_CONFIG, offsetof(rcControlsConfig_t, deadband) }, { "yaw_deadband", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_RC_CONTROLS_CONFIG, offsetof(rcControlsConfig_t, yaw_deadband) }, - { "yaw_control_direction", VAR_INT8 | MASTER_VALUE, .config.minmax = { -1, 1 }, PG_RC_CONTROLS_CONFIG, offsetof(rcControlsConfig_t, yaw_control_direction) }, + { "yaw_control_reversed", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RC_CONTROLS_CONFIG, offsetof(rcControlsConfig_t, yaw_control_reversed) }, // PG_PID_CONFIG { "pid_process_denom", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 1, MAX_PID_PROCESS_DENOM }, PG_PID_CONFIG, offsetof(pidConfig_t, pid_process_denom) }, diff --git a/src/main/fc/config.c b/src/main/fc/config.c index af7868958c..cf4b1721e1 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -559,7 +559,7 @@ void createDefaultConfig(master_t *config) config->boardAlignment.pitchDegrees = 0; config->boardAlignment.yawDegrees = 0; #endif - config->rcControlsConfig.yaw_control_direction = 1; + config->rcControlsConfig.yaw_control_reversed = false; // xxx_hardware: 0:default/autodetect, 1: disable config->compassConfig.mag_hardware = 1; diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index b7765226e0..8e35f412ee 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -273,7 +273,7 @@ void updateMagHold(void) dif += 360; if (dif >= +180) dif -= 360; - dif *= -rcControlsConfig()->yaw_control_direction; + dif *= -GET_YAW_DIRECTION(rcControlsConfig()->yaw_control_reversed); if (STATE(SMALL_ANGLE)) rcCommand[YAW] -= dif * currentPidProfile->P8[PIDMAG] / 30; // 18 deg } else diff --git a/src/main/fc/fc_rc.c b/src/main/fc/fc_rc.c index 8b80032971..ab6a6c610c 100755 --- a/src/main/fc/fc_rc.c +++ b/src/main/fc/fc_rc.c @@ -284,7 +284,7 @@ void updateRcCommands(void) } else { tmp = 0; } - rcCommand[axis] = tmp * -rcControlsConfig()->yaw_control_direction; + rcCommand[axis] = tmp * -GET_YAW_DIRECTION(rcControlsConfig()->yaw_control_reversed); } if (rcData[axis] < rxConfig()->midrc) { rcCommand[axis] = -rcCommand[axis]; diff --git a/src/main/fc/rc_controls.c b/src/main/fc/rc_controls.c index 0f08225de0..5d4ed0d090 100644 --- a/src/main/fc/rc_controls.c +++ b/src/main/fc/rc_controls.c @@ -77,7 +77,7 @@ PG_RESET_TEMPLATE(rcControlsConfig_t, rcControlsConfig, .yaw_deadband = 0, .alt_hold_deadband = 40, .alt_hold_fast_change = 1, - .yaw_control_direction = 1, + .yaw_control_reversed = false, ); PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, 0); diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h index 45713ed1b2..5fc1c4ca44 100644 --- a/src/main/fc/rc_controls.h +++ b/src/main/fc/rc_controls.h @@ -158,11 +158,12 @@ typedef struct rcControlsConfig_s { uint8_t yaw_deadband; // introduce a deadband around the stick center for yaw axis. Must be greater than zero. uint8_t alt_hold_deadband; // defines the neutral zone of throttle stick during altitude hold, default setting is +/-40 uint8_t alt_hold_fast_change; // when disabled, turn off the althold when throttle stick is out of deadband defined with alt_hold_deadband; when enabled, altitude changes slowly proportional to stick movement - int8_t yaw_control_direction; // change control direction of yaw (inverted, normal) + int8_t yaw_control_reversed; // invert control direction of yaw } rcControlsConfig_t; PG_DECLARE(rcControlsConfig_t, rcControlsConfig); +#define GET_YAW_DIRECTION(isInverted) (2 * (isInverted) - 1) typedef struct flight3DConfig_s { uint16_t deadband3d_low; // min 3d value uint16_t deadband3d_high; // max 3d value