mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
fix over write other rssiSource not RSSI_SOURCE_RX_PROTOCOL_CRSF
space rename CRSF_LINK_STATUS_UPDATE_TIMEOUT_US move define
This commit is contained in:
parent
653618d0f6
commit
90c3970588
1 changed files with 15 additions and 12 deletions
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
#define CRSF_PAYLOAD_OFFSET offsetof(crsfFrameDef_t, type)
|
#define CRSF_PAYLOAD_OFFSET offsetof(crsfFrameDef_t, type)
|
||||||
|
|
||||||
#define CRSF_LINK_STATUS_UPDATE_US 250000 // 250ms, 4 Hz mode 1 telemetry
|
#define CRSF_LINK_STATUS_UPDATE_TIMEOUT_US 250000 // 250ms, 4 Hz mode 1 telemetry
|
||||||
|
|
||||||
STATIC_UNIT_TESTED bool crsfFrameDone = false;
|
STATIC_UNIT_TESTED bool crsfFrameDone = false;
|
||||||
STATIC_UNIT_TESTED crsfFrame_t crsfFrame;
|
STATIC_UNIT_TESTED crsfFrame_t crsfFrame;
|
||||||
|
@ -153,10 +153,11 @@ static void handleCrsfLinkStatisticsFrame(const crsfLinkStatistics_t* statsPtr,
|
||||||
{
|
{
|
||||||
const crsfLinkStatistics_t stats = *statsPtr;
|
const crsfLinkStatistics_t stats = *statsPtr;
|
||||||
lastLinkStatisticsFrameUs = currentTimeUs;
|
lastLinkStatisticsFrameUs = currentTimeUs;
|
||||||
|
if (rssiSource == RSSI_SOURCE_RX_PROTOCOL_CRSF) {
|
||||||
const uint8_t rssiDbm = stats.active_antenna ? stats.uplink_RSSI_2 : stats.uplink_RSSI_1;
|
const uint8_t rssiDbm = stats.active_antenna ? stats.uplink_RSSI_2 : stats.uplink_RSSI_1;
|
||||||
const uint16_t rssiPercentScaled = scaleRange(rssiDbm, 130, 0, 0, RSSI_MAX_VALUE);
|
const uint16_t rssiPercentScaled = scaleRange(rssiDbm, 130, 0, 0, RSSI_MAX_VALUE);
|
||||||
setRssi(rssiPercentScaled, RSSI_SOURCE_RX_PROTOCOL_CRSF);
|
setRssi(rssiPercentScaled, RSSI_SOURCE_RX_PROTOCOL_CRSF);
|
||||||
|
}
|
||||||
|
|
||||||
switch (debugMode) {
|
switch (debugMode) {
|
||||||
case DEBUG_CRSF_LINK_STATISTICS_UPLINK:
|
case DEBUG_CRSF_LINK_STATISTICS_UPLINK:
|
||||||
|
@ -180,15 +181,16 @@ static void handleCrsfLinkStatisticsFrame(const crsfLinkStatistics_t* statsPtr,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void crsfCheckRssi(uint32_t currentTimeUs) {
|
|
||||||
UNUSED(currentTimeUs);
|
|
||||||
|
|
||||||
#if defined(USE_CRSF_LINK_STATISTICS)
|
#if defined(USE_CRSF_LINK_STATISTICS)
|
||||||
if (cmpTimeUs(currentTimeUs, lastLinkStatisticsFrameUs) > CRSF_LINK_STATUS_UPDATE_US) {
|
static void crsfCheckRssi(uint32_t currentTimeUs) {
|
||||||
setRssiDirect(0,RSSI_SOURCE_RX_PROTOCOL_CRSF);
|
|
||||||
|
if ( cmpTimeUs(currentTimeUs, lastLinkStatisticsFrameUs) > CRSF_LINK_STATUS_UPDATE_TIMEOUT_US) {
|
||||||
|
if (rssiSource == RSSI_SOURCE_RX_PROTOCOL_CRSF) {
|
||||||
|
setRssiDirect(0, RSSI_SOURCE_RX_PROTOCOL_CRSF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC_UNIT_TESTED uint8_t crsfFrameCRC(void)
|
STATIC_UNIT_TESTED uint8_t crsfFrameCRC(void)
|
||||||
{
|
{
|
||||||
|
@ -281,8 +283,9 @@ STATIC_UNIT_TESTED uint8_t crsfFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig)
|
||||||
{
|
{
|
||||||
UNUSED(rxRuntimeConfig);
|
UNUSED(rxRuntimeConfig);
|
||||||
|
|
||||||
|
#if defined(USE_CRSF_LINK_STATISTICS)
|
||||||
crsfCheckRssi(micros());
|
crsfCheckRssi(micros());
|
||||||
|
#endif
|
||||||
if (crsfFrameDone) {
|
if (crsfFrameDone) {
|
||||||
crsfFrameDone = false;
|
crsfFrameDone = false;
|
||||||
if (crsfFrame.frame.type == CRSF_FRAMETYPE_RC_CHANNELS_PACKED) {
|
if (crsfFrame.frame.type == CRSF_FRAMETYPE_RC_CHANNELS_PACKED) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue