mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
In flight adjustement for horizon strength
This commit is contained in:
parent
9785c297cd
commit
d4005e06f1
2 changed files with 21 additions and 4 deletions
|
@ -211,6 +211,12 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
|
||||||
.adjustmentFunction = ADJUSTMENT_D_SETPOINT_TRANSITION,
|
.adjustmentFunction = ADJUSTMENT_D_SETPOINT_TRANSITION,
|
||||||
.mode = ADJUSTMENT_MODE_STEP,
|
.mode = ADJUSTMENT_MODE_STEP,
|
||||||
.data = { .stepConfig = { .step = 1 }}
|
.data = { .stepConfig = { .step = 1 }}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.adjustmentFunction = ADJUSTMENT_HORIZON_STRENGTH,
|
||||||
|
.mode = ADJUSTMENT_MODE_SELECT,
|
||||||
|
.data = { .selectConfig = { .switchPositions = 255 }}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -360,21 +366,31 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t
|
||||||
|
|
||||||
static void applySelectAdjustment(uint8_t adjustmentFunction, uint8_t position)
|
static void applySelectAdjustment(uint8_t adjustmentFunction, uint8_t position)
|
||||||
{
|
{
|
||||||
bool applied = false;
|
uint8_t beeps = 0;
|
||||||
|
uint8_t newValue = 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);
|
||||||
applied = true;
|
beeps = position + 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_HORIZON_STRENGTH:
|
||||||
|
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) {
|
if(beeps) {
|
||||||
beeperConfirmationBeeps(position + 1);
|
beeperConfirmationBeeps(beeps);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RESET_FREQUENCY_2HZ (1000 / 2)
|
#define RESET_FREQUENCY_2HZ (1000 / 2)
|
||||||
|
|
|
@ -46,6 +46,7 @@ typedef enum {
|
||||||
ADJUSTMENT_RC_RATE_YAW,
|
ADJUSTMENT_RC_RATE_YAW,
|
||||||
ADJUSTMENT_D_SETPOINT,
|
ADJUSTMENT_D_SETPOINT,
|
||||||
ADJUSTMENT_D_SETPOINT_TRANSITION,
|
ADJUSTMENT_D_SETPOINT_TRANSITION,
|
||||||
|
ADJUSTMENT_HORIZON_STRENGTH,
|
||||||
ADJUSTMENT_FUNCTION_COUNT
|
ADJUSTMENT_FUNCTION_COUNT
|
||||||
} adjustmentFunction_e;
|
} adjustmentFunction_e;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue