1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Fix for extreme D level term PID1 Horizon

This commit is contained in:
borisbstyle 2015-05-15 02:16:46 +02:00
parent 3c1b678a37
commit 4bdc64bff9

View file

@ -680,12 +680,11 @@ static void pidRewrite(pidProfile_t *pidProfile, controlRateConfig_t *controlRat
// PID D Level Term is used for Horizon Sensitivity. It is adjusted so the default value of 100 works pretty well.
// Default Level D term of 100 equals to 80% sensitivity and 125 and above is 100% sensitivity. It is scaled to prevent too much truncating n integers
if(pidProfile->D8[PIDLEVEL] == 0){
horizonLevelStrength = 0;
} else if (pidProfile->D8[PIDLEVEL] >= 125){
horizonLevelStrength = 100;
if (pidProfile->D8[PIDLEVEL] >= 125){
horizonLevelStrength = constrain((horizonLevelStrength - 100) + 100, 0, 100);
} else {
horizonLevelStrength = constrain((10 * (horizonLevelStrength - 100) * (10 * pidProfile->D8[PIDLEVEL] / 125) / 100) + 100, 0, 100);
horizonLevelStrength = constrain((10 * (horizonLevelStrength - 100) * (10 * pidProfile->D8[PIDLEVEL] / 125) / 100) + 100, 0, 100);
}
}