Skip to content

Commit

Permalink
S0 and S9 value settings #174
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Dec 12, 2023
1 parent 0c2fc61 commit 268c4de
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
17 changes: 13 additions & 4 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 268c4de

Please sign in to comment.