This commit is contained in:
Krzysiek Egzmont
2024-01-28 23:57:15 +01:00
parent 604a5b430f
commit f85ed9440d
6 changed files with 109 additions and 153 deletions

View File

@@ -750,21 +750,19 @@ static void HandleVox(void)
return; return;
#endif #endif
if (gVoxResumeCountdown == 0) if (gVoxResumeCountdown == 0) {
{
if (gVoxPauseCountdown) if (gVoxPauseCountdown)
return; return;
} }
else else {
{
g_VOX_Lost = false; g_VOX_Lost = false;
gVoxPauseCountdown = 0; gVoxPauseCountdown = 0;
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode) if (gFmRadioMode)
return; return;
#endif #endif
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
return; return;
@@ -772,31 +770,26 @@ static void HandleVox(void)
if (gScanStateDir != SCAN_OFF) if (gScanStateDir != SCAN_OFF)
return; return;
if (gVOX_NoiseDetected) if (gVOX_NoiseDetected) {
{
if (g_VOX_Lost) if (g_VOX_Lost)
gVoxStopCountdown_10ms = vox_stop_count_down_10ms; gVoxStopCountdown_10ms = vox_stop_count_down_10ms;
else if (gVoxStopCountdown_10ms == 0) else if (gVoxStopCountdown_10ms == 0)
gVOX_NoiseDetected = false; gVOX_NoiseDetected = false;
if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) {
{ if (gFlagEndTransmission) {
if (gFlagEndTransmission)
{
//if (gCurrentFunction != FUNCTION_FOREGROUND) //if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
} }
else else {
{
APP_EndTransmission(); APP_EndTransmission();
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) {
{
//if (gCurrentFunction != FUNCTION_FOREGROUND) //if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
} }
else else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
} }
gUpdateStatus = true; gUpdateStatus = true;
@@ -806,15 +799,13 @@ static void HandleVox(void)
return; return;
} }
if (g_VOX_Lost) if (g_VOX_Lost) {
{
gVOX_NoiseDetected = true; gVOX_NoiseDetected = true;
if (gCurrentFunction == FUNCTION_POWER_SAVE) if (gCurrentFunction == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
if (gCurrentFunction != FUNCTION_TRANSMIT && !SerialConfigInProgress()) if (gCurrentFunction != FUNCTION_TRANSMIT && !SerialConfigInProgress()) {
{
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
#endif #endif
@@ -1156,8 +1147,7 @@ void APP_TimeSlice10ms(void)
#endif #endif
} }
if (gUpdateDisplay) if (gUpdateDisplay) {
{
gUpdateDisplay = false; gUpdateDisplay = false;
GUI_DisplayScreen(); GUI_DisplayScreen();
} }
@@ -1184,31 +1174,26 @@ void APP_TimeSlice10ms(void)
gVoxPauseCountdown--; gVoxPauseCountdown--;
#endif #endif
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT) {
{ #ifdef ENABLE_ALARM
#ifdef ENABLE_ALARM if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_SITE_ALARM) {
if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_SITE_ALARM)
{
uint16_t Tone; uint16_t Tone;
gAlarmRunningCounter++; gAlarmRunningCounter++;
gAlarmToneCounter++; gAlarmToneCounter++;
Tone = 500 + (gAlarmToneCounter * 25); Tone = 500 + (gAlarmToneCounter * 25);
if (Tone > 1500) if (Tone > 1500) {
{
Tone = 500; Tone = 500;
gAlarmToneCounter = 0; gAlarmToneCounter = 0;
} }
BK4819_SetScrambleFrequencyControlWord(Tone); BK4819_SetScrambleFrequencyControlWord(Tone);
if (gEeprom.ALARM_MODE == ALARM_MODE_TONE && gAlarmRunningCounter == 512) if (gEeprom.ALARM_MODE == ALARM_MODE_TONE && gAlarmRunningCounter == 512) {
{
gAlarmRunningCounter = 0; gAlarmRunningCounter = 0;
if (gAlarmState == ALARM_STATE_TXALARM) if (gAlarmState == ALARM_STATE_TXALARM) {
{
gAlarmState = ALARM_STATE_SITE_ALARM; gAlarmState = ALARM_STATE_SITE_ALARM;
RADIO_EnableCxCSS(); RADIO_EnableCxCSS();
@@ -1219,8 +1204,7 @@ void APP_TimeSlice10ms(void)
GUI_DisplayScreen(); GUI_DisplayScreen();
} }
else else {
{
gAlarmState = ALARM_STATE_TXALARM; gAlarmState = ALARM_STATE_TXALARM;
GUI_DisplayScreen(); GUI_DisplayScreen();
@@ -1236,13 +1220,10 @@ void APP_TimeSlice10ms(void)
} }
} }
} }
#endif #endif
// repeater tail tone elimination // repeater tail tone elimination
if (gRTTECountdown > 0) if (gRTTECountdown_10ms > 0) {
{ if (--gRTTECountdown_10ms == 0) {
if (--gRTTECountdown == 0)
{
//if (gCurrentFunction != FUNCTION_FOREGROUND) //if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
@@ -1253,11 +1234,9 @@ void APP_TimeSlice10ms(void)
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode && gFM_RestoreCountdown_10ms > 0) if (gFmRadioMode && gFM_RestoreCountdown_10ms > 0) {
{ if (--gFM_RestoreCountdown_10ms == 0) {
if (--gFM_RestoreCountdown_10ms == 0) FM_Start(); // switch back to FM radio mode
{ // switch back to FM radio mode
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM); GUI_SelectNextDisplay(DISPLAY_FM);
} }
} }
@@ -1267,8 +1246,7 @@ void APP_TimeSlice10ms(void)
SCANNER_TimeSlice10ms(); SCANNER_TimeSlice10ms();
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1) if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1) {
{
if (!AIRCOPY_SendMessage()) { if (!AIRCOPY_SendMessage()) {
GUI_DisplayScreen(); GUI_DisplayScreen();
} }
@@ -1780,7 +1758,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
else else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
if (Key == KEY_PTT) if (Key == KEY_PTT)
gPttWasPressed = true; gPttWasPressed = true;

View File

@@ -89,8 +89,7 @@ void DTMF_SendEndOfTransmission(void)
&& gDTMF_CallState == DTMF_CALL_STATE_NONE && gDTMF_CallState == DTMF_CALL_STATE_NONE
#endif #endif
) { // end-of-tx ) { // end-of-tx
if (gEeprom.DTMF_SIDE_TONE) if (gEeprom.DTMF_SIDE_TONE) {
{
AUDIO_AudioPathOn(); AUDIO_AudioPathOn();
gEnableSpeaker = true; gEnableSpeaker = true;
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);

View File

@@ -39,17 +39,14 @@
void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld) void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
{ {
if (gInputBoxIndex > 0) if (gInputBoxIndex > 0) {
{
if (!bKeyHeld && bKeyPressed) // short pressed if (!bKeyHeld && bKeyPressed) // short pressed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
if (bKeyHeld || !bKeyPressed) // held or released if (bKeyHeld || !bKeyPressed) { // held or released
{ if (bKeyHeld || bKeyPressed) { // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
if (bKeyHeld || bKeyPressed) // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
{
if (!bKeyHeld) // won't ever pass if (!bKeyHeld) // won't ever pass
return; return;
@@ -58,31 +55,28 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
COMMON_KeypadLockToggle(); COMMON_KeypadLockToggle();
} }
else // released else { // released
{ #ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM) if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
return; return;
#else #else
if (gScreenToDisplay != DISPLAY_MAIN) if (gScreenToDisplay != DISPLAY_MAIN)
return; return;
#endif #endif
gWasFKeyPressed = !gWasFKeyPressed; // toggle F function gWasFKeyPressed = !gWasFKeyPressed; // toggle F function
if (gWasFKeyPressed) if (gWasFKeyPressed)
gKeyInputCountdown = key_input_timeout_500ms; gKeyInputCountdown = key_input_timeout_500ms;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (!gWasFKeyPressed) if (!gWasFKeyPressed)
gAnotherVoiceID = VOICE_ID_CANCEL; gAnotherVoiceID = VOICE_ID_CANCEL;
#endif #endif
gUpdateStatus = true; gUpdateStatus = true;
} }
} }
else // short pressed else { // short pressed
{
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gScreenToDisplay != DISPLAY_FM) if (gScreenToDisplay != DISPLAY_FM)
#endif #endif
@@ -91,16 +85,13 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
return; return;
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFM_ScanState == FM_SCAN_OFF) // not scanning if (gFM_ScanState == FM_SCAN_OFF) { // not scanning
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
} }
#endif #endif
gBeepToPlay = BEEP_440HZ_500MS; gBeepToPlay = BEEP_440HZ_500MS;
gPttWasReleased = true; gPttWasReleased = true;
} }
} }
@@ -111,29 +102,24 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (!bKeyPressed || SerialConfigInProgress()) if (!bKeyPressed || SerialConfigInProgress())
{ // PTT released { // PTT released
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT) {
{ // we are transmitting .. stop // we are transmitting .. stop
if (gFlagEndTransmission) {
if (gFlagEndTransmission)
{
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
} }
else else {
{
APP_EndTransmission(); APP_EndTransmission();
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
else else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
} }
gFlagEndTransmission = false; gFlagEndTransmission = false;
#ifdef ENABLE_VOX
#ifdef ENABLE_VOX
gVOX_NoiseDetected = false; gVOX_NoiseDetected = false;
#endif #endif
RADIO_SetVfoState(VFO_STATE_NORMAL); RADIO_SetVfoState(VFO_STATE_NORMAL);
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu
@@ -146,27 +132,24 @@ void GENERIC_Key_PTT(bool bKeyPressed)
// PTT pressed // PTT pressed
if (SCANNER_IsScanning()) if (SCANNER_IsScanning()) {
{ // CTCSS/CDCSS scanning .. stop SCANNER_Stop(); // CTCSS/CDCSS scanning .. stop
SCANNER_Stop();
goto cancel_tx; goto cancel_tx;
} }
if (gScanStateDir != SCAN_OFF) if (gScanStateDir != SCAN_OFF) {
{ // frequency/channel scanning . .stop CHFRSCANNER_Stop(); // frequency/channel scanning . .stop
CHFRSCANNER_Stop();
goto cancel_tx; 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
FM_PlayAndUpdate(); FM_PlayAndUpdate();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif #endif
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx; goto cancel_tx;
} }
@@ -177,8 +160,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
goto start_tx; // listening to the FM radio .. start TX'ing goto start_tx; // listening to the FM radio .. start TX'ing
#endif #endif
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0) if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown_10ms == 0) {// already transmitting
{ // already transmitting
gInputBoxIndex = 0; gInputBoxIndex = 0;
return; return;
} }
@@ -192,9 +174,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
// was entering a DTMF string // was entering a DTMF string
if (gDTMF_InputBox_Index > 0 || gDTMF_PreviousIndex > 0) if (gDTMF_InputBox_Index > 0 || gDTMF_PreviousIndex > 0) { // going to transmit a DTMF string
{ // going to transmit a DTMF string
if (gDTMF_InputBox_Index == 0 && gDTMF_PreviousIndex > 0) if (gDTMF_InputBox_Index == 0 && gDTMF_PreviousIndex > 0)
gDTMF_InputBox_Index = gDTMF_PreviousIndex; // use the previous DTMF string gDTMF_InputBox_Index = gDTMF_PreviousIndex; // use the previous DTMF string
@@ -225,8 +205,7 @@ start_tx:
goto done; goto done;
cancel_tx: cancel_tx:
if (gPttIsPressed) if (gPttIsPressed) {
{
gPttWasPressed = true; gPttWasPressed = true;
} }

2
misc.c
View File

@@ -143,7 +143,7 @@ volatile uint8_t gVFOStateResumeCountdown_500ms;
bool gEnableSpeaker; bool gEnableSpeaker;
uint8_t gKeyInputCountdown = 0; uint8_t gKeyInputCountdown = 0;
uint8_t gKeyLockCountdown; uint8_t gKeyLockCountdown;
uint8_t gRTTECountdown; uint8_t gRTTECountdown_10ms;
bool bIsInLockScreen; bool bIsInLockScreen;
uint8_t gUpdateStatus; uint8_t gUpdateStatus;
uint8_t gFoundCTCSS; uint8_t gFoundCTCSS;

2
misc.h
View File

@@ -213,7 +213,7 @@ extern volatile uint16_t gTailNoteEliminationCountdown_10ms;
extern bool gEnableSpeaker; extern bool gEnableSpeaker;
extern uint8_t gKeyInputCountdown; extern uint8_t gKeyInputCountdown;
extern uint8_t gKeyLockCountdown; extern uint8_t gKeyLockCountdown;
extern uint8_t gRTTECountdown; extern uint8_t gRTTECountdown_10ms;
extern bool bIsInLockScreen; extern bool bIsInLockScreen;
extern uint8_t gUpdateStatus; extern uint8_t gUpdateStatus;
extern uint8_t gFoundCTCSS; extern uint8_t gFoundCTCSS;

View File

@@ -1002,7 +1002,7 @@ void RADIO_PrepareTX(void)
gTxTimeoutReached = false; gTxTimeoutReached = false;
gFlagEndTransmission = false; gFlagEndTransmission = false;
gRTTECountdown = 0; gRTTECountdown_10ms = 0;
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;