mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
add crsf rf_mode parameter to osd display
make osdRFmode = 0 default changes as requested fixed formatting and unittests remove 3.41 scaling on crsf LQ and simply osd drawing function Update rx.c changed loop to only go to 99 instead of 300
This commit is contained in:
parent
46b7a8586b
commit
925101cdb2
5 changed files with 34 additions and 20 deletions
|
@ -945,9 +945,10 @@ static void osdBackgroundHorizonSidebars(osdElementParms_t *element)
|
|||
static void osdElementLinkQuality(osdElementParms_t *element)
|
||||
{
|
||||
uint16_t osdLinkQuality = 0;
|
||||
if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) { // 0-300
|
||||
osdLinkQuality = rxGetLinkQuality() / 3.41;
|
||||
tfp_sprintf(element->buff, "%c%3d", SYM_LINK_QUALITY, osdLinkQuality);
|
||||
if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) { // 0-99
|
||||
osdLinkQuality = rxGetLinkQuality();
|
||||
const uint8_t osdRfMode = rxGetRfMode();
|
||||
tfp_sprintf(element->buff, "%c%1d:%2d", SYM_LINK_QUALITY, osdRfMode, osdLinkQuality);
|
||||
} else { // 0-9
|
||||
osdLinkQuality = rxGetLinkQuality() * 10 / LINK_QUALITY_MAX_VALUE;
|
||||
if (osdLinkQuality >= 10) {
|
||||
|
|
|
@ -152,11 +152,6 @@ typedef struct crsfPayloadLinkstatistics_s {
|
|||
|
||||
static timeUs_t lastLinkStatisticsFrameUs;
|
||||
|
||||
#ifdef USE_RX_LINK_QUALITY_INFO
|
||||
STATIC_UNIT_TESTED uint16_t scaleCrsfLq(uint16_t lqvalue) {
|
||||
return (lqvalue % 100) ? ((lqvalue * 3.41) + 1) : (lqvalue * 3.41);
|
||||
}
|
||||
#endif
|
||||
static void handleCrsfLinkStatisticsFrame(const crsfLinkStatistics_t* statsPtr, timeUs_t currentTimeUs)
|
||||
{
|
||||
const crsfLinkStatistics_t stats = *statsPtr;
|
||||
|
@ -172,7 +167,8 @@ static void handleCrsfLinkStatisticsFrame(const crsfLinkStatistics_t* statsPtr,
|
|||
|
||||
#ifdef USE_RX_LINK_QUALITY_INFO
|
||||
if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) {
|
||||
setLinkQualityDirect(scaleCrsfLq((stats.rf_Mode * 100) + stats.uplink_Link_quality));
|
||||
setLinkQualityDirect(stats.uplink_Link_quality);
|
||||
rxSetRfMode(stats.rf_Mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -211,6 +207,7 @@ static void crsfCheckRssi(uint32_t currentTimeUs) {
|
|||
#ifdef USE_RX_LINK_QUALITY_INFO
|
||||
if (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) {
|
||||
setLinkQualityDirect(0);
|
||||
rxSetRfMode(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ static pt1Filter_t frameErrFilter;
|
|||
|
||||
#ifdef USE_RX_LINK_QUALITY_INFO
|
||||
static uint16_t linkQuality = 0;
|
||||
static uint8_t rfMode = 0;
|
||||
#endif
|
||||
|
||||
#define MSP_RSSI_TIMEOUT_US 1500000 // 1.5 sec
|
||||
|
@ -403,6 +404,11 @@ STATIC_UNIT_TESTED uint16_t updateLinkQualitySamples(uint16_t value)
|
|||
sampleIndex = (sampleIndex + 1) % LINK_QUALITY_SAMPLE_COUNT;
|
||||
return sum / LINK_QUALITY_SAMPLE_COUNT;
|
||||
}
|
||||
|
||||
void rxSetRfMode(uint8_t rfModeValue)
|
||||
{
|
||||
rfMode = rfModeValue;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void setLinkQuality(bool validFrame, timeDelta_t currentDeltaTime)
|
||||
|
@ -846,9 +852,14 @@ uint16_t rxGetLinkQuality(void)
|
|||
return linkQuality;
|
||||
}
|
||||
|
||||
uint8_t rxGetRfMode(void)
|
||||
{
|
||||
return rfMode;
|
||||
}
|
||||
|
||||
uint16_t rxGetLinkQualityPercent(void)
|
||||
{
|
||||
return (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) ? (linkQuality / 3.41) : scaleRange(linkQuality, 0, LINK_QUALITY_MAX_VALUE, 0, 100);
|
||||
return (linkQualitySource == LQ_SOURCE_RX_PROTOCOL_CRSF) ? linkQuality : scaleRange(linkQuality, 0, LINK_QUALITY_MAX_VALUE, 0, 100);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -200,6 +200,9 @@ uint8_t getRssiDbm(void);
|
|||
void setRssiDbm(uint8_t newRssiDbm, rssiSource_e source);
|
||||
void setRssiDbmDirect(uint8_t newRssiDbm, rssiSource_e source);
|
||||
|
||||
void rxSetRfMode(uint8_t rfModeValue);
|
||||
uint8_t rxGetRfMode(void);
|
||||
|
||||
void resetAllRxChannelRangeConfigurations(rxChannelRangeConfig_t *rxChannelRangeConfig);
|
||||
|
||||
void suspendRxPwmPpmSignal(void);
|
||||
|
|
|
@ -89,7 +89,6 @@ extern "C" {
|
|||
|
||||
void osdRefresh(timeUs_t currentTimeUs);
|
||||
uint16_t updateLinkQualitySamples(uint16_t value);
|
||||
uint16_t scaleCrsfLq(uint16_t lqvalue);
|
||||
#define LINK_QUALITY_SAMPLE_COUNT 16
|
||||
}
|
||||
|
||||
|
@ -311,16 +310,19 @@ TEST(LQTest, TestElementLQ_PROTOCOL_CRSF_VALUES)
|
|||
|
||||
// crsf setLinkQualityDirect 0-300;
|
||||
|
||||
for (uint16_t x = 0; x <= 300; x++) {
|
||||
// when x scaled
|
||||
setLinkQualityDirect(scaleCrsfLq(x));
|
||||
// then rxGetLinkQuality Osd should be x
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
displayPortTestBufferSubstring(8, 1,"%c%3d", SYM_LINK_QUALITY, x);
|
||||
|
||||
for (uint8_t x = 0; x <= 99; x++) {
|
||||
for (uint8_t m = 0; m <= 4; m++) {
|
||||
// when x scaled
|
||||
setLinkQualityDirect(x);
|
||||
rxSetRfMode(m);
|
||||
// then rxGetLinkQuality Osd should be x
|
||||
// and RfMode should be m
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
displayPortTestBufferSubstring(8, 1, "%c%1d:%2d", SYM_LINK_QUALITY, m, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Tests the LQ Alarms
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue