Skip to content

Commit e0270d5

Browse files
CRSF LQ OSD Style options (#378)
* PR round 2! * Update osd.c adjusting lq default to 70 apparently it doesnt auto adjust defaults with a condition * fixed osd blink minor issue renamed crsf Noise level -> crsf rssi . thanks to OptimusTi of Inav appreciate it. * this works! adding LQ format switching option * TABLE ??? * something. * Update osd.c * Revert "Update osd.c" This reverts commit 96bbfd6. * Revert "something." This reverts commit 9428cda. * Revert "TABLE ???" This reverts commit 99928b3. * this should fix (i think) * how's this look hey quick check this one * damn weird table * LQ format Table Co-authored-by: Quick-Flash <46289813+Quick-Flash@users.noreply.github.com>
1 parent b0d87f4 commit e0270d5

8 files changed

Lines changed: 123 additions & 45 deletions

File tree

src/main/cms/cms_menu_osd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ static long menuOsdActiveElemsOnExit(const OSD_Entry *self)
6262
OSD_Entry menuOsdActiveElemsEntries[] =
6363
{
6464
{"--- ACTIV ELEM ---", OME_Label, NULL, NULL, 0},
65-
{"RSSI", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_RSSI_VALUE], 0},
65+
{"RSSI / LQ", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_RSSI_VALUE], 0},
66+
{"CRSF TX POWER", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_CRSF_TX], 0},
67+
{"CRSF SNR", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_CRSF_SNR], 0},
68+
{"CRSF RSSI", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_CRSF_RSSI], 0},
6669
{"BATTERY VOLTAGE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_MAIN_BATT_VOLTAGE], 0},
6770
{"BATTERY USAGE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_MAIN_BATT_USAGE], 0},
6871
{"AVG CELL VOLTAGE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_AVG_CELL_VOLTAGE], 0},

src/main/interface/settings.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ static const char * const lookupTableUnit[] = {
146146
"IMPERIAL", "METRIC"
147147
};
148148

149+
static const char * const lookupTableCrsfformat[] = {
150+
"TBS", "MODE", "FREQ"
151+
};
152+
149153
static const char * const lookupTableAlignment[] = {
150154
"DEFAULT",
151155
"CW0",
@@ -372,6 +376,7 @@ static const char * const lookupTableRcSmoothingDerivativeType[] = {
372376
const lookupTableEntry_t lookupTables[] = {
373377
LOOKUP_TABLE_ENTRY(lookupTableOffOn),
374378
LOOKUP_TABLE_ENTRY(lookupTableUnit),
379+
LOOKUP_TABLE_ENTRY(lookupTableCrsfformat),
375380
LOOKUP_TABLE_ENTRY(lookupTableAlignment),
376381
#ifdef USE_GPS
377382
LOOKUP_TABLE_ENTRY(lookupTableGPSProvider),
@@ -963,6 +968,7 @@ const clivalue_t valueTable[] = {
963968
#endif
964969
{ "osd_warn_rc_smoothing", VAR_UINT16 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_WARNING_RC_SMOOTHING, PG_OSD_CONFIG, offsetof(osdConfig_t, enabledWarnings)},
965970
{ "osd_warn_dji", VAR_UINT16 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_WARNING_DJI, PG_OSD_CONFIG, offsetof(osdConfig_t, enabledWarnings)},
971+
{ "osd_lq_format", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_CRSFFORMAT }, PG_OSD_CONFIG, offsetof(osdConfig_t, lq_format) },
966972
{ "osd_lq_alarm", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 300 }, PG_OSD_CONFIG, offsetof(osdConfig_t, lq_alarm) },
967973
{ "osd_rssi_alarm", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_OSD_CONFIG, offsetof(osdConfig_t, rssi_alarm) },
968974
{ "osd_cap_alarm", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 20000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, cap_alarm) },
@@ -983,6 +989,9 @@ const clivalue_t valueTable[] = {
983989

984990
{ "osd_vbat_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_MAIN_BATT_VOLTAGE]) },
985991
{ "osd_rssi_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_RSSI_VALUE]) },
992+
{ "osd_crsf_tx_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CRSF_TX]) },
993+
{ "osd_crsf_snr_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CRSF_SNR]) },
994+
{ "osd_crsf_rssi_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CRSF_RSSI]) },
986995
{ "osd_tim_1_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ITEM_TIMER_1]) },
987996
{ "osd_tim_2_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ITEM_TIMER_2]) },
988997
{ "osd_remaining_time_estimate_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_REMAINING_TIME_ESTIMATE]) },

src/main/interface/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
typedef enum {
2929
TABLE_OFF_ON = 0,
3030
TABLE_UNIT,
31+
TABLE_CRSFFORMAT,
3132
TABLE_ALIGNMENT,
3233
#ifdef USE_GPS
3334
TABLE_GPS_PROVIDER,

src/main/io/osd.c

Lines changed: 69 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ char djiWarningBuffer[12];
150150

151151
static uint8_t armState;
152152
static bool lastArmState;
153+
static uint16_t osdLQfinal;
153154

154155
static displayPort_t *osdDisplayPort;
155156

@@ -179,6 +180,9 @@ static const char compassBar[] = {
179180
static const uint8_t osdElementDisplayOrder[] = {
180181
OSD_MAIN_BATT_VOLTAGE,
181182
OSD_RSSI_VALUE,
183+
OSD_CRSF_TX,
184+
OSD_CRSF_SNR,
185+
OSD_CRSF_RSSI,
182186
OSD_CROSSHAIRS,
183187
OSD_HORIZON_SIDEBARS,
184188
OSD_ITEM_TIMER_1,
@@ -488,32 +492,60 @@ static bool osdDrawSingleElement(uint8_t item)
488492
char buff[OSD_ELEMENT_BUFFER_LENGTH] = "";
489493

490494
switch (item) {
491-
case OSD_RSSI_VALUE:
495+
case OSD_RSSI_VALUE: //standard RSSI and CRSF LQ
492496
{
493497
if(crsfRssi)
494498
{
495499
uint16_t osdLQ = CRSFgetLQ();
496500
uint8_t osdRfMode = CRSFgetRFMode();
497-
uint16_t osdLQfinal = 0;
498-
switch (osdRfMode)
501+
osdLQfinal = osdLQ;
502+
switch (osdConfig()->lq_format)
499503
{
500-
case 0:
501-
osdLQfinal = osdLQ;
502-
break;
503-
case 1:
504-
osdLQfinal = osdLQ + 100;
504+
505+
case TBS:
506+
507+
switch (osdRfMode)
508+
{
509+
case 2:
510+
osdLQfinal = osdLQ * 3;
511+
if (osdLQfinal<200)
512+
osdLQfinal=200;
505513
break;
506-
case 2:
507-
osdLQfinal = osdLQ + 200;
514+
default:
515+
osdLQfinal = osdLQ;
508516
break;
509-
}
517+
}
518+
if (osdLQfinal >= 300)
519+
osdLQfinal = 300;
510520

511-
if (osdLQfinal >= 300)
512-
osdLQfinal = 300;
521+
tfp_sprintf(buff, "%c%3d", LINK_QUALITY, osdLQfinal);
522+
break;
513523

514-
tfp_sprintf(buff, "%c%3d", LINK_QUALITY, osdLQfinal);
524+
525+
case MODE:
526+
if (osdLQ >=100)
527+
osdLQfinal = 100;
528+
tfp_sprintf(buff, "%1d:%d", osdRfMode, osdLQfinal);
529+
break;
530+
531+
case FREQ:
532+
switch(osdRfMode)
533+
{
534+
case 0:
535+
osdRfMode = 4;
536+
break;
537+
case 1:
538+
osdRfMode = 50;
539+
break;
540+
case 2:
541+
osdRfMode = 150;
542+
break;
543+
}
544+
tfp_sprintf(buff, "%3dHZ:%d", osdRfMode, osdLQfinal);
545+
break;
515546

516547

548+
}
517549
}
518550
else
519551
{
@@ -525,16 +557,18 @@ static bool osdDrawSingleElement(uint8_t item)
525557
}
526558
break;
527559
}
528-
/*
529-
case OSD_CRSF_SNR:
560+
561+
case OSD_CRSF_SNR: //crsf signal to noise ratio
530562
{
531563
if(crsfRssi)
532564
{
533-
uint16_t osdSNR = CRSFgetSnR();
534-
tfp_sprintf(buff, "%c%3d.%02d" , SYM_BLANK, osdSNR );
565+
uint8_t osdSNR = CRSFgetSnR();
566+
tfp_sprintf(buff, "SN %2dDB", osdSNR );
535567
}
568+
break;
536569
}
537-
case OSD_CRSF_TX_POWER:
570+
571+
case OSD_CRSF_TX: //crsf tx output power
538572
{
539573
if(crsfRssi)
540574
{
@@ -569,10 +603,18 @@ static bool osdDrawSingleElement(uint8_t item)
569603
osdtxpower = 0;
570604
break;
571605
}
572-
tfp_sprintf(buff, "%c%4d" , SYM_BLANK, osdtxpower );
606+
tfp_sprintf(buff, "%dMW", osdtxpower );
573607
}
608+
break;
609+
}
610+
611+
case OSD_CRSF_RSSI: //crsf rssi
612+
{
613+
uint8_t osdcrsfrssi = CRSFgetRSSI();
614+
tfp_sprintf(buff, "-%2dDBM" , osdcrsfrssi );
615+
break;
574616
}
575-
*/
617+
576618
case OSD_MAIN_BATT_VOLTAGE:
577619
buff[0] = osdGetBatterySymbol(osdGetBatteryAverageCellVoltage());
578620
tfp_sprintf(buff + 1, "%2d.%1d%c", getBatteryVoltage() / 10, getBatteryVoltage() % 10, SYM_VOLT);
@@ -1208,8 +1250,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
12081250

12091251
osdConfig->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_ON, OSD_TIMER_PREC_SECOND, 10);
12101252
osdConfig->timers[OSD_TIMER_2] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_SECOND, 10);
1211-
1212-
osdConfig->lq_alarm = 170;
1253+
osdConfig->lq_format = TBS;
1254+
osdConfig->lq_alarm = 70;
12131255
osdConfig->rssi_alarm = 20;
12141256
osdConfig->cap_alarm = 2200;
12151257
osdConfig->alt_alarm = 100; // meters or feet depend on configuration
@@ -1291,24 +1333,10 @@ void osdUpdateAlarms(void)
12911333
int32_t alt = osdGetMetersToSelectedUnit(getEstimatedAltitude()) / 100;
12921334
if(crsfRssi)
12931335
{
1294-
uint16_t osdLQ = CRSFgetLQ();
1295-
uint8_t osdRfMode = CRSFgetRFMode();
1296-
uint16_t osdLQfinal = 0;
1297-
switch (osdRfMode)
1298-
{
1299-
case 0:
1300-
osdLQfinal = osdLQ;
1301-
break;
1302-
case 1:
1303-
osdLQfinal = osdLQ + 100;
1304-
break;
1305-
case 2:
1306-
osdLQfinal = osdLQ + 200;
1307-
break;
1308-
}
1309-
1310-
if (osdLQfinal <= osdConfig()->lq_alarm) //CRSF RSSI_alarm = set to 170 (Mode1 : 60)
1311-
SET_BLINK(OSD_RSSI_VALUE);
1336+
if (osdLQfinal < osdConfig()->lq_alarm) //CRSF RSSI_alarm = set to 170 (Mode1 : 60)
1337+
{
1338+
SET_BLINK(OSD_RSSI_VALUE);
1339+
}
13121340
else
13131341
CLR_BLINK(OSD_RSSI_VALUE);
13141342

src/main/io/osd.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,19 @@ typedef enum {
9595
OSD_ADJUSTMENT_RANGE,
9696
OSD_CORE_TEMPERATURE,
9797
OSD_G_FORCE,
98+
OSD_CRSF_SNR,
99+
OSD_CRSF_TX,
100+
OSD_CRSF_RSSI,
101+
98102
OSD_ITEM_COUNT // MUST BE LAST
99103
} osd_items_e;
100104

105+
typedef enum {
106+
TBS,
107+
MODE,
108+
FREQ
109+
} crsfformat_e;
110+
101111
// *** IMPORTANT ***
102112
// The order of the OSD stats enumeration *must* match the order they're displayed on-screen
103113
// This is because the fields are presented in the configurator in the order of the enumeration
@@ -166,6 +176,7 @@ typedef enum {
166176
OSD_WARNING_COUNT // MUST BE LAST
167177
} osdWarningsFlags_e;
168178

179+
169180
// Make sure the number of warnings do not exceed the available 16bit storage
170181
STATIC_ASSERT(OSD_WARNING_COUNT <= 16, osdwarnings_overflow);
171182

@@ -182,7 +193,9 @@ typedef struct osdConfig_s {
182193
uint16_t lq_alarm;
183194
uint8_t rssi_alarm;
184195
uint16_t distance_alarm;
196+
185197
osd_unit_e units;
198+
186199
uint16_t timers[OSD_TIMER_COUNT];
187200
uint16_t enabledWarnings;
188201

@@ -193,6 +206,8 @@ typedef struct osdConfig_s {
193206
int16_t esc_rpm_alarm;
194207
int16_t esc_current_alarm;
195208
uint8_t core_temp_alarm;
209+
210+
crsfformat_e lq_format;
196211
} osdConfig_t;
197212

198213
PG_DECLARE(osdConfig_t, osdConfig);

src/main/rx/crsf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,18 @@ static void handleCrsfLinkStatisticsFrame(const crsfLinkStatistics_t* statsPtr,
135135
CRSFsetRFMode(stats.rf_Mode);
136136
CRSFsetSnR(stats.downlink_SNR);
137137
CRSFsetTXPower(stats.uplink_TX_Power);
138+
if(stats.uplink_RSSI_1 == 0)
139+
CRSFsetRSSI(stats.uplink_RSSI_2);
140+
else if(stats.uplink_RSSI_2 == 0)
141+
CRSFsetRSSI(stats.uplink_RSSI_1);
142+
else
143+
{
144+
uint8_t rssimin=MIN(stats.uplink_RSSI_1, stats.uplink_RSSI_2) *-1;
145+
CRSFsetRSSI(rssimin);
146+
}
138147
}
139148

149+
140150
STATIC_UNIT_TESTED uint8_t crsfFrameCRC(void)
141151
{
142152
// CRC includes type and payload

src/main/rx/rx.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static uint16_t crsflq = 0;
7878
static uint8_t crsfrfmode = 0;
7979
static uint16_t crsfsnr = 0;
8080
static uint16_t crsftxpower = 0;
81+
static uint16_t crsfrssi = 0;
8182

8283
#define MSP_RSSI_TIMEOUT_US 1500000 // 1.5 sec
8384

@@ -715,14 +716,23 @@ void CRSFsetRFMode(uint8_t crsfrfValue)
715716

716717
void CRSFsetTXPower(uint16_t crsftxpValue)
717718
{
718-
crsftxpower=crsftxpValue;
719+
crsftxpower = crsftxpValue;
719720
}
720721

721722
void CRSFsetSnR(uint16_t crsfsnrValue)
722723
{
723724
crsfsnr = crsfsnrValue;
724725
}
725726

727+
void CRSFsetRSSI(uint8_t crsfrssiValue)
728+
{
729+
crsfrssi = crsfrssiValue;
730+
}
731+
732+
uint8_t CRSFgetRSSI(void)
733+
{
734+
return crsfrssi;
735+
}
726736
uint16_t CRSFgetLQ(void)
727737
{
728738
return crsflq;
@@ -733,7 +743,7 @@ uint8_t CRSFgetRFMode(void)
733743
return crsfrfmode;
734744
}
735745

736-
uint16_t CRSFgetSnR(void)
746+
uint8_t CRSFgetSnR(void)
737747
{
738748
return crsfsnr;
739749
}

src/main/rx/rx.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ void resumeRxPwmPpmSignal(void);
176176
//set and get CRSF stats
177177
void CRSFsetLQ(uint16_t crsflqValue);
178178
void CRSFsetSnR(uint16_t crsfsnrValue);
179+
void CRSFsetRSSI(uint8_t crsfrssiValue);
179180
void CRSFsetRFMode(uint8_t crsfrfValue);
180181
void CRSFsetTXPower(uint16_t crsftxpValue);
182+
uint8_t CRSFgetRSSI(void);
181183
uint16_t CRSFgetLQ(void);
182184
uint8_t CRSFgetRFMode(void);
183-
uint16_t CRSFgetSnR(void);
185+
uint8_t CRSFgetSnR(void);
184186
uint16_t CRSFgetTXPower(void);
185187

186188
uint16_t rxGetRefreshRate(void);

0 commit comments

Comments
 (0)