1
0
Fork 0
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:
toastedcornflakes 2017-03-26 17:06:05 +02:00
parent 9785c297cd
commit d4005e06f1
2 changed files with 21 additions and 4 deletions

View file

@ -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 }}
}
};
@ -360,21 +366,31 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t
static void applySelectAdjustment(uint8_t adjustmentFunction, uint8_t position)
{
bool applied = false;
uint8_t beeps = 0;
uint8_t newValue = 0;
switch(adjustmentFunction) {
case ADJUSTMENT_RATE_PROFILE:
if (getCurrentControlRateProfileIndex() != position) {
changeControlRateProfile(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;
}
if (applied) {
beeperConfirmationBeeps(position + 1);
if(beeps) {
beeperConfirmationBeeps(beeps);
}
}
#define RESET_FREQUENCY_2HZ (1000 / 2)

View file

@ -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;