mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Fixed getDshotAverageRpm function (#12178)
Fixed getDshotAverageRpm function, that was returning erpm value instead of rpm one
This commit is contained in:
parent
040a519ecd
commit
f39f267301
2 changed files with 5 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue