mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-21 17:57:59 +00:00
Maintain monitor state when up/down freq/chan
This commit is contained in:
parent
9d178c549a
commit
14f154b927
45
am_fix.c
45
am_fix.c
@ -297,7 +297,7 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
#endif
|
||||
|
||||
unsigned int counter = 0;
|
||||
|
||||
|
||||
int16_t orig_dB_gain = -17;
|
||||
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
@ -321,8 +321,14 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
// used to limit the max front end gain
|
||||
unsigned int max_index = ARRAY_SIZE(am_fix_gain_table) - 1;
|
||||
|
||||
#ifndef ENABLE_AM_FIX_TEST1
|
||||
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
||||
const int16_t desired_rssi = (-89 + 160) * 2;
|
||||
#endif
|
||||
|
||||
void AM_fix_init(void)
|
||||
{
|
||||
{ // called at boot-up
|
||||
|
||||
/* unsigned int i;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
@ -359,6 +365,8 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
void AM_fix_reset(const int vfo)
|
||||
{ // reset the AM fixer
|
||||
|
||||
counter = 0;
|
||||
|
||||
prev_rssi[vfo] = 0;
|
||||
|
||||
am_gain_hold_counter[vfo] = 0;
|
||||
@ -372,8 +380,6 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
#endif
|
||||
|
||||
am_fix_gain_table_index_prev[vfo] = 0;
|
||||
|
||||
// AM_fix_init(); // bootup calls this
|
||||
}
|
||||
|
||||
// adjust the RX RF gain to try and prevent the AM demodulator from
|
||||
@ -388,13 +394,6 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
int16_t diff_dB;
|
||||
int16_t rssi;
|
||||
|
||||
#ifndef ENABLE_AM_FIX_TEST1
|
||||
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
|
||||
const int16_t desired_rssi = (-89 + 160) * 2; // dBm to ADC sample
|
||||
#endif
|
||||
|
||||
counter++;
|
||||
|
||||
// but we're not in FM mode, we're in AM mode
|
||||
|
||||
switch (gCurrentFunction)
|
||||
@ -402,6 +401,7 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
case FUNCTION_TRANSMIT:
|
||||
case FUNCTION_BAND_SCOPE:
|
||||
case FUNCTION_POWER_SAVE:
|
||||
counter = 0;
|
||||
return;
|
||||
|
||||
case FUNCTION_FOREGROUND:
|
||||
@ -414,6 +414,10 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
break;
|
||||
}
|
||||
|
||||
if (counter > 0)
|
||||
if (++counter >= 20) // limit display update rate to 200ms
|
||||
counter = 0;
|
||||
|
||||
{ // sample the current RSSI level
|
||||
// average it with the previous rssi (a bit of noise/spike immunity)
|
||||
const int16_t new_rssi = BK4819_GetRSSI();
|
||||
@ -427,7 +431,11 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
if (gCurrentRSSI[vfo] != new_rssi)
|
||||
{
|
||||
gCurrentRSSI[vfo] = new_rssi;
|
||||
gUpdateDisplay = ((counter & 15u) == 0); // limit the screen update rate to once every 150ms
|
||||
if (counter == 0)
|
||||
{
|
||||
counter = 1;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,13 +553,21 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
if (gCurrentRSSI[vfo] != new_rssi)
|
||||
{
|
||||
gCurrentRSSI[vfo] = new_rssi;
|
||||
gUpdateDisplay = ((counter & 15u) == 0); // limit the screen update rate to once every 150ms
|
||||
if (counter == 0)
|
||||
{
|
||||
counter = 1;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||
gUpdateDisplay = ((counter & 15u) == 0); // limit the screen update rate to once every 150ms
|
||||
if (counter == 0)
|
||||
{
|
||||
counter = 1;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -568,6 +584,7 @@ const uint8_t orig_pga = 6; // -3dB
|
||||
const int16_t gain_dB = lna_short_dB[lna_short] + lna_dB[lna] + mixer_dB[mixer] + pga_dB[pga];
|
||||
if (s != NULL)
|
||||
sprintf(s, "idx %2d %4ddB %3u", index, gain_dB, prev_rssi[vfo]);
|
||||
counter = 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
48
app/action.c
48
app/action.c
@ -66,27 +66,25 @@ void ACTION_Power(void)
|
||||
gRequestDisplayScreen = gScreenToDisplay;
|
||||
}
|
||||
|
||||
static void ACTION_Monitor(void)
|
||||
void ACTION_Monitor(void)
|
||||
{
|
||||
if (gCurrentFunction != FUNCTION_MONITOR)
|
||||
{
|
||||
{ // enable the monitor
|
||||
RADIO_SelectVfos();
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode)
|
||||
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
APP_StartListening(FUNCTION_MONITOR, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
if (gScanState != SCAN_OFF)
|
||||
{
|
||||
ScanPauseDelayIn_10ms = 500; // 5 seconds
|
||||
ScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
|
||||
gScheduleScanListen = false;
|
||||
gScanPauseMode = true;
|
||||
}
|
||||
@ -98,7 +96,7 @@ static void ACTION_Monitor(void)
|
||||
gScheduleNOAA = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
@ -117,14 +115,18 @@ void ACTION_Scan(bool bRestart)
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode)
|
||||
{
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE &&
|
||||
gCurrentFunction != FUNCTION_MONITOR &&
|
||||
gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
{
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
if (gFM_ScanState != FM_SCAN_OFF)
|
||||
{
|
||||
FM_PlayAndUpdate();
|
||||
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
@ -132,7 +134,7 @@ void ACTION_Scan(bool bRestart)
|
||||
else
|
||||
{
|
||||
uint16_t Frequency;
|
||||
|
||||
|
||||
if (bRestart)
|
||||
{
|
||||
gFM_AutoScan = true;
|
||||
@ -146,16 +148,16 @@ void ACTION_Scan(bool bRestart)
|
||||
gFM_ChannelPosition = 0;
|
||||
Frequency = gEeprom.FM_FrequencyPlaying;
|
||||
}
|
||||
|
||||
|
||||
BK1080_GetFrequencyDeviation(Frequency);
|
||||
FM_Tune(Frequency, 1, bRestart);
|
||||
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -163,6 +165,8 @@ void ACTION_Scan(bool bRestart)
|
||||
if (gScreenToDisplay != DISPLAY_SCANNER)
|
||||
{ // not scanning
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
RADIO_SelectVfos();
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -201,6 +205,8 @@ void ACTION_Scan(bool bRestart)
|
||||
if (!bRestart)
|
||||
{ // scanning
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
SCANNER_Stop();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
@ -241,19 +247,21 @@ void ACTION_Vox(void)
|
||||
if (gFmRadioMode)
|
||||
{
|
||||
FM_TurnOff();
|
||||
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
gVoxResumeCountdown = 80;
|
||||
gFlagReconfigureVfos = true;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
RADIO_SelectVfos();
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
|
||||
FM_Start();
|
||||
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
gRequestDisplayScreen = DISPLAY_FM;
|
||||
}
|
||||
@ -280,7 +288,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
//static void ACTION_FlashLight(void)
|
||||
void ACTION_Power(void);
|
||||
//static void ACTION_Monitor(void)
|
||||
void ACTION_Monitor(void);
|
||||
void ACTION_Scan(bool bFlag);
|
||||
void ACTION_Vox(void);
|
||||
#ifdef ENABLE_ALARM
|
||||
|
26
app/app.c
26
app/app.c
@ -203,7 +203,7 @@ static void APP_HandleIncoming(void)
|
||||
}
|
||||
}
|
||||
|
||||
APP_StartListening(FUNCTION_RECEIVE, false);
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false);
|
||||
}
|
||||
|
||||
static void APP_HandleReceive(void)
|
||||
@ -979,14 +979,14 @@ void APP_Update(void)
|
||||
if (IS_FREQ_CHANNEL(gNextMrChannel))
|
||||
{
|
||||
if (gCurrentFunction == FUNCTION_INCOMING)
|
||||
APP_StartListening(FUNCTION_RECEIVE, true);
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
else
|
||||
FREQ_NextChannel();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
|
||||
APP_StartListening(FUNCTION_RECEIVE, true);
|
||||
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
else
|
||||
MR_NextChannel();
|
||||
}
|
||||
@ -1726,8 +1726,13 @@ void APP_TimeSlice500ms(void)
|
||||
gAskToDelete = false;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
if (gFmRadioMode &&
|
||||
gCurrentFunction != FUNCTION_RECEIVE &&
|
||||
gCurrentFunction != FUNCTION_MONITOR &&
|
||||
gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
{
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef ENABLE_NO_SCAN_TIMEOUT
|
||||
@ -1747,7 +1752,11 @@ void APP_TimeSlice500ms(void)
|
||||
if (--gFM_ResumeCountdown_500ms == 0)
|
||||
{
|
||||
RADIO_SetVfoState(VFO_STATE_NORMAL);
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR && gFmRadioMode)
|
||||
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE &&
|
||||
gCurrentFunction != FUNCTION_TRANSMIT &&
|
||||
gCurrentFunction != FUNCTION_MONITOR &&
|
||||
gFmRadioMode)
|
||||
{ // switch back to FM radio mode
|
||||
FM_Start();
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
@ -1919,7 +1928,7 @@ void CHANNEL_Next(bool bFlag, int8_t Direction)
|
||||
FREQ_NextChannel();
|
||||
}
|
||||
|
||||
ScanPauseDelayIn_10ms = 50; // 500ms
|
||||
ScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
|
||||
gScheduleScanListen = false;
|
||||
gRxReceptionMode = RX_MODE_NONE;
|
||||
gScanPauseMode = false;
|
||||
@ -2340,6 +2349,9 @@ Skip:
|
||||
gVFO_RSSI_bar_level[1] = 0;
|
||||
|
||||
gFlagReconfigureVfos = false;
|
||||
|
||||
if (gMonitor)
|
||||
ACTION_Monitor(); // 1of11
|
||||
}
|
||||
|
||||
if (gFlagRefreshSetting)
|
||||
@ -2350,6 +2362,8 @@ Skip:
|
||||
|
||||
if (gFlagStartScan)
|
||||
{
|
||||
gMonitor = false;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
|
||||
AUDIO_PlaySingleVoice(true);
|
||||
|
@ -57,7 +57,7 @@ void MENU_StartCssScan(int8_t Direction)
|
||||
|
||||
MENU_SelectNextCode();
|
||||
|
||||
ScanPauseDelayIn_10ms = 50;
|
||||
ScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
|
||||
gScheduleScanListen = false;
|
||||
}
|
||||
|
||||
@ -746,7 +746,7 @@ void MENU_SelectNextCode(void)
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
|
||||
ScanPauseDelayIn_10ms = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? 20 : 30;
|
||||
ScanPauseDelayIn_10ms = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms;
|
||||
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -125,8 +125,12 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
||||
return;
|
||||
|
||||
case FUNCTION_MONITOR:
|
||||
gMonitor = true;
|
||||
break;
|
||||
|
||||
case FUNCTION_INCOMING:
|
||||
case FUNCTION_RECEIVE:
|
||||
gMonitor = false;
|
||||
break;
|
||||
|
||||
case FUNCTION_POWER_SAVE:
|
||||
@ -134,6 +138,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
|
||||
gPowerSaveCountdownExpired = false;
|
||||
|
||||
gRxIdleMode = true;
|
||||
|
||||
gMonitor = false;
|
||||
|
||||
BK4819_DisableVox();
|
||||
BK4819_Sleep();
|
||||
|
7
misc.c
7
misc.c
@ -47,6 +47,11 @@ const uint16_t dual_watch_count_noaa_10ms = 70 / 10; // 70ms
|
||||
const uint16_t dual_watch_count_after_vox_10ms = 200 / 10; // 200ms
|
||||
const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles
|
||||
|
||||
const uint16_t scan_pause_delay_in_1_10ms = 5000 / 10; // 5 seconds
|
||||
const uint16_t scan_pause_delay_in_2_10ms = 500 / 10; // 500ms
|
||||
const uint16_t scan_pause_delay_in_3_10ms = 200 / 10; // 200ms
|
||||
const uint16_t scan_pause_delay_in_4_10ms = 300 / 10; // 300ms
|
||||
|
||||
const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds
|
||||
|
||||
const uint16_t power_save1_10ms = 100 / 10; // 100ms
|
||||
@ -84,6 +89,8 @@ bool gSetting_ScrambleEnable;
|
||||
bool gSetting_live_DTMF_decoder;
|
||||
uint8_t gSetting_battery_text;
|
||||
|
||||
bool gMonitor = false; // true opens the squelch
|
||||
|
||||
uint32_t gCustomAesKey[4];
|
||||
bool bHasCustomAesKey;
|
||||
uint32_t gChallenge[4];
|
||||
|
7
misc.h
7
misc.h
@ -121,6 +121,11 @@ extern const uint16_t dual_watch_count_toggle_10ms;
|
||||
extern const uint16_t dual_watch_count_noaa_10ms;
|
||||
extern const uint16_t dual_watch_count_after_vox_10ms;
|
||||
|
||||
extern const uint16_t scan_pause_delay_in_1_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_2_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_3_10ms;
|
||||
extern const uint16_t scan_pause_delay_in_4_10ms;
|
||||
|
||||
extern const uint16_t gMax_bat_v;
|
||||
extern const uint16_t gMin_bat_v;
|
||||
|
||||
@ -147,6 +152,8 @@ extern bool gSetting_ScrambleEnable;
|
||||
extern bool gSetting_live_DTMF_decoder;
|
||||
extern uint8_t gSetting_battery_text;
|
||||
|
||||
extern bool gMonitor;
|
||||
|
||||
extern const uint32_t gDefaultAesKey[4];
|
||||
extern uint32_t gCustomAesKey[4];
|
||||
extern bool bHasCustomAesKey;
|
||||
|
6
radio.c
6
radio.c
@ -669,11 +669,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
// BK4819_SetTailDetection(670); // 67Hz
|
||||
//#endif
|
||||
|
||||
InterruptMask = 0
|
||||
| BK4819_REG_3F_CxCSS_TAIL
|
||||
| BK4819_REG_3F_SQUELCH_FOUND
|
||||
| BK4819_REG_3F_SQUELCH_LOST;
|
||||
|
||||
InterruptMask = BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
break;
|
||||
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
|
Loading…
Reference in New Issue
Block a user