mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Tidy of mixer code. Remove motorCount extern
This commit is contained in:
parent
1475138e75
commit
ae1944b78c
7 changed files with 71 additions and 61 deletions
|
@ -289,9 +289,6 @@ typedef struct blackboxSlowState_s {
|
|||
bool rxFlightChannelsValid;
|
||||
} __attribute__((__packed__)) blackboxSlowState_t; // We pack this struct so that padding doesn't interfere with memcmp()
|
||||
|
||||
//From mixer.c:
|
||||
extern uint8_t motorCount;
|
||||
|
||||
//From rc_controls.c
|
||||
extern uint32_t rcModeActivationMask;
|
||||
|
||||
|
@ -367,7 +364,7 @@ static bool testBlackboxConditionUncached(FlightLogFieldCondition condition)
|
|||
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_6:
|
||||
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_7:
|
||||
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_8:
|
||||
return motorCount >= condition - FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_1 + 1;
|
||||
return getMotorCount() >= condition - FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_1 + 1;
|
||||
|
||||
case FLIGHT_LOG_FIELD_CONDITION_TRICOPTER:
|
||||
return mixerConfig()->mixerMode == MIXER_TRI || mixerConfig()->mixerMode == MIXER_CUSTOM_TRI;
|
||||
|
@ -472,7 +469,6 @@ static void blackboxSetState(BlackboxState newState)
|
|||
static void writeIntraframe(void)
|
||||
{
|
||||
blackboxMainState_t *blackboxCurrent = blackboxHistory[0];
|
||||
int x;
|
||||
|
||||
blackboxWrite('I');
|
||||
|
||||
|
@ -483,7 +479,7 @@ static void writeIntraframe(void)
|
|||
blackboxWriteSignedVBArray(blackboxCurrent->axisPID_I, XYZ_AXIS_COUNT);
|
||||
|
||||
// Don't bother writing the current D term if the corresponding PID setting is zero
|
||||
for (x = 0; x < XYZ_AXIS_COUNT; x++) {
|
||||
for (int x = 0; x < XYZ_AXIS_COUNT; x++) {
|
||||
if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_0 + x)) {
|
||||
blackboxWriteSignedVB(blackboxCurrent->axisPID_D[x]);
|
||||
}
|
||||
|
@ -543,7 +539,8 @@ static void writeIntraframe(void)
|
|||
blackboxWriteUnsignedVB(blackboxCurrent->motor[0] - motorConfig()->minthrottle);
|
||||
|
||||
//Motors tend to be similar to each other so use the first motor's value as a predictor of the others
|
||||
for (x = 1; x < motorCount; x++) {
|
||||
const int motorCount = getMotorCount();
|
||||
for (int x = 1; x < motorCount; x++) {
|
||||
blackboxWriteSignedVB(blackboxCurrent->motor[x] - blackboxCurrent->motor[0]);
|
||||
}
|
||||
|
||||
|
@ -667,7 +664,7 @@ static void writeInterframe(void)
|
|||
blackboxWriteMainStateArrayUsingAveragePredictor(offsetof(blackboxMainState_t, gyroADC), XYZ_AXIS_COUNT);
|
||||
blackboxWriteMainStateArrayUsingAveragePredictor(offsetof(blackboxMainState_t, accSmooth), XYZ_AXIS_COUNT);
|
||||
blackboxWriteMainStateArrayUsingAveragePredictor(offsetof(blackboxMainState_t, debug), 4);
|
||||
blackboxWriteMainStateArrayUsingAveragePredictor(offsetof(blackboxMainState_t, motor), motorCount);
|
||||
blackboxWriteMainStateArrayUsingAveragePredictor(offsetof(blackboxMainState_t, motor), getMotorCount());
|
||||
|
||||
if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_TRICOPTER)) {
|
||||
blackboxWriteSignedVB(blackboxCurrent->servo[5] - blackboxLast->servo[5]);
|
||||
|
@ -1002,6 +999,7 @@ static void loadMainState(timeUs_t currentTimeUs)
|
|||
blackboxCurrent->debug[i] = debug[i];
|
||||
}
|
||||
|
||||
const int motorCount = getMotorCount();
|
||||
for (i = 0; i < motorCount; i++) {
|
||||
blackboxCurrent->motor[i] = motor[i];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue