File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -156,8 +156,18 @@ vec3_t input_rates_calc() {
156156}
157157
158158float input_throttle_calc (float throttle ) {
159- const float n = (throttle * 2.f - 1.f );
160159 const float expo = profile .rate .throttle_expo ;
161160 const float mid = profile .rate .throttle_mid ;
162- return constrain ((n * n * n * expo + n * (1.f - expo ) + 1.f ) * mid , 0.0f , 1.0f );
161+ const float throttle_minus_mid = throttle - mid ;
162+
163+ float divisor = 1 ;
164+ if (throttle_minus_mid > 0.0f ) {
165+ divisor = 1 - mid ;
166+ }
167+ if (throttle_minus_mid < 0.0f ) {
168+ divisor = mid ;
169+ }
170+
171+ // betaflight's throttle curve: https://github.com/betaflight/betaflight/blob/c513b102b6f2af9aa0390cfa7ef908ec652552fc/src/main/fc/rc.c#L838
172+ return constrain (mid + throttle_minus_mid * (1 - expo + expo * (throttle_minus_mid * throttle_minus_mid ) / (divisor * divisor )), 0.0f , 1.0f );
163173}
You can’t perform that action at this time.
0 commit comments