mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Tidy rc_adjustments
This commit is contained in:
parent
c39ab90bc6
commit
9f07785e33
2 changed files with 177 additions and 218 deletions
|
@ -100,122 +100,99 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
|
||||||
{
|
{
|
||||||
.adjustmentFunction = ADJUSTMENT_RC_RATE,
|
.adjustmentFunction = ADJUSTMENT_RC_RATE,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_RC_EXPO,
|
.adjustmentFunction = ADJUSTMENT_RC_EXPO,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_THROTTLE_EXPO,
|
.adjustmentFunction = ADJUSTMENT_THROTTLE_EXPO,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_RATE,
|
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_RATE,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_YAW_RATE,
|
.adjustmentFunction = ADJUSTMENT_YAW_RATE,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_P,
|
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_P,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_I,
|
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_I,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_D,
|
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_D,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_YAW_P,
|
.adjustmentFunction = ADJUSTMENT_YAW_P,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_YAW_I,
|
.adjustmentFunction = ADJUSTMENT_YAW_I,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_YAW_D,
|
.adjustmentFunction = ADJUSTMENT_YAW_D,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_RATE_PROFILE,
|
.adjustmentFunction = ADJUSTMENT_RATE_PROFILE,
|
||||||
.mode = ADJUSTMENT_MODE_SELECT,
|
.mode = ADJUSTMENT_MODE_SELECT,
|
||||||
.data = { .selectConfig = { .switchPositions = 3 }}
|
.data = { .switchPositions = 3 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_RATE,
|
.adjustmentFunction = ADJUSTMENT_PITCH_RATE,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_ROLL_RATE,
|
.adjustmentFunction = ADJUSTMENT_ROLL_RATE,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_P,
|
.adjustmentFunction = ADJUSTMENT_PITCH_P,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_I,
|
.adjustmentFunction = ADJUSTMENT_PITCH_I,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_PITCH_D,
|
.adjustmentFunction = ADJUSTMENT_PITCH_D,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_ROLL_P,
|
.adjustmentFunction = ADJUSTMENT_ROLL_P,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_ROLL_I,
|
.adjustmentFunction = ADJUSTMENT_ROLL_I,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_ROLL_D,
|
.adjustmentFunction = ADJUSTMENT_ROLL_D,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_RC_RATE_YAW,
|
.adjustmentFunction = ADJUSTMENT_RC_RATE_YAW,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_D_SETPOINT,
|
.adjustmentFunction = ADJUSTMENT_D_SETPOINT,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_D_SETPOINT_TRANSITION,
|
.adjustmentFunction = ADJUSTMENT_D_SETPOINT_TRANSITION,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .step = 1 }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
.adjustmentFunction = ADJUSTMENT_HORIZON_STRENGTH,
|
.adjustmentFunction = ADJUSTMENT_HORIZON_STRENGTH,
|
||||||
.mode = ADJUSTMENT_MODE_SELECT,
|
.mode = ADJUSTMENT_MODE_SELECT,
|
||||||
.data = { .selectConfig = { .switchPositions = 255 }}
|
.data = { .switchPositions = 255 }
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -241,126 +218,120 @@ static void configureAdjustment(uint8_t index, uint8_t auxSwitchChannelIndex, co
|
||||||
|
|
||||||
static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustmentFunction, int delta)
|
static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustmentFunction, int delta)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
beeperConfirmationBeeps(delta > 0 ? 2 : 1);
|
||||||
int newValue;
|
int newValue;
|
||||||
|
|
||||||
if (delta > 0) {
|
|
||||||
beeperConfirmationBeeps(2);
|
|
||||||
} else {
|
|
||||||
beeperConfirmationBeeps(1);
|
|
||||||
}
|
|
||||||
switch(adjustmentFunction) {
|
switch(adjustmentFunction) {
|
||||||
case ADJUSTMENT_RC_RATE:
|
case ADJUSTMENT_RC_RATE:
|
||||||
newValue = constrain((int)controlRateConfig->rcRate8 + delta, 0, 250); // FIXME magic numbers repeated in cli.c
|
newValue = constrain((int)controlRateConfig->rcRate8 + delta, 0, 250); // FIXME magic numbers repeated in cli.c
|
||||||
controlRateConfig->rcRate8 = newValue;
|
controlRateConfig->rcRate8 = newValue;
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE, newValue);
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_RC_EXPO:
|
||||||
|
newValue = constrain((int)controlRateConfig->rcExpo8 + delta, 0, 100); // FIXME magic numbers repeated in cli.c
|
||||||
|
controlRateConfig->rcExpo8 = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_EXPO, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_THROTTLE_EXPO:
|
||||||
|
newValue = constrain((int)controlRateConfig->thrExpo8 + delta, 0, 100); // FIXME magic numbers repeated in cli.c
|
||||||
|
controlRateConfig->thrExpo8 = newValue;
|
||||||
|
generateThrottleCurve();
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_THROTTLE_EXPO, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_PITCH_ROLL_RATE:
|
||||||
|
case ADJUSTMENT_PITCH_RATE:
|
||||||
|
newValue = constrain((int)controlRateConfig->rates[FD_PITCH] + delta, 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX);
|
||||||
|
controlRateConfig->rates[FD_PITCH] = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_RATE, newValue);
|
||||||
|
if (adjustmentFunction == ADJUSTMENT_PITCH_RATE) {
|
||||||
break;
|
break;
|
||||||
case ADJUSTMENT_RC_EXPO:
|
}
|
||||||
newValue = constrain((int)controlRateConfig->rcExpo8 + delta, 0, 100); // FIXME magic numbers repeated in cli.c
|
// follow though for combined ADJUSTMENT_PITCH_ROLL_RATE
|
||||||
controlRateConfig->rcExpo8 = newValue;
|
case ADJUSTMENT_ROLL_RATE:
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_EXPO, newValue);
|
newValue = constrain((int)controlRateConfig->rates[FD_ROLL] + delta, 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX);
|
||||||
break;
|
controlRateConfig->rates[FD_ROLL] = newValue;
|
||||||
case ADJUSTMENT_THROTTLE_EXPO:
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_RATE, newValue);
|
||||||
newValue = constrain((int)controlRateConfig->thrExpo8 + delta, 0, 100); // FIXME magic numbers repeated in cli.c
|
break;
|
||||||
controlRateConfig->thrExpo8 = newValue;
|
case ADJUSTMENT_YAW_RATE:
|
||||||
generateThrottleCurve();
|
newValue = constrain((int)controlRateConfig->rates[FD_YAW] + delta, 0, CONTROL_RATE_CONFIG_YAW_RATE_MAX);
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_THROTTLE_EXPO, newValue);
|
controlRateConfig->rates[FD_YAW] = newValue;
|
||||||
break;
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_RATE, newValue);
|
||||||
case ADJUSTMENT_PITCH_ROLL_RATE:
|
break;
|
||||||
case ADJUSTMENT_PITCH_RATE:
|
case ADJUSTMENT_PITCH_ROLL_P:
|
||||||
newValue = constrain((int)controlRateConfig->rates[FD_PITCH] + delta, 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX);
|
case ADJUSTMENT_PITCH_P:
|
||||||
controlRateConfig->rates[FD_PITCH] = newValue;
|
newValue = constrain((int)pidProfile->P8[PIDPITCH] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_RATE, newValue);
|
pidProfile->P8[PIDPITCH] = newValue;
|
||||||
if (adjustmentFunction == ADJUSTMENT_PITCH_RATE) {
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_P, newValue);
|
||||||
break;
|
|
||||||
}
|
|
||||||
// follow though for combined ADJUSTMENT_PITCH_ROLL_RATE
|
|
||||||
case ADJUSTMENT_ROLL_RATE:
|
|
||||||
newValue = constrain((int)controlRateConfig->rates[FD_ROLL] + delta, 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX);
|
|
||||||
controlRateConfig->rates[FD_ROLL] = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_RATE, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_YAW_RATE:
|
|
||||||
newValue = constrain((int)controlRateConfig->rates[FD_YAW] + delta, 0, CONTROL_RATE_CONFIG_YAW_RATE_MAX);
|
|
||||||
controlRateConfig->rates[FD_YAW] = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_RATE, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_PITCH_ROLL_P:
|
|
||||||
case ADJUSTMENT_PITCH_P:
|
|
||||||
newValue = constrain((int)pidProfile->P8[PIDPITCH] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
|
||||||
pidProfile->P8[PIDPITCH] = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_P, newValue);
|
|
||||||
|
|
||||||
if (adjustmentFunction == ADJUSTMENT_PITCH_P) {
|
if (adjustmentFunction == ADJUSTMENT_PITCH_P) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
// follow though for combined ADJUSTMENT_PITCH_ROLL_P
|
|
||||||
case ADJUSTMENT_ROLL_P:
|
|
||||||
newValue = constrain((int)pidProfile->P8[PIDROLL] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
|
||||||
pidProfile->P8[PIDROLL] = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_P, newValue);
|
|
||||||
break;
|
break;
|
||||||
case ADJUSTMENT_PITCH_ROLL_I:
|
}
|
||||||
case ADJUSTMENT_PITCH_I:
|
// follow though for combined ADJUSTMENT_PITCH_ROLL_P
|
||||||
newValue = constrain((int)pidProfile->I8[PIDPITCH] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
case ADJUSTMENT_ROLL_P:
|
||||||
pidProfile->I8[PIDPITCH] = newValue;
|
newValue = constrain((int)pidProfile->P8[PIDROLL] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_I, newValue);
|
pidProfile->P8[PIDROLL] = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_P, newValue);
|
||||||
if (adjustmentFunction == ADJUSTMENT_PITCH_I) {
|
break;
|
||||||
break;
|
case ADJUSTMENT_PITCH_ROLL_I:
|
||||||
}
|
case ADJUSTMENT_PITCH_I:
|
||||||
// follow though for combined ADJUSTMENT_PITCH_ROLL_I
|
newValue = constrain((int)pidProfile->I8[PIDPITCH] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
case ADJUSTMENT_ROLL_I:
|
pidProfile->I8[PIDPITCH] = newValue;
|
||||||
newValue = constrain((int)pidProfile->I8[PIDROLL] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_I, newValue);
|
||||||
pidProfile->I8[PIDROLL] = newValue;
|
if (adjustmentFunction == ADJUSTMENT_PITCH_I) {
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_I, newValue);
|
|
||||||
break;
|
break;
|
||||||
case ADJUSTMENT_PITCH_ROLL_D:
|
}
|
||||||
case ADJUSTMENT_PITCH_D:
|
// fall though for combined ADJUSTMENT_PITCH_ROLL_I
|
||||||
newValue = constrain((int)pidProfile->D8[PIDPITCH] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
case ADJUSTMENT_ROLL_I:
|
||||||
pidProfile->D8[PIDPITCH] = newValue;
|
newValue = constrain((int)pidProfile->I8[PIDROLL] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_D, newValue);
|
pidProfile->I8[PIDROLL] = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_I, newValue);
|
||||||
if (adjustmentFunction == ADJUSTMENT_PITCH_D) {
|
break;
|
||||||
break;
|
case ADJUSTMENT_PITCH_ROLL_D:
|
||||||
}
|
case ADJUSTMENT_PITCH_D:
|
||||||
// follow though for combined ADJUSTMENT_PITCH_ROLL_D
|
newValue = constrain((int)pidProfile->D8[PIDPITCH] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
case ADJUSTMENT_ROLL_D:
|
pidProfile->D8[PIDPITCH] = newValue;
|
||||||
newValue = constrain((int)pidProfile->D8[PIDROLL] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_D, newValue);
|
||||||
pidProfile->D8[PIDROLL] = newValue;
|
if (adjustmentFunction == ADJUSTMENT_PITCH_D) {
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_D, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_YAW_P:
|
|
||||||
newValue = constrain((int)pidProfile->P8[PIDYAW] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
|
||||||
pidProfile->P8[PIDYAW] = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_P, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_YAW_I:
|
|
||||||
newValue = constrain((int)pidProfile->I8[PIDYAW] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
|
||||||
pidProfile->I8[PIDYAW] = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_I, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_YAW_D:
|
|
||||||
newValue = constrain((int)pidProfile->D8[PIDYAW] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
|
||||||
pidProfile->D8[PIDYAW] = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_D, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_RC_RATE_YAW:
|
|
||||||
newValue = constrain((int)controlRateConfig->rcYawRate8 + delta, 0, 300); // FIXME magic numbers repeated in cli.c
|
|
||||||
controlRateConfig->rcYawRate8 = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE_YAW, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_D_SETPOINT:
|
|
||||||
newValue = constrain((int)pidProfile->dtermSetpointWeight + delta, 0, 254); // FIXME magic numbers repeated in cli.c
|
|
||||||
pidProfile->dtermSetpointWeight = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT, newValue);
|
|
||||||
break;
|
|
||||||
case ADJUSTMENT_D_SETPOINT_TRANSITION:
|
|
||||||
newValue = constrain((int)pidProfile->setpointRelaxRatio + delta, 0, 100); // FIXME magic numbers repeated in cli.c
|
|
||||||
pidProfile->setpointRelaxRatio = newValue;
|
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT_TRANSITION, newValue);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
// fall though for combined ADJUSTMENT_PITCH_ROLL_D
|
||||||
|
case ADJUSTMENT_ROLL_D:
|
||||||
|
newValue = constrain((int)pidProfile->D8[PIDROLL] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
|
pidProfile->D8[PIDROLL] = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_D, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_YAW_P:
|
||||||
|
newValue = constrain((int)pidProfile->P8[PIDYAW] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
|
pidProfile->P8[PIDYAW] = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_P, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_YAW_I:
|
||||||
|
newValue = constrain((int)pidProfile->I8[PIDYAW] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
|
pidProfile->I8[PIDYAW] = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_I, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_YAW_D:
|
||||||
|
newValue = constrain((int)pidProfile->D8[PIDYAW] + delta, 0, 200); // FIXME magic numbers repeated in cli.c
|
||||||
|
pidProfile->D8[PIDYAW] = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_D, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_RC_RATE_YAW:
|
||||||
|
newValue = constrain((int)controlRateConfig->rcYawRate8 + delta, 0, 300); // FIXME magic numbers repeated in cli.c
|
||||||
|
controlRateConfig->rcYawRate8 = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE_YAW, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_D_SETPOINT:
|
||||||
|
newValue = constrain((int)pidProfile->dtermSetpointWeight + delta, 0, 254); // FIXME magic numbers repeated in cli.c
|
||||||
|
pidProfile->dtermSetpointWeight = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT, newValue);
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_D_SETPOINT_TRANSITION:
|
||||||
|
newValue = constrain((int)pidProfile->setpointRelaxRatio + delta, 0, 100); // FIXME magic numbers repeated in cli.c
|
||||||
|
pidProfile->setpointRelaxRatio = newValue;
|
||||||
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT_TRANSITION, newValue);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,25 +340,25 @@ static void applySelectAdjustment(uint8_t adjustmentFunction, uint8_t position)
|
||||||
uint8_t beeps = 0;
|
uint8_t beeps = 0;
|
||||||
|
|
||||||
switch(adjustmentFunction) {
|
switch(adjustmentFunction) {
|
||||||
case ADJUSTMENT_RATE_PROFILE:
|
case ADJUSTMENT_RATE_PROFILE:
|
||||||
{
|
{
|
||||||
if (getCurrentControlRateProfileIndex() != position) {
|
if (getCurrentControlRateProfileIndex() != position) {
|
||||||
changeControlRateProfile(position);
|
changeControlRateProfile(position);
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RATE_PROFILE, position);
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RATE_PROFILE, position);
|
||||||
beeps = position + 1;
|
beeps = position + 1;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ADJUSTMENT_HORIZON_STRENGTH:
|
break;
|
||||||
{
|
}
|
||||||
uint8_t newValue = constrain(position, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
case ADJUSTMENT_HORIZON_STRENGTH:
|
||||||
if(pidProfile->D8[PIDLEVEL] != newValue) {
|
{
|
||||||
beeps = ((newValue - pidProfile->D8[PIDLEVEL]) / 8) + 1;
|
uint8_t newValue = constrain(position, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
pidProfile->D8[PIDLEVEL] = newValue;
|
if(pidProfile->D8[PIDLEVEL] != newValue) {
|
||||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_HORIZON_STRENGTH, position);
|
beeps = ((newValue - pidProfile->D8[PIDLEVEL]) / 8) + 1;
|
||||||
}
|
pidProfile->D8[PIDLEVEL] = newValue;
|
||||||
break;
|
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_HORIZON_STRENGTH, position);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (beeps) {
|
if (beeps) {
|
||||||
|
@ -432,9 +403,9 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
|
||||||
if (adjustmentState->config->mode == ADJUSTMENT_MODE_STEP) {
|
if (adjustmentState->config->mode == ADJUSTMENT_MODE_STEP) {
|
||||||
int delta;
|
int delta;
|
||||||
if (rcData[channelIndex] > rxConfig()->midrc + 200) {
|
if (rcData[channelIndex] > rxConfig()->midrc + 200) {
|
||||||
delta = adjustmentState->config->data.stepConfig.step;
|
delta = adjustmentState->config->data.step;
|
||||||
} else if (rcData[channelIndex] < rxConfig()->midrc - 200) {
|
} else if (rcData[channelIndex] < rxConfig()->midrc - 200) {
|
||||||
delta = 0 - adjustmentState->config->data.stepConfig.step;
|
delta = -adjustmentState->config->data.step;
|
||||||
} else {
|
} else {
|
||||||
// returning the switch to the middle immediately resets the ready state
|
// returning the switch to the middle immediately resets the ready state
|
||||||
MARK_ADJUSTMENT_FUNCTION_AS_READY(adjustmentIndex);
|
MARK_ADJUSTMENT_FUNCTION_AS_READY(adjustmentIndex);
|
||||||
|
@ -445,10 +416,10 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyStepAdjustment(controlRateConfig,adjustmentFunction,delta);
|
applyStepAdjustment(controlRateConfig, adjustmentFunction, delta);
|
||||||
pidInitConfig(pidProfile);
|
pidInitConfig(pidProfile);
|
||||||
} else if (adjustmentState->config->mode == ADJUSTMENT_MODE_SELECT) {
|
} else if (adjustmentState->config->mode == ADJUSTMENT_MODE_SELECT) {
|
||||||
const uint16_t rangeWidth = ((2100 - 900) / adjustmentState->config->data.selectConfig.switchPositions);
|
const uint16_t rangeWidth = ((2100 - 900) / adjustmentState->config->data.switchPositions);
|
||||||
const uint8_t position = (constrain(rcData[channelIndex], 900, 2100 - 1) - 900) / rangeWidth;
|
const uint8_t position = (constrain(rcData[channelIndex], 900, 2100 - 1) - 900) / rangeWidth;
|
||||||
applySelectAdjustment(adjustmentFunction, position);
|
applySelectAdjustment(adjustmentFunction, position);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,17 +56,9 @@ typedef enum {
|
||||||
ADJUSTMENT_MODE_SELECT
|
ADJUSTMENT_MODE_SELECT
|
||||||
} adjustmentMode_e;
|
} adjustmentMode_e;
|
||||||
|
|
||||||
typedef struct adjustmentStepConfig_s {
|
|
||||||
uint8_t step;
|
|
||||||
} adjustmentStepConfig_t;
|
|
||||||
|
|
||||||
typedef struct adjustmentSelectConfig_s {
|
|
||||||
uint8_t switchPositions;
|
|
||||||
} adjustmentSelectConfig_t;
|
|
||||||
|
|
||||||
typedef union adjustmentConfig_u {
|
typedef union adjustmentConfig_u {
|
||||||
adjustmentStepConfig_t stepConfig;
|
uint8_t step;
|
||||||
adjustmentSelectConfig_t selectConfig;
|
uint8_t switchPositions;
|
||||||
} adjustmentData_t;
|
} adjustmentData_t;
|
||||||
|
|
||||||
typedef struct adjustmentConfig_s {
|
typedef struct adjustmentConfig_s {
|
||||||
|
@ -105,10 +97,6 @@ typedef struct adjustmentState_s {
|
||||||
|
|
||||||
PG_DECLARE_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges);
|
PG_DECLARE_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges);
|
||||||
|
|
||||||
typedef struct adjustmentProfile_s {
|
|
||||||
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT];
|
|
||||||
} adjustmentProfile_t;
|
|
||||||
|
|
||||||
void resetAdjustmentStates(void);
|
void resetAdjustmentStates(void);
|
||||||
void updateAdjustmentStates(void);
|
void updateAdjustmentStates(void);
|
||||||
struct controlRateConfig_s;
|
struct controlRateConfig_s;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue