Skip to content

Dead code in spectrum telemetry #11298

@error414

Description

@error414

https://github.com/iNavFlight/inav/blob/master/src/main/telemetry/srxl.c#L187

Inav does not contain USE_ESC_SENSOR_TELEMETRY neither USE_DSHOT_TELEMETRY, neither getEscSensorData(ESC_SENSOR_COMBINED); Probably acidently compied from betaflight, https://github.com/betaflight/betaflight/blob/master/src/main/sensors/esc_sensor.c#L155

If nobody complained about it probably we can remove it, or fix it, unfortunately I don't have any spectrum device.

uint16_t getMotorAveragePeriod(void)
{

#if defined( USE_ESC_SENSOR_TELEMETRY) || defined( USE_DSHOT_TELEMETRY)
    uint32_t rpm = 0;
    uint16_t period_us = SPEKTRUM_RPM_UNUSED;

#if defined( USE_ESC_SENSOR_TELEMETRY)
    escSensorData_t *escData = getEscSensorData(ESC_SENSOR_COMBINED);
    if (escData != NULL) {
        rpm = escData->rpm;
    }
#endif

#if defined(USE_DSHOT_TELEMETRY)
    if (useDshotTelemetry) {
        uint16_t motors = getMotorCount();

        if (motors > 0) {
            for (int motor = 0; motor < motors; motor++) {
                rpm += getDshotTelemetry(motor);
            }
            rpm = 100.0f / (motorConfig()->motorPoleCount / 2.0f) * rpm;  // convert erpm freq to RPM.
            rpm /= motors;           // Average combined rpm
        }
    }
#endif

    if (rpm > SPEKTRUM_MIN_RPM && rpm < SPEKTRUM_MAX_RPM) {
        period_us = MICROSEC_PER_MINUTE / rpm; // revs/minute -> microSeconds
    } else {
        period_us = MICROSEC_PER_MINUTE / SPEKTRUM_MIN_RPM;
    }

    return period_us;
#else
    return SPEKTRUM_RPM_UNUSED;
#endif
}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions