mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
Add user option to force DSHOT EDT decoding always on
This commit is contained in:
parent
acbab53d13
commit
d5f8526ae6
5 changed files with 17 additions and 1 deletions
|
@ -956,6 +956,7 @@ const clivalue_t valueTable[] = {
|
|||
#ifdef USE_DSHOT_TELEMETRY
|
||||
{ PARAM_NAME_DSHOT_BIDIR, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotTelemetry) },
|
||||
{ "dshot_edt", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotEdt) },
|
||||
{ "dshot_edt_always_decode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotEdtAlwaysDecode) },
|
||||
#endif
|
||||
#ifdef USE_DSHOT_BITBANG
|
||||
{ "dshot_bitbang", VAR_UINT8 | HARDWARE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON_AUTO }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotBitbang) },
|
||||
|
|
|
@ -150,6 +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;
|
||||
|
||||
// Lookup table for extended telemetry type decoding
|
||||
// Only contains extended telemetry types, eRPM is handled by conditional logic
|
||||
|
@ -180,6 +181,7 @@ void initDshotTelemetry(const timeUs_t looptimeUs)
|
|||
|
||||
// erpmToHz is used by bidir dshot and ESC telemetry
|
||||
erpmToHz = ERPM_PER_LSB / SECONDS_PER_MINUTE / (motorConfig()->motorPoleCount / 2.0f);
|
||||
edtAlwaysDecode = motorConfig()->dev.useDshotEdtAlwaysDecode == DSHOT_EDT_ALWAYS_DECODE_ON;
|
||||
|
||||
#ifdef USE_RPM_FILTER
|
||||
if (motorConfig()->dev.useDshotTelemetry) {
|
||||
|
@ -214,6 +216,7 @@ static void dshot_decode_telemetry_value(uint8_t motorIndex, uint32_t *pDecoded,
|
|||
{
|
||||
uint16_t value = dshotTelemetryState.motorState[motorIndex].rawValue;
|
||||
bool isEdtEnabled = (dshotTelemetryState.motorState[motorIndex].telemetryTypes & DSHOT_EXTENDED_TELEMETRY_MASK) != 0;
|
||||
isEdtEnabled |= edtAlwaysDecode;
|
||||
|
||||
// https://github.com/bird-sanctuary/extended-dshot-telemetry
|
||||
// Extract telemetry type field and check for eRPM conditions in one operation
|
||||
|
|
|
@ -47,7 +47,11 @@
|
|||
#define DEFAULT_DSHOT_TELEMETRY DSHOT_TELEMETRY_OFF
|
||||
#endif
|
||||
|
||||
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 3);
|
||||
#if !defined(DEFAULT_DSHOT_EDT_ALWAYS_DECODE)
|
||||
#define DEFAULT_DSHOT_EDT_ALWAYS_DECODE DSHOT_EDT_ALWAYS_DECODE_OFF
|
||||
#endif
|
||||
|
||||
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 4);
|
||||
|
||||
void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
||||
{
|
||||
|
@ -112,6 +116,7 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
|||
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
motorConfig->dev.useDshotTelemetry = DEFAULT_DSHOT_TELEMETRY;
|
||||
motorConfig->dev.useDshotEdtAlwaysDecode = DEFAULT_DSHOT_EDT_ALWAYS_DECODE;
|
||||
#endif
|
||||
|
||||
#ifdef USE_DSHOT_BITBANG
|
||||
|
|
|
@ -57,6 +57,11 @@ 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
|
||||
|
@ -65,6 +70,7 @@ typedef struct motorDevConfig_s {
|
|||
uint8_t useBurstDshot;
|
||||
uint8_t useDshotTelemetry;
|
||||
uint8_t useDshotEdt;
|
||||
uint8_t useDshotEdtAlwaysDecode;
|
||||
ioTag_t ioTags[MAX_SUPPORTED_MOTORS];
|
||||
uint8_t motorTransportProtocol;
|
||||
uint8_t useDshotBitbang;
|
||||
|
|
|
@ -43,6 +43,7 @@ PG_RESET_TEMPLATE(motorConfig_t, motorConfig,
|
|||
.useBurstDshot = 0,
|
||||
.useDshotTelemetry = 0,
|
||||
.useDshotEdt = 0,
|
||||
.useDshotEdtAlwaysDecode = 0,
|
||||
.ioTags = {IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE},
|
||||
.motorTransportProtocol = 0,
|
||||
.useDshotBitbang = 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue