motor: tidy mix scaling
@@ -79,16 +79,11 @@ static float motord(float in, int x) {
static void motor_mixer_scale_calc(float mix[4]) {
#ifdef BRUSHLESS_MIX_SCALING
- uint8_t mix_scaling = 0;
-
// only enable once really in the air
- if (flags.on_ground) {
- mix_scaling = 0;
- } else {
- mix_scaling = flags.in_air;
+ if (flags.on_ground || !flags.in_air) {
+ return;
}
- if (mix_scaling) {
float mix_min = 1000.0f;
float mix_max = -1000.0f;
@@ -104,11 +99,11 @@ static void motor_mixer_scale_calc(float mix[4]) {
mix_max = (1 + CLIPPING_LIMIT);
}
- float mix_range = mix_max - mix_min;
float reduce_amount = 0.0f;
+ const float mix_range = mix_max - mix_min;
if (mix_range > 1.0f) {
- float scale = 1.0f / mix_range;
+ const float scale = 1.0f / mix_range;
for (int i = 0; i < 4; i++)
mix[i] *= scale;
@@ -122,11 +117,8 @@ static void motor_mixer_scale_calc(float mix[4]) {
reduce_amount = mix_min;
}
- if (reduce_amount != 0.0f) {
for (int i = 0; i < 4; i++)
mix[i] -= reduce_amount;
- }
- }
#endif
#ifdef BRUSHED_MIX_SCALING
