mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
Use motorCount from mixer.c instead of determine motor count again
This commit is contained in:
parent
0df4c63132
commit
bc1109c546
3 changed files with 9 additions and 10 deletions
|
@ -240,6 +240,10 @@ static motorMixer_t *customMixers;
|
||||||
static uint16_t disarmMotorOutput, minMotorOutputNormal, maxMotorOutputNormal, deadbandMotor3dHigh, deadbandMotor3dLow;
|
static uint16_t disarmMotorOutput, minMotorOutputNormal, maxMotorOutputNormal, deadbandMotor3dHigh, deadbandMotor3dLow;
|
||||||
static float rcCommandThrottleRange;
|
static float rcCommandThrottleRange;
|
||||||
|
|
||||||
|
uint8_t getMotorCount() {
|
||||||
|
return motorCount;
|
||||||
|
}
|
||||||
|
|
||||||
bool isMotorProtocolDshot(void) {
|
bool isMotorProtocolDshot(void) {
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (motorConfig->motorPwmProtocol == PWM_TYPE_DSHOT150 || motorConfig->motorPwmProtocol == PWM_TYPE_DSHOT300 || motorConfig->motorPwmProtocol == PWM_TYPE_DSHOT600)
|
if (motorConfig->motorPwmProtocol == PWM_TYPE_DSHOT150 || motorConfig->motorPwmProtocol == PWM_TYPE_DSHOT300 || motorConfig->motorPwmProtocol == PWM_TYPE_DSHOT600)
|
||||||
|
|
|
@ -115,6 +115,8 @@ extern int16_t motor_disarmed[MAX_SUPPORTED_MOTORS];
|
||||||
struct motorConfig_s;
|
struct motorConfig_s;
|
||||||
struct rxConfig_s;
|
struct rxConfig_s;
|
||||||
|
|
||||||
|
uint8_t getMotorCount();
|
||||||
|
|
||||||
void mixerUseConfigs(
|
void mixerUseConfigs(
|
||||||
flight3DConfig_t *flight3DConfigToUse,
|
flight3DConfig_t *flight3DConfigToUse,
|
||||||
struct motorConfig_s *motorConfigToUse,
|
struct motorConfig_s *motorConfigToUse,
|
||||||
|
|
|
@ -90,7 +90,6 @@ static serialPort_t *escTelemetryPort = NULL;
|
||||||
static esc_telemetry_t escTelemetryData[MAX_SUPPORTED_MOTORS];
|
static esc_telemetry_t escTelemetryData[MAX_SUPPORTED_MOTORS];
|
||||||
static uint32_t escTriggerTimestamp = -1;
|
static uint32_t escTriggerTimestamp = -1;
|
||||||
static uint32_t escTriggerLastTimestamp = -1;
|
static uint32_t escTriggerLastTimestamp = -1;
|
||||||
static uint8_t enabledMotorCount;
|
|
||||||
static uint8_t timeoutRetryCount = 0;
|
static uint8_t timeoutRetryCount = 0;
|
||||||
|
|
||||||
static uint8_t escTelemetryMotor = 0; // motor index
|
static uint8_t escTelemetryMotor = 0; // motor index
|
||||||
|
@ -142,12 +141,6 @@ bool escTelemetryInit(void)
|
||||||
escTelemetryEnabled = true;
|
escTelemetryEnabled = true;
|
||||||
masterConfig.batteryConfig.currentMeterType = CURRENT_SENSOR_ESC;
|
masterConfig.batteryConfig.currentMeterType = CURRENT_SENSOR_ESC;
|
||||||
masterConfig.batteryConfig.batteryMeterType = BATTERY_SENSOR_ESC;
|
masterConfig.batteryConfig.batteryMeterType = BATTERY_SENSOR_ESC;
|
||||||
|
|
||||||
//Determine number of enabled motors
|
|
||||||
enabledMotorCount = 0;
|
|
||||||
while(enabledMotorCount < MAX_SUPPORTED_MOTORS && pwmGetMotors()[enabledMotorCount].enabled) {
|
|
||||||
enabledMotorCount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return escTelemetryPort != NULL;
|
return escTelemetryPort != NULL;
|
||||||
|
@ -254,12 +247,12 @@ void escTelemetryProcess(uint32_t currentTime)
|
||||||
|
|
||||||
if (state == ESC_TLM_FRAME_COMPLETE) {
|
if (state == ESC_TLM_FRAME_COMPLETE) {
|
||||||
// Wait until all ESCs are processed
|
// Wait until all ESCs are processed
|
||||||
if (escTelemetryMotor == enabledMotorCount-1) {
|
if (escTelemetryMotor == getMotorCount()-1) {
|
||||||
escCurrent = 0;
|
escCurrent = 0;
|
||||||
escConsumption = 0;
|
escConsumption = 0;
|
||||||
escVbat = 0;
|
escVbat = 0;
|
||||||
|
|
||||||
for (int i = 0; i < enabledMotorCount; i++) {
|
for (int i = 0; i < getMotorCount(); i++) {
|
||||||
if (!escTelemetryData[i].skipped) {
|
if (!escTelemetryData[i].skipped) {
|
||||||
escVbat = i > 0 ? ((escVbat + escTelemetryData[i].voltage) / 2) : escTelemetryData[i].voltage;
|
escVbat = i > 0 ? ((escVbat + escTelemetryData[i].voltage) / 2) : escTelemetryData[i].voltage;
|
||||||
escCurrent = escCurrent + escTelemetryData[i].current;
|
escCurrent = escCurrent + escTelemetryData[i].current;
|
||||||
|
@ -288,7 +281,7 @@ void escTelemetryProcess(uint32_t currentTime)
|
||||||
static void selectNextMotor(void)
|
static void selectNextMotor(void)
|
||||||
{
|
{
|
||||||
escTelemetryMotor++;
|
escTelemetryMotor++;
|
||||||
if (escTelemetryMotor == enabledMotorCount) {
|
if (escTelemetryMotor == getMotorCount()) {
|
||||||
escTelemetryMotor = 0;
|
escTelemetryMotor = 0;
|
||||||
}
|
}
|
||||||
escTriggerTimestamp = millis();
|
escTriggerTimestamp = millis();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue