Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Jan 28, 2024
1 parent 604a5b4 commit f85ed94
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 146 deletions.
136 changes: 57 additions & 79 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,53 +750,46 @@ static void HandleVox(void)
return;
#endif

if (gVoxResumeCountdown == 0)
{
if (gVoxResumeCountdown == 0) {
if (gVoxPauseCountdown)
return;
}
else
{
else {
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}

#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
return;
#endif
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
return;
#endif

if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
return;

if (gScanStateDir != SCAN_OFF)
return;

if (gVOX_NoiseDetected)
{
if (gVOX_NoiseDetected) {
if (g_VOX_Lost)
gVoxStopCountdown_10ms = vox_stop_count_down_10ms;
else if (gVoxStopCountdown_10ms == 0)
gVOX_NoiseDetected = false;

if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected)
{
if (gFlagEndTransmission)
{
if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) {
if (gFlagEndTransmission) {
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else
{
else {
APP_EndTransmission();

if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
{
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) {
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
}

gUpdateStatus = true;
Expand All @@ -806,15 +799,13 @@ static void HandleVox(void)
return;
}

if (g_VOX_Lost)
{
if (g_VOX_Lost) {
gVOX_NoiseDetected = true;

if (gCurrentFunction == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_FOREGROUND);

if (gCurrentFunction != FUNCTION_TRANSMIT && !SerialConfigInProgress())
{
if (gCurrentFunction != FUNCTION_TRANSMIT && !SerialConfigInProgress()) {
#ifdef ENABLE_DTMF_CALLING
gDTMF_ReplyState = DTMF_REPLY_NONE;
#endif
Expand Down Expand Up @@ -1156,8 +1147,7 @@ void APP_TimeSlice10ms(void)
#endif
}

if (gUpdateDisplay)
{
if (gUpdateDisplay) {
gUpdateDisplay = false;
GUI_DisplayScreen();
}
Expand All @@ -1184,65 +1174,56 @@ void APP_TimeSlice10ms(void)
gVoxPauseCountdown--;
#endif

if (gCurrentFunction == FUNCTION_TRANSMIT)
{
#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_SITE_ALARM)
{
uint16_t Tone;
if (gCurrentFunction == FUNCTION_TRANSMIT) {
#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_SITE_ALARM) {
uint16_t Tone;

gAlarmRunningCounter++;
gAlarmToneCounter++;
gAlarmRunningCounter++;
gAlarmToneCounter++;

Tone = 500 + (gAlarmToneCounter * 25);
if (Tone > 1500)
{
Tone = 500;
gAlarmToneCounter = 0;
}
Tone = 500 + (gAlarmToneCounter * 25);
if (Tone > 1500) {
Tone = 500;
gAlarmToneCounter = 0;
}

BK4819_SetScrambleFrequencyControlWord(Tone);
BK4819_SetScrambleFrequencyControlWord(Tone);

if (gEeprom.ALARM_MODE == ALARM_MODE_TONE && gAlarmRunningCounter == 512)
{
gAlarmRunningCounter = 0;
if (gEeprom.ALARM_MODE == ALARM_MODE_TONE && gAlarmRunningCounter == 512) {
gAlarmRunningCounter = 0;

if (gAlarmState == ALARM_STATE_TXALARM)
{
gAlarmState = ALARM_STATE_SITE_ALARM;
if (gAlarmState == ALARM_STATE_TXALARM) {
gAlarmState = ALARM_STATE_SITE_ALARM;

RADIO_EnableCxCSS();
BK4819_SetupPowerAmplifier(0, 0);
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false);
BK4819_Enable_AfDac_DiscMode_TxDsp();
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
RADIO_EnableCxCSS();
BK4819_SetupPowerAmplifier(0, 0);
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false);
BK4819_Enable_AfDac_DiscMode_TxDsp();
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);

GUI_DisplayScreen();
}
else
{
gAlarmState = ALARM_STATE_TXALARM;
GUI_DisplayScreen();
}
else {
gAlarmState = ALARM_STATE_TXALARM;

GUI_DisplayScreen();
GUI_DisplayScreen();

BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
RADIO_SetTxParameters();
BK4819_TransmitTone(true, 500);
SYSTEM_DelayMs(2);
AUDIO_AudioPathOn();
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
RADIO_SetTxParameters();
BK4819_TransmitTone(true, 500);
SYSTEM_DelayMs(2);
AUDIO_AudioPathOn();

gEnableSpeaker = true;
gAlarmToneCounter = 0;
}
gEnableSpeaker = true;
gAlarmToneCounter = 0;
}
}
#endif

}
#endif
// repeater tail tone elimination
if (gRTTECountdown > 0)
{
if (--gRTTECountdown == 0)
{
if (gRTTECountdown_10ms > 0) {
if (--gRTTECountdown_10ms == 0) {
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);

Expand All @@ -1253,11 +1234,9 @@ void APP_TimeSlice10ms(void)
}

#ifdef ENABLE_FMRADIO
if (gFmRadioMode && gFM_RestoreCountdown_10ms > 0)
{
if (--gFM_RestoreCountdown_10ms == 0)
{ // switch back to FM radio mode
FM_Start();
if (gFmRadioMode && gFM_RestoreCountdown_10ms > 0) {
if (--gFM_RestoreCountdown_10ms == 0) {
FM_Start(); // switch back to FM radio mode
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
Expand All @@ -1267,8 +1246,7 @@ void APP_TimeSlice10ms(void)
SCANNER_TimeSlice10ms();

#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1)
{
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1) {
if (!AIRCOPY_SendMessage()) {
GUI_DisplayScreen();
}
Expand Down Expand Up @@ -1780,7 +1758,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
FUNCTION_Select(FUNCTION_FOREGROUND);
else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;

if (Key == KEY_PTT)
gPttWasPressed = true;
Expand Down
3 changes: 1 addition & 2 deletions app/dtmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ void DTMF_SendEndOfTransmission(void)
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
#endif
) { // end-of-tx
if (gEeprom.DTMF_SIDE_TONE)
{
if (gEeprom.DTMF_SIDE_TONE) {
AUDIO_AudioPathOn();
gEnableSpeaker = true;
SYSTEM_DelayMs(60);
Expand Down
Loading

0 comments on commit f85ed94

Please sign in to comment.