@@ -47,7 +47,7 @@ static float motord(float in, int x) {
4747 return in + out ;
4848}
4949
50- static void motor_brushless_mixer_scale_calc (float throttle , float mix [MOTOR_PIN_MAX ]) {
50+ static void motor_brushless_mixer_scale_calc (float throttle , float mix [MULTI_MOTOR_COUNT ]) {
5151 // only enable once really in the air
5252 if (flags .on_ground || !flags .in_air ) {
5353 return ;
@@ -56,7 +56,7 @@ static void motor_brushless_mixer_scale_calc(float throttle, float mix[MOTOR_PIN
5656 float min = FLT_MAX ;
5757 float max = FLT_MIN ;
5858
59- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ ) {
59+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ ) {
6060 if (mix [i ] < min ) {
6161 min = mix [i ];
6262 }
@@ -72,18 +72,18 @@ static void motor_brushless_mixer_scale_calc(float throttle, float mix[MOTOR_PIN
7272 const float scaled_max = max * scale ;
7373 const float scaled_throttle = constrain (throttle , - scaled_min , 1.0f - scaled_max );
7474
75- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ ) {
75+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ ) {
7676 mix [i ] = mix [i ] * scale + scaled_throttle ;
7777 }
7878}
7979
80- static void motor_brushed_mixer_scale_calc (float throttle , float mix [MOTOR_PIN_MAX ]) {
80+ static void motor_brushed_mixer_scale_calc (float throttle , float mix [MULTI_MOTOR_COUNT ]) {
8181 // throttle reduction
8282 float overthrottle = 0 ;
8383 float underthrottle = 0.001f ;
8484 static float overthrottlefilt = 0 ;
8585
86- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ ) {
86+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ ) {
8787 mix [i ] += throttle ;
8888
8989 if (mix [i ] > overthrottle )
@@ -117,7 +117,7 @@ static void motor_brushed_mixer_scale_calc(float throttle, float mix[MOTOR_PIN_M
117117
118118 if (overthrottle > 0 ) { // exceeding max motor thrust
119119 float temp = overthrottle ;
120- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ ) {
120+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ ) {
121121 mix [i ] -= temp ;
122122 }
123123 }
@@ -126,7 +126,7 @@ static void motor_brushed_mixer_scale_calc(float throttle, float mix[MOTOR_PIN_M
126126 if (flags .in_air == 1 ) {
127127 float underthrottle = 0 ;
128128
129- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ ) {
129+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ ) {
130130 if (mix [i ] < underthrottle )
131131 underthrottle = mix [i ];
132132 }
@@ -136,20 +136,20 @@ static void motor_brushed_mixer_scale_calc(float throttle, float mix[MOTOR_PIN_M
136136 underthrottle = - (float )MIX_THROTTLE_INCREASE_MAX ;
137137
138138 if (underthrottle < 0.0f ) {
139- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ )
139+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ )
140140 mix [i ] -= underthrottle ;
141141 }
142142 }
143143}
144144
145- static void motor_mixer_scale_calc (float throttle , float mix [MOTOR_PIN_MAX ]) {
145+ static void motor_mixer_scale_calc (float throttle , float mix [MULTI_MOTOR_COUNT ]) {
146146 if (target .brushless ) {
147147 return motor_brushless_mixer_scale_calc (throttle , mix );
148148 }
149149 return motor_brushed_mixer_scale_calc (throttle , mix );
150150}
151151
152- void motor_test_calc (bool motortest_usb , float mix [MOTOR_PIN_MAX ]) {
152+ void motor_test_calc (bool motortest_usb , float mix [MULTI_MOTOR_COUNT ]) {
153153 if (motortest_usb ) {
154154 // set mix according to values we got via usb
155155 mix [MOTOR_FR ] = motor_test .value [MOTOR_FR ];
@@ -184,7 +184,7 @@ void motor_test_calc(bool motortest_usb, float mix[MOTOR_PIN_MAX]) {
184184 }
185185}
186186
187- void motor_mixer_calc (float mix [MOTOR_PIN_MAX ]) {
187+ void motor_mixer_calc (float mix [MULTI_MOTOR_COUNT ]) {
188188 const float yaw = profile .motor .invert_yaw ? - state .pidoutput .yaw : state .pidoutput .yaw ;
189189
190190#ifndef MOTOR_PLUS_CONFIGURATION
@@ -202,7 +202,7 @@ void motor_mixer_calc(float mix[MOTOR_PIN_MAX]) {
202202#endif
203203
204204 if (profile .motor .torque_boost > 0.0f ) {
205- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ ) {
205+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ ) {
206206 mix [i ] = motord (mix [i ], i );
207207 }
208208 }
@@ -211,7 +211,7 @@ void motor_mixer_calc(float mix[MOTOR_PIN_MAX]) {
211211}
212212
213213//********************************MOTOR OUTPUT***********************************************************
214- void motor_output_calc (float mix [MOTOR_PIN_MAX ]) {
214+ void motor_output_calc (float mix [MULTI_MOTOR_COUNT ]) {
215215 state .thrsum = 0 ; // reset throttle sum for voltage monitoring logic in main loop
216216
217217 // only apply digital idle if we are armed and not in motor test
@@ -222,22 +222,19 @@ void motor_output_calc(float mix[MOTOR_PIN_MAX]) {
222222 }
223223
224224 // Begin for-loop to send motor commands
225- for (uint32_t i = 0 ; i < MOTOR_PIN_MAX ; i ++ ) {
225+ for (uint32_t i = 0 ; i < MULTI_MOTOR_COUNT ; i ++ ) {
226226 if (!flags .motortest_override ) {
227227 // use values as supplied in motor test mode
228228 mix [i ] = constrain (mix [i ], 0 , 1 );
229229 mix [i ] = mapf (mix [i ], 0.0f , 1.0f , motor_min_value , profile .motor .motor_limit * 0.01f );
230230 } else if (mix [i ] <= 0.0f ) {
231- // zero throttle in motor test must map to MOTOR_OFF (-1) so the dshot driver sends value 0 ( stop) rather than 48 ( min throttle)
231+ // zero throttle in motor test must map to MOTOR_OFF so the dshot driver sends stop rather than min throttle
232232 mix [i ] = MOTOR_OFF ;
233233 }
234234
235- #ifndef NOMOTORS
236- output_set_role (OUTPUT_ROLE_MOTOR_1 + i , mix [i ]);
237- #endif
238235 state .thrsum += mix [i ];
239236 }
240237
241238 // calculate throttle sum for voltage monitoring logic in main loop
242- state .thrsum = state .thrsum / MOTOR_PIN_MAX ;
239+ state .thrsum = state .thrsum / MULTI_MOTOR_COUNT ;
243240}
0 commit comments