Refactoring

This commit is contained in:
Krzysiek Egzmont
2023-10-17 01:31:08 +02:00
parent 298ff29cf4
commit 0c0cbb232c
5 changed files with 156 additions and 157 deletions

View File

@@ -22,7 +22,7 @@
//static void ACTION_FlashLight(void)
void ACTION_Power(void);
void ACTION_Monitor(void);
void ACTION_Scan(bool bFlag);
void ACTION_Scan(bool bRestart);
#ifdef ENABLE_VOX
void ACTION_Vox(void);
#endif

View File

@@ -943,38 +943,38 @@ void APP_Update(void)
if (gCurrentFunction != FUNCTION_TRANSMIT)
APP_HandleFunction();
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
// if (gFmRadioCountdown_500ms > 0)
if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11
return;
#endif
#endif
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0)
#else
#else
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed)
#endif
#endif
{ // scanning
SCANNER_ContinueScanning();
}
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && gVoiceWriteIndex == 0)
#else
#else
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen)
#endif
#endif
{
MENU_SelectNextCode();
gScheduleScanListen = false;
}
#ifdef ENABLE_NOAA
#ifdef ENABLE_VOICE
#ifdef ENABLE_NOAA
#ifdef ENABLE_VOICE
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0)
#else
#else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA)
#endif
#endif
{
NOAA_IncreaseChannel();
RADIO_SetupRegisters(false);
@@ -982,23 +982,23 @@ void APP_Update(void)
gNOAA_Countdown_10ms = 7; // 70ms
gScheduleNOAA = false;
}
#endif
#endif
// toggle between the VFO's if dual watch is enabled
if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
if (gScheduleDualWatch && gVoiceWriteIndex == 0)
#else
#else
if (gScheduleDualWatch)
#endif
#endif
{
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
{
if (!gPttIsPressed &&
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
#endif
gDTMF_CallState == DTMF_CALL_STATE_NONE &&
gCurrentFunction != FUNCTION_POWER_SAVE)
{
@@ -1016,7 +1016,7 @@ void APP_Update(void)
}
}
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
if (gScheduleFM &&
gFM_ScanState != FM_SCAN_OFF &&
gCurrentFunction != FUNCTION_MONITOR &&
@@ -1026,20 +1026,20 @@ void APP_Update(void)
FM_Play();
gScheduleFM = false;
}
#endif
#endif
#ifdef ENABLE_VOX
#ifdef ENABLE_VOX
if (gEeprom.VOX_SWITCH)
APP_HandleVox();
#endif
#endif
if (gSchedulePowerSave)
{
#ifdef ENABLE_NOAA
#ifdef ENABLE_NOAA
if (
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
gFmRadioMode ||
#endif
#endif
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
@@ -1059,11 +1059,11 @@ void APP_Update(void)
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
}
#else
#else
if (
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
gFmRadioMode ||
#endif
#endif
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
@@ -1081,24 +1081,24 @@ void APP_Update(void)
}
gSchedulePowerSave = false;
#endif
#endif
}
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0)
#else
#else
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE)
#endif
#endif
{ // wake up, enable RX then go back to sleep
if (gRxIdleMode)
{
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
#ifdef ENABLE_VOX
#ifdef ENABLE_VOX
if (gEeprom.VOX_SWITCH)
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
#endif
#endif
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF &&
gScanStateDir == SCAN_OFF &&

View File

@@ -202,7 +202,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
case KEY_5:
if(beep) {
#ifdef ENABLE_NOAA
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
@@ -211,9 +211,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
else
{
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif
#endif
}
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@@ -223,9 +223,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#endif
}
else {
#ifdef ENABLE_VOX
#ifdef ENABLE_VOX
toggle_chan_scanlist();
#endif
#endif
}
break;
@@ -235,11 +235,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break;
case KEY_7:
#ifdef ENABLE_VOX
#ifdef ENABLE_VOX
ACTION_Vox();
#else
#else
toggle_chan_scanlist();
#endif
#endif
break;
case KEY_8:
@@ -252,11 +252,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
{
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, gEeprom.CHAN_1_CALL + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
#endif
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break;
@@ -647,28 +647,28 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return;
}
if (bKeyHeld && !gWasFKeyPressed)
{ // long press .. toggle scanning
if (!bKeyPressed)
return; // released
if (bKeyHeld && !gWasFKeyPressed) // long press
{
if (!bKeyPressed) // released
return;
ACTION_Scan(false);
ACTION_Scan(false);// toggle scanning
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
if (bKeyPressed)
{ // just pressed
// gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (bKeyPressed) // just pressed
{
// gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL;
return;
}
// just released
if (!gWasFKeyPressed)
{ // pressed without the F-key
if (!gWasFKeyPressed) // pressed without the F-key
{
#ifdef ENABLE_NOAA
if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))

19
main.c
View File

@@ -167,21 +167,21 @@ void Main(void)
boot_counter_10ms = 0;
break;
}
#ifdef ENABLE_BOOT_BEEPS
#ifdef ENABLE_BOOT_BEEPS
if ((boot_counter_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif
#endif
}
}
#ifdef ENABLE_PWRON_PASSWORD
#ifdef ENABLE_PWRON_PASSWORD
if (gEeprom.POWER_ON_PASSWORD < 1000000)
{
bIsInLockScreen = true;
UI_DisplayLock();
bIsInLockScreen = false;
}
#endif
#endif
BOOT_ProcessMode(BootMode);
@@ -189,7 +189,7 @@ void Main(void)
gUpdateStatus = true;
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
{
uint8_t Channel;
@@ -201,17 +201,16 @@ void Main(void)
AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(2, Channel + 1);
}
else
if (IS_FREQ_CHANNEL(Channel))
else if (IS_FREQ_CHANNEL(Channel))
AUDIO_SetVoiceID(1, VOICE_ID_FREQUENCY_MODE);
AUDIO_PlaySingleVoice(0);
}
#endif
#endif
#ifdef ENABLE_NOAA
#ifdef ENABLE_NOAA
RADIO_ConfigureNOAA();
#endif
#endif
// ******************
}

View File

@@ -161,7 +161,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
if (IS_VALID_CHANNEL(Channel))
{
#ifdef ENABLE_NOAA
#ifdef ENABLE_NOAA
if (Channel >= NOAA_CHANNEL_FIRST)
{
RADIO_InitInfo(pRadio, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[Channel - NOAA_CHANNEL_FIRST]);
@@ -174,7 +174,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
gUpdateStatus = true;
return;
}
#endif
#endif
if (Channel <= MR_CHANNEL_LAST)
{