Real AM fix attempt, messy
This commit is contained in:
2
Makefile
2
Makefile
@@ -33,7 +33,7 @@ ENABLE_BOOT_BEEPS := 0
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 0
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 0
|
||||
ENABLE_NO_CODE_SCAN_TIMEOUT := 1
|
||||
ENABLE_AM_FIX := 1
|
||||
ENABLE_AM_FIX := 0
|
||||
ENABLE_SQUELCH_MORE_SENSITIVE := 1
|
||||
ENABLE_FASTER_CHANNEL_SCAN := 1
|
||||
ENABLE_RSSI_BAR := 1
|
||||
|
27
am_fix.c
27
am_fix.c
@@ -186,7 +186,7 @@ static const t_gain_table gain_table[] =
|
||||
{0x03FF, 0}, // 91 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB
|
||||
};
|
||||
|
||||
static const unsigned int original_index = 90;
|
||||
static const unsigned int original_index = 85;
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
// display update rate
|
||||
@@ -206,9 +206,6 @@ int16_t prev_rssi[2] = {0, 0};
|
||||
// to help reduce gain hunting, peak hold count down tick
|
||||
unsigned int hold_counter[2] = {0, 0};
|
||||
|
||||
// used to correct the RSSI readings after our RF gain adjustments
|
||||
int16_t rssi_gain_diff[2] = {0, 0};
|
||||
|
||||
// used to limit the max RF gain
|
||||
const unsigned max_index = ARRAY_SIZE(gain_table) - 1;
|
||||
|
||||
@@ -233,7 +230,6 @@ void AM_fix_reset(const unsigned vfo)
|
||||
|
||||
prev_rssi[vfo] = 0;
|
||||
hold_counter[vfo] = 0;
|
||||
rssi_gain_diff[vfo] = 0;
|
||||
gain_table_index_prev[vfo] = 0;
|
||||
}
|
||||
|
||||
@@ -287,9 +283,10 @@ void AM_fix_10ms(const unsigned vfo, bool force)
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
{
|
||||
int16_t new_rssi = rssi - rssi_gain_diff[vfo];
|
||||
if (gCurrentRSSI[vfo] != new_rssi) { // rssi changed
|
||||
gCurrentRSSI[vfo] = new_rssi;
|
||||
static int16_t lastRssi;
|
||||
|
||||
if (lastRssi != rssi) { // rssi changed
|
||||
lastRssi = rssi;
|
||||
|
||||
if (counter == 0) {
|
||||
counter = 1;
|
||||
@@ -353,16 +350,8 @@ void AM_fix_10ms(const unsigned vfo, bool force)
|
||||
gain_table_index_prev[vfo] = index;
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_13, gain_table[index].reg_val);
|
||||
|
||||
// offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we make
|
||||
|
||||
// RF gain difference from original QS setting
|
||||
rssi_gain_diff[vfo] = ((int16_t)gain_table[index].gain_dB - gain_table[original_index].gain_dB) * 2;
|
||||
}
|
||||
|
||||
// save the corrected RSSI level
|
||||
gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo];
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
if (counter == 0) {
|
||||
counter = 1;
|
||||
@@ -381,11 +370,5 @@ void AM_fix_print_data(const unsigned vfo, char *s) {
|
||||
}
|
||||
#endif
|
||||
|
||||
int16_t AM_fix_get_rssi_gain_diff(const unsigned vfo)
|
||||
{
|
||||
if(vfo > 1)
|
||||
return 0;
|
||||
return rssi_gain_diff[vfo];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
1
am_fix.h
1
am_fix.h
@@ -26,7 +26,6 @@
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
void AM_fix_print_data(const unsigned vfo, char *s);
|
||||
#endif
|
||||
int16_t AM_fix_get_rssi_gain_diff(const unsigned vfo);
|
||||
|
||||
#endif
|
||||
|
||||
|
47
app/app.c
47
app/app.c
@@ -63,27 +63,11 @@
|
||||
#include "ui/status.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include "debugging.h"
|
||||
|
||||
static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||
static void FlashlightTimeSlice();
|
||||
|
||||
static void UpdateRSSI(const int vfo)
|
||||
{
|
||||
int16_t rssi = BK4819_GetRSSI();
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
// add RF gain adjust compensation
|
||||
if (gEeprom.VfoInfo[vfo].Modulation == MODULATION_AM && gSetting_AM_fix)
|
||||
rssi -= AM_fix_get_rssi_gain_diff(vfo);
|
||||
#endif
|
||||
|
||||
if (gCurrentRSSI[vfo] == rssi)
|
||||
return; // no change
|
||||
|
||||
gCurrentRSSI[vfo] = rssi;
|
||||
|
||||
UI_UpdateRSSI(rssi, vfo);
|
||||
}
|
||||
|
||||
static void CheckForIncoming(void)
|
||||
{
|
||||
if (!g_SquelchLost)
|
||||
@@ -108,9 +92,6 @@ static void CheckForIncoming(void)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//gUpdateDisplay = true;
|
||||
|
||||
UpdateRSSI(gEeprom.RX_VFO);
|
||||
gUpdateRSSI = true;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -124,9 +105,6 @@ static void CheckForIncoming(void)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//gUpdateDisplay = true;
|
||||
|
||||
UpdateRSSI(gEeprom.RX_VFO);
|
||||
gUpdateRSSI = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -146,9 +124,6 @@ static void CheckForIncoming(void)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//gUpdateDisplay = true;
|
||||
|
||||
UpdateRSSI(gEeprom.RX_VFO);
|
||||
gUpdateRSSI = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -163,9 +138,6 @@ static void CheckForIncoming(void)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//gUpdateDisplay = true;
|
||||
|
||||
UpdateRSSI(gEeprom.RX_VFO);
|
||||
gUpdateRSSI = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,8 +966,6 @@ void APP_Update(void)
|
||||
!gCssBackgroundScan)
|
||||
{ // dual watch mode, toggle between the two VFO's
|
||||
DualwatchAlternate();
|
||||
|
||||
gUpdateRSSI = false;
|
||||
}
|
||||
|
||||
FUNCTION_Init();
|
||||
@@ -1004,11 +974,8 @@ void APP_Update(void)
|
||||
gRxIdleMode = false; // RX is awake
|
||||
}
|
||||
else
|
||||
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssBackgroundScan || gUpdateRSSI)
|
||||
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssBackgroundScan)
|
||||
{ // dual watch mode off or scanning or rssi update request
|
||||
|
||||
UpdateRSSI(gEeprom.RX_VFO);
|
||||
|
||||
// go back to sleep
|
||||
|
||||
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10;
|
||||
@@ -1021,12 +988,9 @@ void APP_Update(void)
|
||||
// Authentic device checked removed
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// toggle between the two VFO's
|
||||
DualwatchAlternate();
|
||||
|
||||
gUpdateRSSI = true;
|
||||
gPowerSave_10ms = power_save1_10ms;
|
||||
}
|
||||
|
||||
@@ -1530,9 +1494,6 @@ void APP_TimeSlice500ms(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (gCurrentFunction != FUNCTION_POWER_SAVE && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
UpdateRSSI(gEeprom.RX_VFO);
|
||||
|
||||
if (!gPttIsPressed && gVFOStateResumeCountdown_500ms > 0)
|
||||
{
|
||||
if (--gVFOStateResumeCountdown_500ms == 0)
|
||||
|
@@ -292,11 +292,7 @@ uint16_t GetRssi() {
|
||||
SYSTICK_DelayUs(100);
|
||||
}
|
||||
|
||||
return BK4819_GetRSSI()
|
||||
#ifdef ENABLE_AM_FIX
|
||||
- ((settings.modulationType == MODULATION_AM) ? AM_fix_get_rssi_gain_diff(vfo) : 0)
|
||||
#endif
|
||||
;
|
||||
return BK4819_GetRSSI();
|
||||
}
|
||||
|
||||
static void ToggleAudio(bool on) {
|
||||
@@ -495,10 +491,14 @@ static void ToggleModulation() {
|
||||
settings.modulationType = MODULATION_FM;
|
||||
}
|
||||
RADIO_SetModulation(settings.modulationType);
|
||||
if(settings.modulationType != MODULATION_AM) {
|
||||
BK4819_InitAGC();
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if(gSetting_AM_fix && settings.modulationType != MODULATION_AM) {
|
||||
BK4819_InitAGC(false);
|
||||
BK4819_SetAGC(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
RelaunchScan();
|
||||
redrawScreen = true;
|
||||
}
|
||||
@@ -1180,8 +1180,8 @@ void APP_RunSpectrum() {
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if(settings.modulationType != MODULATION_AM) {
|
||||
BK4819_InitAGC();
|
||||
BK4819_SetAGC(1);
|
||||
BK4819_InitAGC(false);
|
||||
BK4819_SetAGC(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include "driver/bk4819.h"
|
||||
#include "string.h"
|
||||
#include "external/printf/printf.h"
|
||||
#include "am_fix.h"
|
||||
|
||||
|
||||
static inline void LogUart(char * str)
|
||||
@@ -26,7 +27,8 @@ static inline void LogPrint()
|
||||
uint16_t rssi = BK4819_GetRSSI();
|
||||
uint16_t reg7e = BK4819_ReadRegister(0x7E);
|
||||
char buf[32];
|
||||
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15), (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111, (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
|
||||
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n",
|
||||
(reg7e >> 15), (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111, (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
|
||||
LogUart(buf);
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,7 @@ void BK4819_Init(void)
|
||||
BK4819_WriteRegister(BK4819_REG_37, 0x1D0F);
|
||||
BK4819_WriteRegister(BK4819_REG_36, 0x0022);
|
||||
|
||||
BK4819_InitAGC();
|
||||
BK4819_InitAGC(false);
|
||||
BK4819_SetAGC(true);
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_19, 0b0001000001000001); // <15> MIC AGC 1 = disable 0 = enable
|
||||
@@ -263,7 +263,7 @@ void BK4819_SetAGC(bool enable)
|
||||
// }
|
||||
}
|
||||
|
||||
void BK4819_InitAGC()
|
||||
void BK4819_InitAGC(bool amModulation)
|
||||
{
|
||||
// REG_10, REG_11, REG_12 REG_13, REG_14
|
||||
//
|
||||
@@ -308,13 +308,56 @@ void BK4819_InitAGC()
|
||||
BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 0x037B / 000000 11 011 11 011 / -24dB
|
||||
BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 0x027B / 000000 10 011 11 011 / -43dB
|
||||
BK4819_WriteRegister(BK4819_REG_10, 0x007A); // 0x007A / 000000 00 011 11 010 / -58dB
|
||||
BK4819_WriteRegister(BK4819_REG_14, 0x0019); // 0x0019 / 000000 00 000 11 001 / -79dB
|
||||
BK4819_WriteRegister(BK4819_REG_49, (0 << 14) | (84 << 7) | (56 << 0)); //0x2A38 / 00 1010100 0111000 / 84, 56
|
||||
if(amModulation) {
|
||||
BK4819_WriteRegister(BK4819_REG_14, 0x0000);
|
||||
BK4819_WriteRegister(BK4819_REG_49, (0 << 14) | (50 << 7) | (32 << 0));
|
||||
}
|
||||
else{
|
||||
BK4819_WriteRegister(BK4819_REG_14, 0x0019); // 0x0019 / 000000 00 000 11 001 / -79dB
|
||||
BK4819_WriteRegister(BK4819_REG_49, (0 << 14) | (84 << 7) | (56 << 0)); //0x2A38 / 00 1010100 0111000 / 84, 56
|
||||
}
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_7B, 0x8420);
|
||||
|
||||
}
|
||||
|
||||
int8_t BK4819_GetRxGain_dB(void)
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
uint16_t pga:3;
|
||||
uint16_t mixer:2;
|
||||
uint16_t lna:3;
|
||||
uint16_t lnaS:2;
|
||||
};
|
||||
uint16_t __raw;
|
||||
} agcGainReg;
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint16_t _ : 5;
|
||||
uint16_t agcSigStrength : 7;
|
||||
int16_t gainIdx : 3;
|
||||
uint16_t agcEnab : 1;
|
||||
};
|
||||
uint16_t __raw;
|
||||
} reg7e;
|
||||
|
||||
reg7e.__raw = BK4819_ReadRegister(BK4819_REG_7E);
|
||||
uint8_t gainAddr = reg7e.gainIdx < 0 ? BK4819_REG_14 : BK4819_REG_10 + reg7e.gainIdx;
|
||||
agcGainReg.__raw = BK4819_ReadRegister(gainAddr);
|
||||
int8_t lnaShortTab[] = {-28, -24, -19, 0};
|
||||
int8_t lnaTab[] = {-24, -19, -14, -9, -6, -4, -2, 0};
|
||||
int8_t mixerTab[] = {-8, -6, -3, 0};
|
||||
int8_t pgaTab[] = {-33, -27, -21, -15, -9, -6, -3, 0};
|
||||
return lnaShortTab[agcGainReg.lnaS] + lnaTab[agcGainReg.lna] + mixerTab[agcGainReg.mixer] + pgaTab[agcGainReg.pga];
|
||||
}
|
||||
|
||||
int16_t BK4819_GetRSSI_dBm(void)
|
||||
{
|
||||
uint16_t rssi = BK4819_GetRSSI();
|
||||
return (rssi / 2) - 160;// - BK4819_GetRxGain_dB();
|
||||
}
|
||||
|
||||
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet)
|
||||
{
|
||||
|
@@ -73,7 +73,7 @@ void BK4819_WriteU8(uint8_t Data);
|
||||
void BK4819_WriteU16(uint16_t Data);
|
||||
|
||||
void BK4819_SetAGC(bool enable);
|
||||
void BK4819_InitAGC();
|
||||
void BK4819_InitAGC(bool amModulation);
|
||||
|
||||
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet);
|
||||
|
||||
@@ -136,6 +136,8 @@ void BK4819_EnableCDCSS(void);
|
||||
void BK4819_EnableCTCSS(void);
|
||||
|
||||
uint16_t BK4819_GetRSSI(void);
|
||||
int8_t BK4819_GetRxGain_dB(void);
|
||||
int16_t BK4819_GetRSSI_dBm(void);
|
||||
uint8_t BK4819_GetGlitchIndicator(void);
|
||||
uint8_t BK4819_GetExNoiceIndicator(void);
|
||||
uint16_t BK4819_GetVoiceAmplitudeOut(void);
|
||||
|
3
misc.c
3
misc.c
@@ -160,7 +160,6 @@ bool gCssBackgroundScan;
|
||||
volatile bool gScheduleScanListen = true;
|
||||
volatile uint16_t gScanPauseDelayIn_10ms;
|
||||
|
||||
bool gUpdateRSSI;
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
AlarmState_t gAlarmState;
|
||||
#endif
|
||||
@@ -250,8 +249,6 @@ volatile bool gFlagTailNoteEliminationComplete;
|
||||
|
||||
volatile uint8_t boot_counter_10ms;
|
||||
|
||||
int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
|
||||
|
||||
uint8_t gIsLocked = 0xFF;
|
||||
|
||||
|
||||
|
2
misc.h
2
misc.h
@@ -247,7 +247,6 @@ enum
|
||||
extern volatile bool gScheduleScanListen;
|
||||
extern volatile uint16_t gScanPauseDelayIn_10ms;
|
||||
|
||||
extern bool gUpdateRSSI;
|
||||
extern AlarmState_t gAlarmState;
|
||||
extern uint16_t gMenuCountdown;
|
||||
extern bool gPttWasReleased;
|
||||
@@ -332,7 +331,6 @@ extern volatile uint8_t gVFOStateResumeCountdown_500ms;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern volatile bool gScheduleFM;
|
||||
#endif
|
||||
extern int16_t gCurrentRSSI[2]; // now one per VFO
|
||||
extern uint8_t gIsLocked;
|
||||
extern volatile uint8_t boot_counter_10ms;
|
||||
|
||||
|
14
radio.c
14
radio.c
@@ -772,8 +772,12 @@ void RADIO_SetupRegisters(bool switchToForeground)
|
||||
}
|
||||
#endif
|
||||
|
||||
BK4819_SetAGC(1);
|
||||
BK4819_InitAGC();
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if(gSetting_AM_fix) {
|
||||
BK4819_SetAGC(true);
|
||||
BK4819_InitAGC(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
// enable/disable BK4819 selected interrupts
|
||||
BK4819_WriteRegister(BK4819_REG_3F, InterruptMask);
|
||||
@@ -923,9 +927,11 @@ void RADIO_SetModulation(ModulationMode_t modulation)
|
||||
BK4819_WriteRegister(BK4819_REG_3D, modulation == MODULATION_USB ? 0 : 0x2AAB);
|
||||
BK4819_SetRegValue(afcDisableRegSpec, modulation != MODULATION_FM);
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if(modulation == MODULATION_AM && gSetting_AM_fix)
|
||||
if(modulation == MODULATION_AM && gSetting_AM_fix) {
|
||||
BK4819_SetAGC(0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
BK4819_InitAGC(modulation == MODULATION_AM);
|
||||
}
|
||||
|
||||
void RADIO_SetVfoState(VfoState_t State)
|
||||
|
127
ui/main.c
127
ui/main.c
@@ -37,6 +37,8 @@
|
||||
#include "ui/main.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include "debugging.h"
|
||||
|
||||
center_line_t center_line = CENTER_LINE_NONE;
|
||||
|
||||
const int8_t dBmCorrTable[7] = {
|
||||
@@ -150,64 +152,63 @@ void UI_DisplayAudioBar(void)
|
||||
#endif
|
||||
|
||||
|
||||
static void DisplayRSSIBar(const int16_t rssi, const bool now)
|
||||
void DisplayRSSIBar(const bool now)
|
||||
{
|
||||
#if defined(ENABLE_RSSI_BAR)
|
||||
|
||||
if (center_line == CENTER_LINE_RSSI) {
|
||||
const unsigned int txt_width = 7 * 8; // 8 text chars
|
||||
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
|
||||
const unsigned int txt_width = 7 * 8; // 8 text chars
|
||||
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
|
||||
|
||||
const unsigned int line = 3;
|
||||
uint8_t *p_line = gFrameBuffer[line];
|
||||
char str[16];
|
||||
const unsigned int line = 3;
|
||||
uint8_t *p_line = gFrameBuffer[line];
|
||||
char str[16];
|
||||
|
||||
const char plus[] = {
|
||||
0b00011000,
|
||||
0b00011000,
|
||||
0b01111110,
|
||||
0b01111110,
|
||||
0b01111110,
|
||||
0b00011000,
|
||||
0b00011000,
|
||||
};
|
||||
const char plus[] = {
|
||||
0b00011000,
|
||||
0b00011000,
|
||||
0b01111110,
|
||||
0b01111110,
|
||||
0b01111110,
|
||||
0b00011000,
|
||||
0b00011000,
|
||||
};
|
||||
|
||||
if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
|
||||
return; // display is in use
|
||||
if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
|
||||
return; // display is in use
|
||||
|
||||
if (gCurrentFunction == FUNCTION_TRANSMIT ||
|
||||
gScreenToDisplay != DISPLAY_MAIN
|
||||
if (gCurrentFunction == FUNCTION_TRANSMIT ||
|
||||
gScreenToDisplay != DISPLAY_MAIN
|
||||
#ifdef ENABLE_DTMF_CALLING
|
||||
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
|
||||
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
|
||||
#endif
|
||||
)
|
||||
return; // display is in use
|
||||
)
|
||||
return; // display is in use
|
||||
|
||||
if (now)
|
||||
memset(p_line, 0, LCD_WIDTH);
|
||||
|
||||
if (now)
|
||||
memset(p_line, 0, LCD_WIDTH);
|
||||
|
||||
|
||||
const int16_t s0_dBm = -130; // S0 .. base level
|
||||
const int16_t rssi_dBm = (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band];
|
||||
const int16_t s0_dBm = -130; // S0 .. base level
|
||||
const int16_t rssi_dBm = BK4819_GetRSSI_dBm() + 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);
|
||||
uint8_t overS9Bars = MIN(overS9dBm/10, 4);
|
||||
|
||||
if(overS9Bars == 0) {
|
||||
sprintf(str, "% 4d S%d", rssi_dBm, s_level);
|
||||
}
|
||||
else {
|
||||
sprintf(str, "% 4d %2d", rssi_dBm, overS9dBm);
|
||||
memcpy(p_line + 2 + 7*5, &plus, ARRAY_SIZE(plus));
|
||||
}
|
||||
|
||||
UI_PrintStringSmall(str, 2, 0, line);
|
||||
|
||||
DrawLevelBar(bar_x, line, s_level + overS9Bars);
|
||||
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);
|
||||
uint8_t overS9Bars = MIN(overS9dBm/10, 4);
|
||||
|
||||
if(overS9Bars == 0) {
|
||||
sprintf(str, "% 4d S%d", rssi_dBm, s_level);
|
||||
}
|
||||
else {
|
||||
sprintf(str, "% 4d %2d", rssi_dBm, overS9dBm);
|
||||
memcpy(p_line + 2 + 7*5, &plus, ARRAY_SIZE(plus));
|
||||
}
|
||||
#else
|
||||
|
||||
UI_PrintStringSmall(str, 2, 0, line);
|
||||
DrawLevelBar(bar_x, line, s_level + overS9Bars);
|
||||
if (now)
|
||||
ST7565_BlitLine(line);
|
||||
#else
|
||||
int16_t rssi = BK4819_GetRSSI();
|
||||
uint8_t Level;
|
||||
|
||||
if (rssi >= gEEPROM_RSSI_CALIB[gRxVfo->Band][3]) {
|
||||
@@ -226,29 +227,15 @@ static void DisplayRSSIBar(const int16_t rssi, const bool now)
|
||||
if (now)
|
||||
memset(pLine, 0, 23);
|
||||
DrawSmallAntennaAndBars(pLine, Level);
|
||||
if (now)
|
||||
ST7565_BlitFullScreen();
|
||||
#endif
|
||||
|
||||
if (now)
|
||||
ST7565_BlitFullScreen();
|
||||
}
|
||||
|
||||
|
||||
void UI_UpdateRSSI(const int16_t rssi, const int vfo)
|
||||
{
|
||||
(void)vfo; // unused
|
||||
|
||||
// optional larger RSSI dBm, S-point and bar level
|
||||
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||
gCurrentFunction == FUNCTION_MONITOR ||
|
||||
gCurrentFunction == FUNCTION_INCOMING)
|
||||
{
|
||||
|
||||
DisplayRSSIBar(rssi, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef ENABLE_AGC_SHOW_DATA
|
||||
static void PrintAGC(bool now)
|
||||
{
|
||||
@@ -290,10 +277,20 @@ static void PrintAGC(bool now)
|
||||
|
||||
void UI_MAIN_TimeSlice500ms(void)
|
||||
{
|
||||
if(gScreenToDisplay==DISPLAY_MAIN) {
|
||||
#ifdef ENABLE_AGC_SHOW_DATA
|
||||
if(gScreenToDisplay==DISPLAY_MAIN)
|
||||
PrintAGC(true);
|
||||
PrintAGC(true);
|
||||
return;
|
||||
#endif
|
||||
|
||||
const bool rx = (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||
gCurrentFunction == FUNCTION_MONITOR ||
|
||||
gCurrentFunction == FUNCTION_INCOMING);
|
||||
|
||||
|
||||
if(rx)
|
||||
DisplayRSSIBar(true);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -759,7 +756,7 @@ void UI_DisplayMain(void)
|
||||
#ifdef ENABLE_RSSI_BAR
|
||||
if (rx) {
|
||||
center_line = CENTER_LINE_RSSI;
|
||||
DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_VFO], false);
|
||||
DisplayRSSIBar(false);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user