From 268c4dece3eb5ffcc7bd47ebe05d81fe8089ff29 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Sat, 9 Dec 2023 15:40:38 +0100 Subject: [PATCH] S0 and S9 value settings #174 --- settings.c | 17 +++++++++++++---- settings.h | 4 ++++ ui/main.c | 10 +++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/settings.c b/settings.c index d98171015..b75d0451e 100644 --- a/settings.c +++ b/settings.c @@ -132,9 +132,13 @@ void SETTINGS_InitEEPROM(void) memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4); // 0EA0..0EA7 - #ifdef ENABLE_VOICE - EEPROM_ReadBuffer(0x0EA0, Data, 8); - gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH; + EEPROM_ReadBuffer(0x0EA0, Data, 8); + #ifdef ENABLE_VOICE + gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH; + #endif + #ifdef ENABLE_RSSI_BAR + gEeprom.S0_LEVEL = (Data[1] < 0xFF) ? Data[1] : 130; + gEeprom.S9_LEVEL = (Data[2] < gEeprom.S0_LEVEL-9) ? Data[2] : 76; #endif // 0EA8..0EAF @@ -524,8 +528,13 @@ void SETTINGS_SaveSettings(void) memset(State, 0xFF, sizeof(State)); #ifdef ENABLE_VOICE State[0] = gEeprom.VOICE_PROMPT; - EEPROM_WriteBuffer(0x0EA0, State); #endif +#ifdef ENABLE_RSSI_BAR + State[1] = gEeprom.S0_LEVEL; + State[2] = gEeprom.S9_LEVEL; +#endif + EEPROM_WriteBuffer(0x0EA0, State); + #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) State[0] = gEeprom.ALARM_MODE; diff --git a/settings.h b/settings.h index d9e078713..4b27f605e 100644 --- a/settings.h +++ b/settings.h @@ -247,6 +247,10 @@ typedef struct { #endif uint8_t BACKLIGHT_MAX; BATTERY_Type_t BATTERY_TYPE; +#ifdef ENABLE_RSSI_BAR + uint8_t S0_LEVEL; + uint8_t S9_LEVEL; +#endif } EEPROM_Config_t; extern EEPROM_Config_t gEeprom; diff --git a/ui/main.c b/ui/main.c index c2daa063f..7633f6883 100644 --- a/ui/main.c +++ b/ui/main.c @@ -198,17 +198,17 @@ void DisplayRSSIBar(const bool now) memset(p_line, 0, LCD_WIDTH); - const int16_t s0_dBm = -130; // S0 .. base level - const int16_t rssi_dBm = + const int16_t s0_dBm = -gEeprom.S0_LEVEL; // S0 .. base level + const int16_t rssi_dBm = BK4819_GetRSSI_dBm() #ifdef ENABLE_AM_FIX + ((gSetting_AM_fix && gRxVfo->Modulation == MODULATION_AM) ? AM_fix_get_gain_diff() : 0) #endif + dBmCorrTable[gRxVfo->Band]; - - 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); + int s0_9 = gEeprom.S0_LEVEL - gEeprom.S9_LEVEL; + const uint8_t s_level = MIN(MAX((int32_t)(rssi_dBm - s0_dBm)*100 / (s0_9*100/9), 0), 9); // S0 - S9 + uint8_t overS9dBm = MIN(MAX(rssi_dBm + gEeprom.S9_LEVEL, 0), 99); uint8_t overS9Bars = MIN(overS9dBm/10, 4); if(overS9Bars == 0) {