Skip to content

Commit 268c4de

Browse files
committed
S0 and S9 value settings #174
1 parent 0c2fc61 commit 268c4de

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

settings.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,13 @@ void SETTINGS_InitEEPROM(void)
132132
memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4);
133133

134134
// 0EA0..0EA7
135-
#ifdef ENABLE_VOICE
136-
EEPROM_ReadBuffer(0x0EA0, Data, 8);
137-
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
135+
EEPROM_ReadBuffer(0x0EA0, Data, 8);
136+
#ifdef ENABLE_VOICE
137+
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
138+
#endif
139+
#ifdef ENABLE_RSSI_BAR
140+
gEeprom.S0_LEVEL = (Data[1] < 0xFF) ? Data[1] : 130;
141+
gEeprom.S9_LEVEL = (Data[2] < gEeprom.S0_LEVEL-9) ? Data[2] : 76;
138142
#endif
139143

140144
// 0EA8..0EAF
@@ -524,8 +528,13 @@ void SETTINGS_SaveSettings(void)
524528
memset(State, 0xFF, sizeof(State));
525529
#ifdef ENABLE_VOICE
526530
State[0] = gEeprom.VOICE_PROMPT;
527-
EEPROM_WriteBuffer(0x0EA0, State);
528531
#endif
532+
#ifdef ENABLE_RSSI_BAR
533+
State[1] = gEeprom.S0_LEVEL;
534+
State[2] = gEeprom.S9_LEVEL;
535+
#endif
536+
EEPROM_WriteBuffer(0x0EA0, State);
537+
529538

530539
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
531540
State[0] = gEeprom.ALARM_MODE;

settings.h

+4
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ typedef struct {
247247
#endif
248248
uint8_t BACKLIGHT_MAX;
249249
BATTERY_Type_t BATTERY_TYPE;
250+
#ifdef ENABLE_RSSI_BAR
251+
uint8_t S0_LEVEL;
252+
uint8_t S9_LEVEL;
253+
#endif
250254
} EEPROM_Config_t;
251255

252256
extern EEPROM_Config_t gEeprom;

ui/main.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,17 @@ void DisplayRSSIBar(const bool now)
198198
memset(p_line, 0, LCD_WIDTH);
199199

200200

201-
const int16_t s0_dBm = -130; // S0 .. base level
202-
const int16_t rssi_dBm =
201+
const int16_t s0_dBm = -gEeprom.S0_LEVEL; // S0 .. base level
202+
const int16_t rssi_dBm =
203203
BK4819_GetRSSI_dBm()
204204
#ifdef ENABLE_AM_FIX
205205
+ ((gSetting_AM_fix && gRxVfo->Modulation == MODULATION_AM) ? AM_fix_get_gain_diff() : 0)
206206
#endif
207207
+ dBmCorrTable[gRxVfo->Band];
208208

209-
210-
const uint8_t s_level = MIN(MAX((rssi_dBm - s0_dBm) / 6, 0), 9); // S0 - S9
211-
uint8_t overS9dBm = MIN(MAX(rssi_dBm - (s0_dBm + 9*6), 0), 99);
209+
int s0_9 = gEeprom.S0_LEVEL - gEeprom.S9_LEVEL;
210+
const uint8_t s_level = MIN(MAX((int32_t)(rssi_dBm - s0_dBm)*100 / (s0_9*100/9), 0), 9); // S0 - S9
211+
uint8_t overS9dBm = MIN(MAX(rssi_dBm + gEeprom.S9_LEVEL, 0), 99);
212212
uint8_t overS9Bars = MIN(overS9dBm/10, 4);
213213

214214
if(overS9Bars == 0) {

0 commit comments

Comments
 (0)