fix: RX stat labelling dependent on telemetry protocol (#3523)

* RX stat (formerly known as "RSSI") labeling dependent on protocol (RSSI/dbm, Rqly/%, Sgnl/-)  used for range check, multi rf tuning and low/critical warning settings pages

* chore: Bump libopenui

* removed define that was supposed to be for testing only

function getRxStatLabels(): wasting flash as inline, no need to be inlined

* removed inline on getRxStatLabels() - step 2
This commit is contained in:
Michael
2023-05-17 11:17:35 +10:00
committed by GitHub
parent 5db37e2a2b
commit fd7d359695
11 changed files with 89 additions and 26 deletions
+56
View File
@@ -72,6 +72,8 @@ static uint8_t intTelemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
static uint8_t intTelemetryRxBufferCount;
#endif
static rxStatStruct rxStat;
uint8_t * getTelemetryRxBuffer(uint8_t moduleIdx)
{
#if defined(INTERNAL_MODULE_SERIAL_TELEMETRY)
@@ -90,6 +92,60 @@ uint8_t &getTelemetryRxBufferCount(uint8_t moduleIdx)
return telemetryRxBufferCount;
}
rxStatStruct *getRxStatLabels() {
// default to RSSI/db notation
rxStat.label = STR_RXSTAT_LABEL_RSSI;
rxStat.unit = STR_RXSTAT_UNIT_DBM;
// Currently we can only display a single rx stat in settings/telemetry.
// If both modules are used we choose the internal one
// TODO: have to rx stat sections in settings/telemetry
uint8_t moduleToUse = INTERNAL_MODULE;
if(g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_NONE &&
g_model.moduleData[EXTERNAL_MODULE].type != MODULE_TYPE_NONE) {
moduleToUse = EXTERNAL_MODULE;
}
uint8_t moduleType = g_model.moduleData[moduleToUse].type;
switch(moduleType) {
case MODULE_TYPE_MULTIMODULE: {
uint8_t multiProtocol = g_model.moduleData[moduleToUse].multi.rfProtocol;
if (multiProtocol == MODULE_SUBTYPE_MULTI_FS_AFHDS2A ||
multiProtocol == MODULE_SUBTYPE_MULTI_HOTT ||
multiProtocol == MODULE_SUBTYPE_MULTI_MLINK) {
rxStat.label = STR_RXSTAT_LABEL_RQLY;
rxStat.unit = STR_RXSTAT_UNIT_PERCENT;
}
}
break;
case MODULE_TYPE_CROSSFIRE:
case MODULE_TYPE_GHOST:
rxStat.label = STR_RXSTAT_LABEL_RQLY;
rxStat.unit = STR_RXSTAT_UNIT_PERCENT;
break;
case MODULE_TYPE_FLYSKY:
#if defined (PCBNV14)
extern uint32_t NV14internalModuleFwVersion;
if(moduleToUse == INTERNAL_MODULE) {
if(g_model.moduleData[INTERNAL_MODULE].subType == FLYSKY_SUBTYPE_AFHDS2A &&
NV14internalModuleFwVersion >= 0x1000E) {
rxStat.label = STR_RXSTAT_LABEL_SIGNAL;
rxStat.unit = STR_RXSTAT_UNIT_NOUNIT ;
}
}
#endif
break;
}
return &rxStat;
}
// TODO: move to module port driver
//
// static int (*_telemetryGetByte)(void*, uint8_t*) = nullptr;
+6 -4
View File
@@ -126,10 +126,12 @@ void frskyDSetDefault(int index, uint16_t id);
#define IS_DISTANCE_UNIT(unit) ((unit) == UNIT_METERS || (unit) == UNIT_FEET)
#define IS_SPEED_UNIT(unit) ((unit) >= UNIT_KTS && (unit) <= UNIT_MPH)
inline const char* getRssiLabel()
{
return "Rx-Stats";
}
typedef struct {
const char *label;
const char *unit;
} rxStatStruct;
rxStatStruct *getRxStatLabels();
// TODO: this should handle only the external S.PORT line
// - and go away in the end: one proto per module, not global!