1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 21:05:35 +03:00

Fixed getDshotAverageRpm function (#12178)

Fixed getDshotAverageRpm function, that was returning erpm value instead of rpm one
This commit is contained in:
Daniel Mosquera 2023-01-15 03:42:10 +01:00 committed by GitHub
parent 040a519ecd
commit f39f267301
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -261,7 +261,7 @@ uint16_t getDshotTelemetry(uint8_t index)
// Process telemetry in case it haven´t been processed yet
if (dshotTelemetryState.rawValueState == DSHOT_RAW_VALUE_STATE_NOT_PROCESSED) {
const unsigned motorCount = motorDeviceCount();
uint32_t rpmTotal = 0;
uint32_t erpmTotal = 0;
uint32_t rpmSamples = 0;
// Decode all telemetry data now to discharge interrupt from this task
@ -275,7 +275,7 @@ uint16_t getDshotTelemetry(uint8_t index)
dshotUpdateTelemetryData(k, type, value);
if (type == DSHOT_TELEMETRY_TYPE_eRPM) {
rpmTotal += value;
erpmTotal += value;
rpmSamples++;
}
}
@ -283,7 +283,7 @@ uint16_t getDshotTelemetry(uint8_t index)
// Update average
if (rpmSamples > 0) {
dshotTelemetryState.averageRpm = rpmTotal / rpmSamples;
dshotTelemetryState.averageErpm = (uint16_t)(erpmTotal / rpmSamples);
}
// Set state to processed
@ -325,7 +325,7 @@ uint32_t erpmToRpm(uint16_t erpm)
uint32_t getDshotAverageRpm(void)
{
return dshotTelemetryState.averageRpm;
return erpmToRpm(dshotTelemetryState.averageErpm);
}
#endif // USE_DSHOT_TELEMETRY

View file

@ -103,7 +103,7 @@ typedef struct dshotTelemetryState_s {
uint32_t readCount;
dshotTelemetryMotorState_t motorState[MAX_SUPPORTED_MOTORS];
uint32_t inputBuffer[MAX_GCR_EDGES];
uint32_t averageRpm;
uint16_t averageErpm;
dshotRawValueState_t rawValueState;
} dshotTelemetryState_t;