From f9966d1eee9153d737c95b182003c30f8b19e514 Mon Sep 17 00:00:00 2001 From: kedeng Date: Fri, 11 Jul 2025 19:12:14 +0800 Subject: [PATCH] Remove unnecessary enum for dshot_edt_always_decode option --- src/main/drivers/dshot.c | 5 ++--- src/main/pg/motor.c | 2 +- src/main/pg/motor.h | 5 ----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/drivers/dshot.c b/src/main/drivers/dshot.c index c3647098c7..3c50dbaba5 100644 --- a/src/main/drivers/dshot.c +++ b/src/main/drivers/dshot.c @@ -150,7 +150,7 @@ FAST_DATA_ZERO_INIT static float minMotorFrequencyHz; FAST_DATA_ZERO_INIT static float erpmToHz; FAST_DATA_ZERO_INIT static float dshotRpmAverage; FAST_DATA_ZERO_INIT static float dshotRpm[MAX_SUPPORTED_MOTORS]; -FAST_DATA_ZERO_INIT static dshotEdtAlwaysDecode_e edtAlwaysDecode; +FAST_DATA_ZERO_INIT static bool edtAlwaysDecode; // Lookup table for extended telemetry type decoding // Only contains extended telemetry types, eRPM is handled by conditional logic @@ -215,8 +215,7 @@ static uint32_t dshot_decode_eRPM_telemetry_value(uint16_t value) static void dshot_decode_telemetry_value(uint8_t motorIndex, uint32_t *pDecoded, dshotTelemetryType_t *pType) { uint16_t value = dshotTelemetryState.motorState[motorIndex].rawValue; - bool isEdtEnabled = (dshotTelemetryState.motorState[motorIndex].telemetryTypes & DSHOT_EXTENDED_TELEMETRY_MASK) != 0; - isEdtEnabled = isEdtEnabled || (edtAlwaysDecode == DSHOT_EDT_ALWAYS_DECODE_ON); + bool isEdtEnabled = edtAlwaysDecode || (dshotTelemetryState.motorState[motorIndex].telemetryTypes & DSHOT_EXTENDED_TELEMETRY_MASK) != 0; // https://github.com/bird-sanctuary/extended-dshot-telemetry // Extract telemetry type field and check for eRPM conditions in one operation diff --git a/src/main/pg/motor.c b/src/main/pg/motor.c index 5f6682cb77..c34fe2e560 100644 --- a/src/main/pg/motor.c +++ b/src/main/pg/motor.c @@ -48,7 +48,7 @@ #endif #if !defined(DEFAULT_DSHOT_EDT_ALWAYS_DECODE) -#define DEFAULT_DSHOT_EDT_ALWAYS_DECODE DSHOT_EDT_ALWAYS_DECODE_OFF +#define DEFAULT_DSHOT_EDT_ALWAYS_DECODE false #endif PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 4); diff --git a/src/main/pg/motor.h b/src/main/pg/motor.h index d4adc82a18..6161f43833 100644 --- a/src/main/pg/motor.h +++ b/src/main/pg/motor.h @@ -57,11 +57,6 @@ typedef enum { DSHOT_TELEMETRY_ON, } dshotTelemetry_e; -typedef enum { - DSHOT_EDT_ALWAYS_DECODE_OFF, - DSHOT_EDT_ALWAYS_DECODE_ON, -} dshotEdtAlwaysDecode_e; - typedef struct motorDevConfig_s { uint16_t motorPwmRate; // The update rate of motor outputs (50-498Hz) uint8_t motorProtocol; // Pwm Protocol