Skip to content

Commit

Permalink
Add diversity antenna element for CRSF
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Feb 13, 2023
1 parent 19f22f5 commit c90e05f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/osd/osd_elements.c
Expand Up @@ -1458,7 +1458,13 @@ static void osdElementRssiDbm(osdElementParms_t *element)
#ifdef USE_RX_RSNR
static void osdElementRsnr(osdElementParms_t *element)
{
tfp_sprintf(element->buff, "%c%3d", SYM_RSSI, getRsnr());
const int8_t antenna = getActiveAntenna();

if (antenna) {
tfp_sprintf(element->buff, "%c%3d(%1d)", SYM_RSSI, getRsnr(), antenna + 1);
} else {
tfp_sprintf(element->buff, "%c%3d", SYM_RSSI, getRsnr());
}
}
#endif // USE_RX_RSNR

Expand Down
1 change: 1 addition & 0 deletions src/main/rx/crsf.c
Expand Up @@ -238,6 +238,7 @@ static void handleCrsfLinkStatisticsFrame(const crsfLinkStatistics_t* statsPtr,

#ifdef USE_RX_RSNR
setRsnr(stats.uplink_SNR);
setActiveAntenna(stats.active_antenna);
#endif

#ifdef USE_RX_LINK_QUALITY_INFO
Expand Down
11 changes: 11 additions & 0 deletions src/main/rx/rx.c
Expand Up @@ -83,6 +83,7 @@ static int16_t rssiDbm = CRSF_RSSI_MIN; // range: [-130,0]
static int16_t rssiDbmRaw = CRSF_RSSI_MIN; // range: [-130,0]
#endif //USE_RX_RSSI_DBM
#ifdef USE_RX_RSNR
static int8_t activeAntenna;
static int16_t rsnr = CRSF_SNR_MIN; // range: [-30,20]
static int16_t rsnrRaw = CRSF_SNR_MIN; // range: [-30,20]
#endif //USE_RX_RSNR
Expand Down Expand Up @@ -945,6 +946,16 @@ void setRssiDbmDirect(int16_t newRssiDbm, rssiSource_e source)
#endif //USE_RX_RSSI_DBM

#ifdef USE_RX_RSNR
int8_t getActiveAntenna(void)
{
return activeAntenna;
}

void setActiveAntenna(int8_t antenna)
{
activeAntenna = antenna;
}

int16_t getRsnr(void)
{
return rsnr;
Expand Down
2 changes: 2 additions & 0 deletions src/main/rx/rx.h
Expand Up @@ -208,7 +208,9 @@ void setRssiDbmDirect(int16_t newRssiDbm, rssiSource_e source);
#endif //USE_RX_RSSI_DBM

#ifdef USE_RX_RSNR
int8_t getActiveAntenna(void);
int16_t getRsnr(void);
void setActiveAntenna(int8_t antenna);
void setRsnr(int16_t newRsnr);
void setRsnrDirect(int16_t newRsnr);
#endif //USE_RX_RSNR
Expand Down

0 comments on commit c90e05f

Please sign in to comment.