From e0178c4805683efad995c88e77c573a64eb47ba0 Mon Sep 17 00:00:00 2001 From: Nunu Date: Sat, 30 Dec 2023 19:21:12 +0100 Subject: [PATCH] Fix S-meter for UHF/VHF bands. --- frequencies.h | 3 +++ ui/main.c | 17 ++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/frequencies.h b/frequencies.h index 25d28f4..1044c2e 100644 --- a/frequencies.h +++ b/frequencies.h @@ -29,6 +29,9 @@ extern const freq_band_table_t BX4819_band2; extern const freq_band_table_t frequencyBandTable[7]; +// 30Mhz defines start of HF band +#define HF_FREQUENCY 3000000 + typedef enum { BAND_NONE = -1, BAND1_50MHz = 0, diff --git a/ui/main.c b/ui/main.c index 4ba683b..ca4a851 100644 --- a/ui/main.c +++ b/ui/main.c @@ -176,18 +176,13 @@ static void DisplayRSSIBar(const int16_t rssi, const bool now) if (now) memset(p_line, 0, LCD_WIDTH); - const int8_t dBmCorrTable[7] = { - -15, // band 1 - -25, // band 2 - -20, // band 3 - -4, // band 4 - -7, // band 5 - -6, // band 6 - -1 // band 7 - }; + int16_t s0_dBm = -130; // S0 .. base level - const int16_t s0_dBm = -130; // S0 .. base level - const int16_t rssi_dBm = (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band]; + // adjust S-level for bands above HF + if(gRxVfo->freq_config_RX.Frequency > HF_FREQUENCY) + s0_dBm-=20; + + const int16_t rssi_dBm = (rssi / 2) - 160; const uint8_t s_level = MIN(MAX((rssi_dBm - s0_dBm) / 6, 0), 9); // S0 - S9 uint8_t overS9dBm = MIN(MAX(rssi_dBm - (s0_dBm + 9*6), 0), 99);