mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
Merge pull request #2748 from toastedcornflakes/in-flight-strength-horizon
Adjustement for horizon strength
This commit is contained in:
commit
d42e07d837
2 changed files with 32 additions and 12 deletions
|
@ -211,6 +211,12 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
|
|||
.adjustmentFunction = ADJUSTMENT_D_SETPOINT_TRANSITION,
|
||||
.mode = ADJUSTMENT_MODE_STEP,
|
||||
.data = { .stepConfig = { .step = 1 }}
|
||||
},
|
||||
{
|
||||
.adjustmentFunction = ADJUSTMENT_HORIZON_STRENGTH,
|
||||
.mode = ADJUSTMENT_MODE_SELECT,
|
||||
.data = { .selectConfig = { .switchPositions = 255 }}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -247,18 +253,18 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t
|
|||
newValue = constrain((int)controlRateConfig->rcRate8 + delta, 0, 250); // FIXME magic numbers repeated in cli.c
|
||||
controlRateConfig->rcRate8 = newValue;
|
||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE, newValue);
|
||||
break;
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
|
@ -360,21 +366,34 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t
|
|||
|
||||
static void applySelectAdjustment(uint8_t adjustmentFunction, uint8_t position)
|
||||
{
|
||||
bool applied = false;
|
||||
uint8_t beeps = 0;
|
||||
|
||||
switch(adjustmentFunction) {
|
||||
case ADJUSTMENT_RATE_PROFILE:
|
||||
if (getCurrentControlRateProfileIndex() != position) {
|
||||
changeControlRateProfile(position);
|
||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RATE_PROFILE, position);
|
||||
applied = true;
|
||||
case ADJUSTMENT_RATE_PROFILE:
|
||||
{
|
||||
if (getCurrentControlRateProfileIndex() != position) {
|
||||
changeControlRateProfile(position);
|
||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RATE_PROFILE, position);
|
||||
beeps = position + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ADJUSTMENT_HORIZON_STRENGTH:
|
||||
{
|
||||
uint8_t newValue = constrain(position, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||
if(pidProfile->D8[PIDLEVEL] != newValue) {
|
||||
beeps = ((newValue - pidProfile->D8[PIDLEVEL]) / 8) + 1;
|
||||
pidProfile->D8[PIDLEVEL] = newValue;
|
||||
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_HORIZON_STRENGTH, position);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (applied) {
|
||||
beeperConfirmationBeeps(position + 1);
|
||||
if (beeps) {
|
||||
beeperConfirmationBeeps(beeps);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#define RESET_FREQUENCY_2HZ (1000 / 2)
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef enum {
|
|||
ADJUSTMENT_RC_RATE_YAW,
|
||||
ADJUSTMENT_D_SETPOINT,
|
||||
ADJUSTMENT_D_SETPOINT_TRANSITION,
|
||||
ADJUSTMENT_HORIZON_STRENGTH,
|
||||
ADJUSTMENT_FUNCTION_COUNT
|
||||
} adjustmentFunction_e;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue