Replace RX CSS menu scanning procedure with BK scanning method

This commit is contained in:
Krzysiek Egzmont 2023-11-06 01:25:44 +01:00
parent 1238bf090c
commit b1d3a95ca2
20 changed files with 232 additions and 297 deletions

View File

@ -24,6 +24,7 @@
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/scanner.h"
#include "audio.h" #include "audio.h"
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -164,7 +165,7 @@ void ACTION_Scan(bool bRestart)
} }
#endif #endif
if (gScreenToDisplay != DISPLAY_SCANNER) if (!SCANNER_IsScanning())
{ // not scanning { // not scanning
gMonitor = false; gMonitor = false;

View File

@ -93,15 +93,6 @@ static void CheckForIncoming(void)
if (gScanStateDir == SCAN_OFF) if (gScanStateDir == SCAN_OFF)
{ // not RF scanning { // not RF scanning
if (gCssScanMode != CSS_SCAN_MODE_OFF && gRxReceptionMode == RX_MODE_NONE)
{ // CTCSS/DTS scanning
gScanPauseDelayIn_10ms = scan_pause_delay_in_5_10ms;
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_DETECTED;
}
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
{ // dual watch is disabled { // dual watch is disabled
@ -220,7 +211,7 @@ static void HandleIncoming(void)
if (!bFlag) if (!bFlag)
return; return;
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) if (gScanStateDir == SCAN_OFF)
{ // not scanning { // not scanning
if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED)
{ // DTMF DCD is enabled { // DTMF DCD is enabled
@ -498,11 +489,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
} }
#endif #endif
if (gCssScanMode != CSS_SCAN_MODE_OFF)
gCssScanMode = CSS_SCAN_MODE_FOUND;
if (gScanStateDir == SCAN_OFF && if (gScanStateDir == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF &&
gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ // not scanning, dual watch is enabled { // not scanning, dual watch is enabled
@ -634,7 +621,7 @@ static void DualwatchAlternate(void)
static void CheckRadioInterrupts(void) static void CheckRadioInterrupts(void)
{ {
if (gScreenToDisplay == DISPLAY_SCANNER) if (SCANNER_IsScanning())
return; return;
while (BK4819_ReadRegister(BK4819_REG_0C) & 1u) while (BK4819_ReadRegister(BK4819_REG_0C) & 1u)
@ -806,7 +793,7 @@ void APP_EndTransmission(void)
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
return; return;
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) if (gScanStateDir != SCAN_OFF)
return; return;
if (gVOX_NoiseDetected) if (gVOX_NoiseDetected)
@ -897,25 +884,14 @@ void APP_Update(void)
#endif #endif
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0) if (!SCANNER_IsScanning() && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0)
#else #else
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed) if (!SCANNER_IsScanning() && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed)
#endif #endif
{ // scanning { // scanning
CHFRSCANNER_ContinueScanning(); CHFRSCANNER_ContinueScanning();
} }
#ifdef ENABLE_VOICE
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && gVoiceWriteIndex == 0)
#else
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen)
#endif
{
MENU_SelectNextCode();
gScheduleScanListen = false;
}
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0)
@ -932,7 +908,7 @@ void APP_Update(void)
#endif #endif
// toggle between the VFO's if dual watch is enabled // toggle between the VFO's if dual watch is enabled
if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) if (!SCANNER_IsScanning() && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gScheduleDualWatch && gVoiceWriteIndex == 0) if (gScheduleDualWatch && gVoiceWriteIndex == 0)
@ -940,7 +916,7 @@ void APP_Update(void)
if (gScheduleDualWatch) if (gScheduleDualWatch)
#endif #endif
{ {
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) if (gScanStateDir == SCAN_OFF)
{ {
if (!gPttIsPressed && if (!gPttIsPressed &&
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -991,7 +967,7 @@ void APP_Update(void)
gKeyBeingHeld || gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 || gEeprom.BATTERY_SAVE == 0 ||
gScanStateDir != SCAN_OFF || gScanStateDir != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF || gCssBackgroundScan ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
{ {
@ -1015,7 +991,7 @@ void APP_Update(void)
gKeyBeingHeld || gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 || gEeprom.BATTERY_SAVE == 0 ||
gScanStateDir != SCAN_OFF || gScanStateDir != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF || gCssBackgroundScan ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
{ {
@ -1049,7 +1025,7 @@ void APP_Update(void)
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF &&
gScanStateDir == SCAN_OFF && gScanStateDir == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF) !gCssBackgroundScan)
{ // dual watch mode, toggle between the two VFO's { // dual watch mode, toggle between the two VFO's
DualwatchAlternate(); DualwatchAlternate();
@ -1062,7 +1038,7 @@ void APP_Update(void)
gRxIdleMode = false; // RX is awake gRxIdleMode = false; // RX is awake
} }
else else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssBackgroundScan || gUpdateRSSI)
{ // dual watch mode off or scanning or rssi update request { // dual watch mode off or scanning or rssi update request
UpdateRSSI(gEeprom.RX_VFO); UpdateRSSI(gEeprom.RX_VFO);
@ -1447,9 +1423,9 @@ void APP_TimeSlice500ms(void)
if (gBacklightCountdown > 0 && if (gBacklightCountdown > 0 &&
!gAskToSave && !gAskToSave &&
gCssScanMode == CSS_SCAN_MODE_OFF && !gCssBackgroundScan &&
// don't turn off backlight if user is in backlight menu option // don't turn off backlight if user is in backlight menu option
!(gScreenToDisplay == DISPLAY_MENU && (GetCurrentMenuId() == MENU_ABR || GetCurrentMenuId() == MENU_ABR_MAX)) !(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX))
) )
{ if (--gBacklightCountdown == 0) { if (--gBacklightCountdown == 0)
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) // backlight is not set to be always on if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) // backlight is not set to be always on
@ -1504,15 +1480,15 @@ void APP_TimeSlice500ms(void)
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF) if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && !gCssBackgroundScan)
#else #else
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (!gCssBackgroundScan)
#endif #endif
{ {
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && !SCANNER_IsScanning())
#else #else
if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning())
#endif #endif
{ {
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU) if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU)
@ -1534,7 +1510,7 @@ void APP_TimeSlice500ms(void)
if (gInputBoxIndex > 0 || gDTMF_InputMode) if (gInputBoxIndex > 0 || gDTMF_InputMode)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
/* /*
if (gScreenToDisplay == DISPLAY_SCANNER) if (SCANNER_IsScanning())
{ {
BK4819_StopScan(); BK4819_StopScan();
@ -1570,10 +1546,10 @@ void APP_TimeSlice500ms(void)
if (disp == DISPLAY_INVALID) if (disp == DISPLAY_INVALID)
{ {
#ifndef ENABLE_CODE_SCAN_TIMEOUT #ifndef ENABLE_CODE_SCAN_TIMEOUT
if (gScreenToDisplay != DISPLAY_SCANNER) if (!SCANNER_IsScanning())
#endif #endif
disp = DISPLAY_MAIN; disp = DISPLAY_MAIN;
} }
if (disp != DISPLAY_INVALID) if (disp != DISPLAY_INVALID)
@ -1727,7 +1703,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
else // key pressed or held else // key pressed or held
{ {
const uint8_t s = gSetting_backlight_on_tx_rx; const uint8_t s = gSetting_backlight_on_tx_rx;
const int m = GetCurrentMenuId(); const int m = UI_MENU_GetCurrentMenuId();
if ( //not when PTT and the backlight shouldn't turn on on TX if ( //not when PTT and the backlight shouldn't turn on on TX
!(Key == KEY_PTT && s != BACKLIGHT_ON_TR_TX && s != BACKLIGHT_ON_TR_TXRX) !(Key == KEY_PTT && s != BACKLIGHT_ON_TR_TX && s != BACKLIGHT_ON_TR_TXRX)
// not in the backlight menu // not in the backlight menu
@ -1816,7 +1792,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Key <= KEY_9 || Key == KEY_F) if (Key <= KEY_9 || Key == KEY_F)
{ {
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) if (gScanStateDir != SCAN_OFF || gCssBackgroundScan)
{ // FREQ/CTCSS/DCS scanning { // FREQ/CTCSS/DCS scanning
if (bKeyPressed && !bKeyHeld) if (bKeyPressed && !bKeyHeld)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
@ -1972,9 +1948,9 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
else else
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY) if (!SCANNER_IsScanning() && gScreenToDisplay != DISPLAY_AIRCOPY)
#else #else
if (gScreenToDisplay != DISPLAY_SCANNER) if (!SCANNER_IsScanning())
#endif #endif
{ {
ACTION_Handle(Key, bKeyPressed, bKeyHeld); ACTION_Handle(Key, bKeyPressed, bKeyHeld);
@ -2000,12 +1976,6 @@ Skip:
gFlagAcceptSetting = false; gFlagAcceptSetting = false;
} }
if (gFlagStopScan)
{
BK4819_StopScan();
gFlagStopScan = false;
}
if (gRequestSaveSettings) if (gRequestSaveSettings)
{ {
if (!bKeyHeld) if (!bKeyHeld)
@ -2042,7 +2012,7 @@ Skip:
{ {
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel); SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel);
if (gScreenToDisplay != DISPLAY_SCANNER) if (!SCANNER_IsScanning())
if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere
gVfoConfigureMode = VFO_CONFIGURE; gVfoConfigureMode = VFO_CONFIGURE;
} }

View File

@ -210,7 +210,7 @@ void DTMF_HandleRequest(void)
if (!gDTMF_RX_pending) if (!gDTMF_RX_pending)
return; // nothing new received return; // nothing new received
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) if (gScanStateDir != SCAN_OFF || gCssBackgroundScan)
{ // we're busy scanning { // we're busy scanning
DTMF_clear_RX(); DTMF_clear_RX();
return; return;

View File

@ -143,36 +143,21 @@ void GENERIC_Key_PTT(bool bKeyPressed)
// PTT pressed // PTT pressed
if (gScanStateDir != SCAN_OFF || // frequency/channel scanning
gScreenToDisplay == DISPLAY_SCANNER || // CTCSS/CDCSS scanning
gCssScanMode != CSS_SCAN_MODE_OFF) // " "
{ // we're scanning .. stop
if (gScreenToDisplay == DISPLAY_SCANNER)
{ // CTCSS/CDCSS scanning .. stop
gEeprom.CROSS_BAND_RX_TX = gBackup_CROSS_BAND_RX_TX;
gFlagStopScan = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
}
else
if (gScanStateDir != SCAN_OFF)
{ // frequency/channel scanning . .stop
CHFRSCANNER_Stop();
}
else
if (gCssScanMode != CSS_SCAN_MODE_OFF)
{ // CTCSS/CDCSS scanning .. stop
MENU_StopCssScan();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
if (SCANNER_IsScanning())
{ // CTCSS/CDCSS scanning .. stop
SCANNER_Stop();
goto cancel_tx; goto cancel_tx;
} }
if (gScanStateDir != SCAN_OFF)
{ // frequency/channel scanning . .stop
CHFRSCANNER_Stop();
goto cancel_tx;
}
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF) if (gFM_ScanState != FM_SCAN_OFF)
{ // FM radio is scanning .. stop { // FM radio is scanning .. stop

View File

@ -46,7 +46,7 @@
void toggle_chan_scanlist(void) void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting { // toggle the selected channels scanlist setting
if (gScreenToDisplay == DISPLAY_SCANNER || !IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if ( SCANNER_IsScanning() || !IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
return; return;
if (gTxVfo->SCANLIST1_PARTICIPATION) if (gTxVfo->SCANLIST1_PARTICIPATION)
@ -106,7 +106,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
#ifdef ENABLE_COPY_CHAN_TO_VFO #ifdef ENABLE_COPY_CHAN_TO_VFO
if (gEeprom.VFO_OPEN && gCssScanMode == CSS_SCAN_MODE_OFF) if (gEeprom.VFO_OPEN && !gCssBackgroundScan)
{ {
if (gScanStateDir != SCAN_OFF) if (gScanStateDir != SCAN_OFF)
@ -664,7 +664,6 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
SCANNER_Start(true); SCANNER_Start(true);
gRequestDisplayScreen = DISPLAY_SCANNER; gRequestDisplayScreen = DISPLAY_SCANNER;
} }
gPttWasReleased = true; gPttWasReleased = true;

View File

@ -75,27 +75,39 @@
} }
#endif #endif
void MENU_StartCssScan(int8_t Direction) void MENU_StartCssScan(void)
{ {
gCssScanMode = CSS_SCAN_MODE_SCANNING; SCANNER_Start(true);
gUpdateStatus = true; gUpdateStatus = true;
gCssBackgroundScan = true;
gMenuScrollDirection = Direction; gRequestDisplayScreen = DISPLAY_MENU;
}
RADIO_SelectVfos(); void MENU_CssScanFound(void)
{
if(gScanCssResultType == CODE_TYPE_DIGITAL || gScanCssResultType == CODE_TYPE_REVERSE_DIGITAL) {
gMenuCursor = UI_MENU_GetMenuIdx(MENU_R_DCS);
}
else if(gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE) {
gMenuCursor = UI_MENU_GetMenuIdx(MENU_R_CTCS);
}
MENU_SelectNextCode(); MENU_ShowCurrentSetting();
gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms; gUpdateStatus = true;
gScheduleScanListen = false; gUpdateDisplay = true;
} }
void MENU_StopCssScan(void) void MENU_StopCssScan(void)
{ {
gCssScanMode = CSS_SCAN_MODE_OFF; gCssBackgroundScan = false;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gUpdateDisplay = true;
gUpdateStatus = true; gUpdateStatus = true;
RADIO_SetupRegisters(true);
} }
int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
@ -367,14 +379,14 @@ void MENU_AcceptSetting(void)
uint8_t Code; uint8_t Code;
FREQ_Config_t *pConfig = &gTxVfo->freq_config_RX; FREQ_Config_t *pConfig = &gTxVfo->freq_config_RX;
if (!MENU_GetLimits(GetCurrentMenuId(), &Min, &Max)) if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max))
{ {
if (gSubMenuSelection < Min) gSubMenuSelection = Min; if (gSubMenuSelection < Min) gSubMenuSelection = Min;
else else
if (gSubMenuSelection > Max) gSubMenuSelection = Max; if (gSubMenuSelection > Max) gSubMenuSelection = Max;
} }
switch (GetCurrentMenuId()) switch (UI_MENU_GetCurrentMenuId())
{ {
default: default:
return; return;
@ -808,7 +820,7 @@ void MENU_AcceptSetting(void)
&gEeprom.KEY_2_SHORT_PRESS_ACTION, &gEeprom.KEY_2_SHORT_PRESS_ACTION,
&gEeprom.KEY_2_LONG_PRESS_ACTION, &gEeprom.KEY_2_LONG_PRESS_ACTION,
&gEeprom.KEY_M_LONG_PRESS_ACTION}; &gEeprom.KEY_M_LONG_PRESS_ACTION};
*fun[GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id; *fun[UI_MENU_GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id;
} }
break; break;
@ -817,53 +829,12 @@ void MENU_AcceptSetting(void)
gRequestSaveSettings = true; gRequestSaveSettings = true;
} }
void MENU_SelectNextCode(void)
{
int32_t UpperLimit;
if (GetCurrentMenuId() == MENU_R_DCS)
UpperLimit = 208;
//UpperLimit = ARRAY_SIZE(DCS_Options);
else if (GetCurrentMenuId() == MENU_R_CTCS)
UpperLimit = ARRAY_SIZE(CTCSS_Options) - 1;
else
return;
gSubMenuSelection = NUMBER_AddWithWraparound(gSubMenuSelection, gMenuScrollDirection, 1, UpperLimit);
if (GetCurrentMenuId() == MENU_R_DCS)
{
if (gSubMenuSelection > 104)
{
gSelectedCodeType = CODE_TYPE_REVERSE_DIGITAL;
gSelectedCode = gSubMenuSelection - 105;
}
else
{
gSelectedCodeType = CODE_TYPE_DIGITAL;
gSelectedCode = gSubMenuSelection - 1;
}
}
else
{
gSelectedCodeType = CODE_TYPE_CONTINUOUS_TONE;
gSelectedCode = gSubMenuSelection - 1;
}
RADIO_SetupRegisters(true);
gScanPauseDelayIn_10ms = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms;
gUpdateDisplay = true;
}
static void MENU_ClampSelection(int8_t Direction) static void MENU_ClampSelection(int8_t Direction)
{ {
int32_t Min; int32_t Min;
int32_t Max; int32_t Max;
if (!MENU_GetLimits(GetCurrentMenuId(), &Min, &Max)) if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max))
{ {
int32_t Selection = gSubMenuSelection; int32_t Selection = gSubMenuSelection;
if (Selection < Min) Selection = Min; if (Selection < Min) Selection = Min;
@ -875,7 +846,7 @@ static void MENU_ClampSelection(int8_t Direction)
void MENU_ShowCurrentSetting(void) void MENU_ShowCurrentSetting(void)
{ {
switch (GetCurrentMenuId()) switch (UI_MENU_GetCurrentMenuId())
{ {
case MENU_SQL: case MENU_SQL:
gSubMenuSelection = gEeprom.SQUELCH_LEVEL; gSubMenuSelection = gEeprom.SQUELCH_LEVEL;
@ -889,28 +860,41 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gTxVfo->OUTPUT_POWER; gSubMenuSelection = gTxVfo->OUTPUT_POWER;
break; break;
case MENU_R_DCS: case MENU_RESET:
switch (gTxVfo->freq_config_RX.CodeType) gSubMenuSelection = 0;
{ break;
case MENU_R_DCS:
case MENU_R_CTCS:
{
DCS_CodeType_t type = gTxVfo->freq_config_RX.CodeType;
uint8_t code = gTxVfo->freq_config_RX.Code;
int menuid = UI_MENU_GetCurrentMenuId();
if(gScanUseCssResult) {
gScanUseCssResult = false;
type = gScanCssResultType;
code = gScanCssResultCode;
}
if((menuid==MENU_R_CTCS) ^ (type==CODE_TYPE_CONTINUOUS_TONE)) { //not the same type
gSubMenuSelection = 0;
break;
}
switch (type) {
case CODE_TYPE_CONTINUOUS_TONE:
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
gSubMenuSelection = gTxVfo->freq_config_RX.Code + 1; gSubMenuSelection = code + 1;
break; break;
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
gSubMenuSelection = gTxVfo->freq_config_RX.Code + 105; gSubMenuSelection = code + 105;
break; break;
default: default:
gSubMenuSelection = 0; gSubMenuSelection = 0;
break; break;
} }
break; break;
}
case MENU_RESET:
gSubMenuSelection = 0;
break;
case MENU_R_CTCS:
gSubMenuSelection = (gTxVfo->freq_config_RX.CodeType == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_RX.Code + 1 : 0;
break;
case MENU_T_DCS: case MENU_T_DCS:
switch (gTxVfo->freq_config_TX.CodeType) switch (gTxVfo->freq_config_TX.CodeType)
@ -1199,7 +1183,7 @@ void MENU_ShowCurrentSetting(void)
&gEeprom.KEY_2_SHORT_PRESS_ACTION, &gEeprom.KEY_2_SHORT_PRESS_ACTION,
&gEeprom.KEY_2_LONG_PRESS_ACTION, &gEeprom.KEY_2_LONG_PRESS_ACTION,
&gEeprom.KEY_M_LONG_PRESS_ACTION}; &gEeprom.KEY_M_LONG_PRESS_ACTION};
uint8_t id = *fun[GetCurrentMenuId()-MENU_F1SHRT]; uint8_t id = *fun[UI_MENU_GetCurrentMenuId()-MENU_F1SHRT];
for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) { for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) {
if(gSubMenu_SIDEFUNCTIONS[i].id==id) { if(gSubMenu_SIDEFUNCTIONS[i].id==id) {
@ -1228,7 +1212,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name { // currently editing the channel name
if (edit_index < 10) if (edit_index < 10)
@ -1293,7 +1277,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
if (GetCurrentMenuId() == MENU_OFFSET) if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET)
{ {
uint32_t Frequency; uint32_t Frequency;
@ -1316,10 +1300,10 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
if (GetCurrentMenuId() == MENU_MEM_CH || if (UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_DEL_CH ||
GetCurrentMenuId() == MENU_1_CALL || UI_MENU_GetCurrentMenuId() == MENU_1_CALL ||
GetCurrentMenuId() == MENU_MEM_NAME) UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
{ // enter 3-digit channel number { // enter 3-digit channel number
if (gInputBoxIndex < 3) if (gInputBoxIndex < 3)
@ -1348,7 +1332,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
if (MENU_GetLimits(GetCurrentMenuId(), &Min, &Max)) if (MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max))
{ {
gInputBoxIndex = 0; gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@ -1389,11 +1373,11 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (!gCssBackgroundScan)
{ {
if (gIsInSubMenu) if (gIsInSubMenu)
{ {
if (gInputBoxIndex == 0 || GetCurrentMenuId() != MENU_OFFSET) if (gInputBoxIndex == 0 || UI_MENU_GetCurrentMenuId() != MENU_OFFSET)
{ {
gAskForConfirmation = 0; gAskForConfirmation = 0;
gIsInSubMenu = false; gIsInSubMenu = false;
@ -1449,12 +1433,12 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (!gIsInSubMenu) if (!gIsInSubMenu)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (GetCurrentMenuId() != MENU_SCR) if (UI_MENU_GetCurrentMenuId() != MENU_SCR)
gAnotherVoiceID = MenuList[gMenuCursor].voice_id; gAnotherVoiceID = MenuList[gMenuCursor].voice_id;
#endif #endif
#if 1 #if 1
if (GetCurrentMenuId() == MENU_DEL_CH || GetCurrentMenuId() == MENU_MEM_NAME) if (UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
return; // invalid channel return; // invalid channel
#endif #endif
@ -1462,7 +1446,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gAskForConfirmation = 0; gAskForConfirmation = 0;
gIsInSubMenu = true; gIsInSubMenu = true;
// if (GetCurrentMenuId() != MENU_D_LIST) // if (UI_MENU_GetCurrentMenuId() != MENU_D_LIST)
{ {
gInputBoxIndex = 0; gInputBoxIndex = 0;
edit_index = -1; edit_index = -1;
@ -1471,7 +1455,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
return; return;
} }
if (GetCurrentMenuId() == MENU_MEM_NAME) if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
{ {
if (edit_index < 0) if (edit_index < 0)
{ // enter channel name edit mode { // enter channel name edit mode
@ -1518,10 +1502,10 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (gIsInSubMenu) if (gIsInSubMenu)
{ {
if (GetCurrentMenuId() == MENU_RESET || if (UI_MENU_GetCurrentMenuId() == MENU_RESET ||
GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_DEL_CH ||
GetCurrentMenuId() == MENU_MEM_NAME) UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME)
{ {
switch (gAskForConfirmation) switch (gAskForConfirmation)
{ {
@ -1534,7 +1518,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
UI_DisplayMenu(); UI_DisplayMenu();
if (GetCurrentMenuId() == MENU_RESET) if (UI_MENU_GetCurrentMenuId() == MENU_RESET)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM); AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
@ -1562,14 +1546,10 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
} }
} }
if (gCssScanMode != CSS_SCAN_MODE_OFF) SCANNER_Stop();
{
gCssScanMode = CSS_SCAN_MODE_OFF;
gUpdateStatus = true;
}
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (GetCurrentMenuId() == MENU_SCR) if (UI_MENU_GetCurrentMenuId() == MENU_SCR)
gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON; gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else else
gAnotherVoiceID = VOICE_ID_CONFIRM; gAnotherVoiceID = VOICE_ID_CONFIRM;
@ -1585,7 +1565,7 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name { // currently editing the channel name
if (edit_index < 10) if (edit_index < 10)
@ -1612,26 +1592,12 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
if (gRxVfo->Modulation == MODULATION_FM) if (gRxVfo->Modulation == MODULATION_FM)
#endif #endif
{ {
if (GetCurrentMenuId() == MENU_R_CTCS || GetCurrentMenuId() == MENU_R_DCS) if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gIsInSubMenu)
{ // scan CTCSS or DCS to find the tone/code of the incoming signal { // scan CTCSS or DCS to find the tone/code of the incoming signal
if (!SCANNER_IsScanning())
if (gCssScanMode == CSS_SCAN_MODE_OFF) MENU_StartCssScan();
{
MENU_StartCssScan(1);
gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(1);
#endif
}
else else
{
MENU_StopCssScan(); MENU_StopCssScan();
gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
} }
gPttWasReleased = true; gPttWasReleased = true;
@ -1647,7 +1613,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint8_t Channel; uint8_t Channel;
bool bCheckScanList; bool bCheckScanList;
if (GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0) if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character { // change the character
if (bKeyPressed && edit_index < 10 && Direction != 0) if (bKeyPressed && edit_index < 10 && Direction != 0)
{ {
@ -1682,12 +1648,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (!bKeyPressed) if (!bKeyPressed)
return; return;
if (gCssScanMode != CSS_SCAN_MODE_OFF) if (SCANNER_IsScanning()) {
{
MENU_StartCssScan(Direction);
gPttWasReleased = true;
gRequestDisplayScreen = DISPLAY_MENU;
return; return;
} }
@ -1699,7 +1660,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
if (GetCurrentMenuId() != MENU_ABR && gEeprom.BACKLIGHT_TIME == 0) // backlight always off and not in the backlight menu if (UI_MENU_GetCurrentMenuId() != MENU_ABR && gEeprom.BACKLIGHT_TIME == 0) // backlight always off and not in the backlight menu
{ {
BACKLIGHT_TurnOff(); BACKLIGHT_TurnOff();
} }
@ -1707,7 +1668,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return; return;
} }
if (GetCurrentMenuId() == MENU_OFFSET) if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET)
{ {
int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection; int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection;
if (Offset < 99999990) if (Offset < 99999990)
@ -1725,7 +1686,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
VFO = 0; VFO = 0;
switch (GetCurrentMenuId()) switch (UI_MENU_GetCurrentMenuId())
{ {
case MENU_DEL_CH: case MENU_DEL_CH:
case MENU_1_CALL: case MENU_1_CALL:
@ -1785,7 +1746,7 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
MENU_Key_STAR(bKeyPressed, bKeyHeld); MENU_Key_STAR(bKeyPressed, bKeyHeld);
break; break;
case KEY_F: case KEY_F:
if (GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name { // currently editing the channel name
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)
{ {
@ -1817,11 +1778,11 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gScreenToDisplay == DISPLAY_MENU) if (gScreenToDisplay == DISPLAY_MENU)
{ {
if (GetCurrentMenuId() == MENU_VOL || if (UI_MENU_GetCurrentMenuId() == MENU_VOL ||
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
GetCurrentMenuId() == MENU_F_CALI || UI_MENU_GetCurrentMenuId() == MENU_F_CALI ||
#endif #endif
GetCurrentMenuId() == MENU_BATCAL) UI_MENU_GetCurrentMenuId() == MENU_BATCAL)
{ {
gMenuCountdown = menu_timeout_long_500ms; gMenuCountdown = menu_timeout_long_500ms;
} }

View File

@ -25,9 +25,9 @@
int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax); int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax);
void MENU_AcceptSetting(void); void MENU_AcceptSetting(void);
void MENU_SelectNextCode(void);
void MENU_ShowCurrentSetting(void); void MENU_ShowCurrentSetting(void);
void MENU_StartCssScan(int8_t Direction); void MENU_StartCssScan(void);
void MENU_CssScanFound(void);
void MENU_StopCssScan(void); void MENU_StopCssScan(void);
void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);

View File

@ -17,6 +17,7 @@
#include "app/app.h" #include "app/app.h"
#include "app/dtmf.h" #include "app/dtmf.h"
#include "app/generic.h" #include "app/generic.h"
#include "app/menu.h"
#include "app/scanner.h" #include "app/scanner.h"
#include "audio.h" #include "audio.h"
#include "driver/bk4819.h" #include "driver/bk4819.h"
@ -29,7 +30,6 @@
DCS_CodeType_t gScanCssResultType; DCS_CodeType_t gScanCssResultType;
uint8_t gScanCssResultCode; uint8_t gScanCssResultCode;
bool gFlagStopScan;
bool gScanSingleFrequency; // scan CTCSS/DCS codes for current frequency bool gScanSingleFrequency; // scan CTCSS/DCS codes for current frequency
SCAN_SaveState_t gScannerSaveState; SCAN_SaveState_t gScannerSaveState;
uint8_t gScanChannel; uint8_t gScanChannel;
@ -84,16 +84,8 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
switch (gScannerSaveState) { switch (gScannerSaveState) {
case SCAN_SAVE_NO_PROMPT: case SCAN_SAVE_NO_PROMPT:
SCANNER_Stop();
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
gEeprom.CROSS_BAND_RX_TX = gBackup_CROSS_BAND_RX_TX;
gUpdateStatus = true;
gFlagStopScan = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
break; break;
case SCAN_SAVE_CHAN_SEL: case SCAN_SAVE_CHAN_SEL:
@ -374,9 +366,25 @@ void SCANNER_Start(bool singleFreq)
gScanProgressIndicator = 0; gScanProgressIndicator = 0;
} }
void SCANNER_Stop(void)
{
if(SCANNER_IsScanning()) {
gEeprom.CROSS_BAND_RX_TX = gBackup_CROSS_BAND_RX_TX;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true;
gUpdateStatus = true;
gCssBackgroundScan = false;
gScanUseCssResult = false;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL;
#endif
BK4819_StopScan();
}
}
void SCANNER_TimeSlice10ms(void) void SCANNER_TimeSlice10ms(void)
{ {
if (gScreenToDisplay != DISPLAY_SCANNER) if (!SCANNER_IsScanning())
return; return;
if (gScanDelay_10ms > 0) { if (gScanDelay_10ms > 0) {
@ -419,7 +427,8 @@ void SCANNER_TimeSlice10ms(void)
gScanProgressIndicator = 0; gScanProgressIndicator = 0;
gScanCssState = SCAN_CSS_STATE_SCANNING; gScanCssState = SCAN_CSS_STATE_SCANNING;
GUI_SelectNextDisplay(DISPLAY_SCANNER); if(!gCssBackgroundScan)
GUI_SelectNextDisplay(DISPLAY_SCANNER);
gUpdateStatus = true; gUpdateStatus = true;
} }
@ -466,23 +475,33 @@ void SCANNER_TimeSlice10ms(void)
} }
} }
if (gScanCssState < SCAN_CSS_STATE_FOUND) { if (gScanCssState < SCAN_CSS_STATE_FOUND) { // scanning or off
BK4819_SetScanFrequency(gScanFrequency); BK4819_SetScanFrequency(gScanFrequency);
gScanDelay_10ms = scan_delay_10ms; gScanDelay_10ms = scan_delay_10ms;
break; break;
} }
GUI_SelectNextDisplay(DISPLAY_SCANNER); if(gCssBackgroundScan) {
gCssBackgroundScan = false;
if(gScanUseCssResult)
MENU_CssScanFound();
}
else
GUI_SelectNextDisplay(DISPLAY_SCANNER);
break; break;
} }
default: default:
gCssBackgroundScan = false;
break; break;
} }
} }
void SCANNER_TimeSlice500ms(void) void SCANNER_TimeSlice500ms(void)
{ {
if (gScreenToDisplay == DISPLAY_SCANNER && gScannerSaveState == SCAN_SAVE_NO_PROMPT && gScanCssState < SCAN_CSS_STATE_FOUND) { if (SCANNER_IsScanning() && gScannerSaveState == SCAN_SAVE_NO_PROMPT && gScanCssState < SCAN_CSS_STATE_FOUND) {
gScanProgressIndicator++; gScanProgressIndicator++;
#ifdef ENABLE_CODE_SCAN_TIMEOUT #ifdef ENABLE_CODE_SCAN_TIMEOUT
if (gScanProgressIndicator > 32) { if (gScanProgressIndicator > 32) {
@ -496,4 +515,12 @@ void SCANNER_TimeSlice500ms(void)
#endif #endif
gUpdateDisplay = true; gUpdateDisplay = true;
} }
else if(gCssBackgroundScan) {
gUpdateDisplay = true;
}
}
bool SCANNER_IsScanning(void)
{
return gCssBackgroundScan || (gScreenToDisplay == DISPLAY_SCANNER);
} }

View File

@ -38,7 +38,6 @@ typedef enum
extern DCS_CodeType_t gScanCssResultType; extern DCS_CodeType_t gScanCssResultType;
extern uint8_t gScanCssResultCode; extern uint8_t gScanCssResultCode;
extern bool gFlagStopScan;
extern bool gScanSingleFrequency; extern bool gScanSingleFrequency;
extern SCAN_SaveState_t gScannerSaveState; extern SCAN_SaveState_t gScannerSaveState;
extern uint8_t gScanChannel; extern uint8_t gScanChannel;
@ -49,8 +48,10 @@ extern bool gScanUseCssResult;
void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
void SCANNER_Start(bool singleFreq); void SCANNER_Start(bool singleFreq);
void SCANNER_Stop(void);
void SCANNER_TimeSlice10ms(void); void SCANNER_TimeSlice10ms(void);
void SCANNER_TimeSlice500ms(void); void SCANNER_TimeSlice500ms(void);
bool SCANNER_IsScanning(void);
#endif #endif

View File

@ -44,18 +44,16 @@ FUNCTION_Type_t gCurrentFunction;
void FUNCTION_Init(void) void FUNCTION_Init(void)
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif #endif
{ {
gCurrentCodeType = gSelectedCodeType; gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
if (gCssScanMode == CSS_SCAN_MODE_OFF)
gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE; gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
#endif #endif
DTMF_clear_RX(); DTMF_clear_RX();

View File

@ -120,7 +120,7 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
} }
if ((gScreenToDisplay == DISPLAY_MENU) && GetCurrentMenuId() == MENU_VOL) if ((gScreenToDisplay == DISPLAY_MENU) && UI_MENU_GetCurrentMenuId() == MENU_VOL)
gUpdateDisplay = true; gUpdateDisplay = true;
if (gBatteryCurrent < 501) if (gBatteryCurrent < 501)

2
misc.c
View File

@ -154,7 +154,7 @@ uint8_t gVFO_RSSI_bar_level[2];
uint8_t gReducedService; uint8_t gReducedService;
uint8_t gBatteryVoltageIndex; uint8_t gBatteryVoltageIndex;
CssScanMode_t gCssScanMode; bool gCssBackgroundScan;
volatile bool gScheduleScanListen = true; volatile bool gScheduleScanListen = true;
volatile uint16_t gScanPauseDelayIn_10ms; volatile uint16_t gScanPauseDelayIn_10ms;

13
misc.h
View File

@ -75,14 +75,6 @@ enum ReceptionMode_t {
}; };
typedef enum ReceptionMode_t ReceptionMode_t; typedef enum ReceptionMode_t ReceptionMode_t;
enum CssScanMode_t
{
CSS_SCAN_MODE_OFF = 0,
CSS_SCAN_MODE_SCANNING,
CSS_SCAN_MODE_FOUND,
};
typedef enum CssScanMode_t CssScanMode_t;
enum BacklightOnRxTx_t { enum BacklightOnRxTx_t {
BACKLIGHT_ON_TR_OFF, BACKLIGHT_ON_TR_OFF,
BACKLIGHT_ON_TR_TX, BACKLIGHT_ON_TR_TX,
@ -229,9 +221,8 @@ extern uint8_t gVFO_RSSI_bar_level[2];
extern uint8_t gReducedService; extern uint8_t gReducedService;
extern uint8_t gBatteryVoltageIndex; extern uint8_t gBatteryVoltageIndex;
// if not equal CSS_SCAN_MODE_OFF we are scanning CTCSS/DCS // we are searching CTCSS/DCS inside RX ctcss/dcs menu
// this is a scanning inside RX ctcss/dcs menu extern bool gCssBackgroundScan;
extern CssScanMode_t gCssScanMode;
enum enum

11
radio.c
View File

@ -38,9 +38,7 @@
VFO_Info_t *gTxVfo; VFO_Info_t *gTxVfo;
VFO_Info_t *gRxVfo; VFO_Info_t *gRxVfo;
VFO_Info_t *gCurrentVfo; VFO_Info_t *gCurrentVfo;
DCS_CodeType_t gSelectedCodeType;
DCS_CodeType_t gCurrentCodeType; DCS_CodeType_t gCurrentCodeType;
uint8_t gSelectedCode;
VfoState_t VfoState[2]; VfoState_t VfoState[2];
const char gModulationStr[][4] = const char gModulationStr[][4] =
@ -681,13 +679,8 @@ void RADIO_SetupRegisters(bool switchToForeground)
{ {
if (gRxVfo->Modulation == MODULATION_FM) if (gRxVfo->Modulation == MODULATION_FM)
{ // FM { // FM
uint8_t CodeType = gSelectedCodeType; uint8_t CodeType = gRxVfo->pRX->CodeType;
uint8_t Code = gSelectedCode; uint8_t Code = gRxVfo->pRX->Code;
if (gCssScanMode == CSS_SCAN_MODE_OFF)
{
CodeType = gRxVfo->pRX->CodeType;
Code = gRxVfo->pRX->Code;
}
switch (CodeType) switch (CodeType)
{ {

View File

@ -149,9 +149,7 @@ extern VFO_Info_t *gRxVfo;
// Equal to gTxVfo unless dual watch changes it on incomming transmition (this can only happen when XB off and DW on) // Equal to gTxVfo unless dual watch changes it on incomming transmition (this can only happen when XB off and DW on)
extern VFO_Info_t *gCurrentVfo; extern VFO_Info_t *gCurrentVfo;
extern DCS_CodeType_t gSelectedCodeType;
extern DCS_CodeType_t gCurrentCodeType; extern DCS_CodeType_t gCurrentCodeType;
extern uint8_t gSelectedCode;
extern VfoState_t VfoState[2]; extern VfoState_t VfoState[2];

View File

@ -78,18 +78,18 @@ void SystickHandler(void)
if (gCurrentFunction == FUNCTION_POWER_SAVE) if (gCurrentFunction == FUNCTION_POWER_SAVE)
DECREMENT_AND_TRIGGER(gPowerSave_10ms, gPowerSaveCountdownExpired); DECREMENT_AND_TRIGGER(gPowerSave_10ms, gPowerSaveCountdownExpired);
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) if (gScanStateDir == SCAN_OFF && !gCssBackgroundScan && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE) if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch); DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) if (gScanStateDir == SCAN_OFF && !gCssBackgroundScan && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
if (gCurrentFunction != FUNCTION_RECEIVE) if (gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA); DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA);
#endif #endif
if (gScanStateDir != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING) if (gScanStateDir != SCAN_OFF)
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen); DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen);

View File

@ -367,13 +367,21 @@ const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(SIDEFUNCTIONS);
bool gIsInSubMenu; bool gIsInSubMenu;
uint8_t gMenuCursor; uint8_t gMenuCursor;
int GetCurrentMenuId() { int UI_MENU_GetCurrentMenuId() {
if(gMenuCursor < ARRAY_SIZE(MenuList)) if(gMenuCursor < ARRAY_SIZE(MenuList))
return MenuList[gMenuCursor].menu_id; return MenuList[gMenuCursor].menu_id;
else else
return MenuList[ARRAY_SIZE(MenuList)-1].menu_id; return MenuList[ARRAY_SIZE(MenuList)-1].menu_id;
} }
int8_t gMenuScrollDirection;
uint8_t UI_MENU_GetMenuIdx(uint8_t id)
{
for(uint8_t i = 0; i < ARRAY_SIZE(MenuList); i++)
if(MenuList[i].menu_id == id)
return i;
return 0;
}
int32_t gSubMenuSelection; int32_t gSubMenuSelection;
// edit box // edit box
@ -476,7 +484,7 @@ void UI_DisplayMenu(void)
bool already_printed = false; bool already_printed = false;
switch (GetCurrentMenuId()) switch (UI_MENU_GetCurrentMenuId())
{ {
case MENU_SQL: case MENU_SQL:
sprintf(String, "%d", gSubMenuSelection); sprintf(String, "%d", gSubMenuSelection);
@ -884,9 +892,9 @@ void UI_DisplayMenu(void)
} }
} }
if (GetCurrentMenuId() == MENU_SLIST1 || GetCurrentMenuId() == MENU_SLIST2) if (UI_MENU_GetCurrentMenuId() == MENU_SLIST1 || UI_MENU_GetCurrentMenuId() == MENU_SLIST2)
{ {
i = (GetCurrentMenuId() == MENU_SLIST1) ? 0 : 1; i = (UI_MENU_GetCurrentMenuId() == MENU_SLIST1) ? 0 : 1;
// if (gSubMenuSelection == 0xFF) // if (gSubMenuSelection == 0xFF)
if (gSubMenuSelection < 0) if (gSubMenuSelection < 0)
@ -931,9 +939,9 @@ void UI_DisplayMenu(void)
} }
} }
if (GetCurrentMenuId() == MENU_MEM_CH || if (UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_DEL_CH ||
GetCurrentMenuId() == MENU_1_CALL) UI_MENU_GetCurrentMenuId() == MENU_1_CALL)
{ // display the channel name { // display the channel name
char s[11]; char s[11];
BOARD_fetchChannelName(s, gSubMenuSelection); BOARD_fetchChannelName(s, gSubMenuSelection);
@ -942,18 +950,19 @@ void UI_DisplayMenu(void)
UI_PrintString(s, menu_item_x1, menu_item_x2, 2, 8); UI_PrintString(s, menu_item_x1, menu_item_x2, 2, 8);
} }
if ((GetCurrentMenuId() == MENU_R_CTCS || GetCurrentMenuId() == MENU_R_DCS) && gCssScanMode != CSS_SCAN_MODE_OFF) if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gCssBackgroundScan)
UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8); UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8);
if (GetCurrentMenuId() == MENU_UPCODE) if (UI_MENU_GetCurrentMenuId() == MENU_UPCODE)
if (strlen(gEeprom.DTMF_UP_CODE) > 8) if (strlen(gEeprom.DTMF_UP_CODE) > 8)
UI_PrintString(gEeprom.DTMF_UP_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(gEeprom.DTMF_UP_CODE + 8, menu_item_x1, menu_item_x2, 4, 8);
if (GetCurrentMenuId() == MENU_DWCODE) if (UI_MENU_GetCurrentMenuId() == MENU_DWCODE)
if (strlen(gEeprom.DTMF_DOWN_CODE) > 8) if (strlen(gEeprom.DTMF_DOWN_CODE) > 8)
UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8);
if (GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid) if (UI_MENU_GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid)
{ {
Contact[11] = 0; Contact[11] = 0;
memmove(&gDTMF_ID, Contact + 8, 4); memmove(&gDTMF_ID, Contact + 8, 4);
@ -961,20 +970,20 @@ void UI_DisplayMenu(void)
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
} }
if (GetCurrentMenuId() == MENU_R_CTCS || if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS ||
GetCurrentMenuId() == MENU_T_CTCS || UI_MENU_GetCurrentMenuId() == MENU_T_CTCS ||
GetCurrentMenuId() == MENU_R_DCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS ||
GetCurrentMenuId() == MENU_T_DCS || UI_MENU_GetCurrentMenuId() == MENU_T_DCS ||
GetCurrentMenuId() == MENU_D_LIST) UI_MENU_GetCurrentMenuId() == MENU_D_LIST)
{ {
sprintf(String, "%2d", gSubMenuSelection); sprintf(String, "%2d", gSubMenuSelection);
UI_PrintStringSmall(String, 105, 0, 0); UI_PrintStringSmall(String, 105, 0, 0);
} }
if ((GetCurrentMenuId() == MENU_RESET || if ((UI_MENU_GetCurrentMenuId() == MENU_RESET ||
GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
GetCurrentMenuId() == MENU_MEM_NAME || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME ||
GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation) UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation)
{ // display confirmation { // display confirmation
strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!"); strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!");
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);

View File

@ -165,8 +165,7 @@ extern const t_sidefunction* gSubMenu_SIDEFUNCTIONS;
extern bool gIsInSubMenu; extern bool gIsInSubMenu;
extern uint8_t gMenuCursor; extern uint8_t gMenuCursor;
int GetCurrentMenuId();
extern int8_t gMenuScrollDirection;
extern int32_t gSubMenuSelection; extern int32_t gSubMenuSelection;
extern char edit_original[17]; extern char edit_original[17];
@ -174,5 +173,7 @@ extern char edit[17];
extern int edit_index; extern int edit_index;
void UI_DisplayMenu(void); void UI_DisplayMenu(void);
int UI_MENU_GetCurrentMenuId();
uint8_t UI_MENU_GetMenuIdx(uint8_t id);
#endif #endif

View File

@ -20,6 +20,7 @@
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/scanner.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "driver/keyboard.h" #include "driver/keyboard.h"
#include "driver/st7565.h" #include "driver/st7565.h"
@ -86,10 +87,10 @@ void UI_DisplayStatus()
} }
else else
// SCAN indicator // SCAN indicator
if (gScanStateDir != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER) if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning())
{ {
char * s = ""; char * s = "";
if (IS_MR_CHANNEL(gNextMrChannel) && gScreenToDisplay != DISPLAY_SCANNER) if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning())
{ // channel mode { // channel mode
switch(gEeprom.SCAN_LIST_DEFAULT) { switch(gEeprom.SCAN_LIST_DEFAULT) {
case 0: s = "1"; break; case 0: s = "1"; break;
@ -119,7 +120,7 @@ void UI_DisplayStatus()
#endif #endif
x++; x++;
if(gScreenToDisplay != DISPLAY_SCANNER) { if(!SCANNER_IsScanning()) {
uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2; uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2;
if(dw == 1 || dw == 3) { // DWR - dual watch + respond if(dw == 1 || dw == 3) { // DWR - dual watch + respond
if(gDualWatchActive) if(gDualWatchActive)

View File

@ -86,7 +86,7 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
gInputBoxIndex = 0; gInputBoxIndex = 0;
gIsInSubMenu = false; gIsInSubMenu = false;
gCssScanMode = CSS_SCAN_MODE_OFF; gCssBackgroundScan = false;
gScanStateDir = SCAN_OFF; gScanStateDir = SCAN_OFF;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
gFM_ScanState = FM_SCAN_OFF; gFM_ScanState = FM_SCAN_OFF;