Skip to content

Commit

Permalink
Fix kamilsss655#25: When you stop the scan with the PTT the Walkie st…
Browse files Browse the repository at this point in the history
…ays in permanent TX
  • Loading branch information
egzumer committed Oct 10, 2023
1 parent 8307578 commit a6ef758
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 49 deletions.
45 changes: 22 additions & 23 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,14 +1290,15 @@ void APP_CheckKeys(void)
{
KEY_Code_t Key;

#ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
return;
#else
if (gSetting_KILLED)
return;
#endif
#ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
return;
#else
if (gSetting_KILLED)
return;
#endif

// -------------------- PTT ------------------------
if (gPttIsPressed)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0)
Expand All @@ -1313,8 +1314,7 @@ void APP_CheckKeys(void)
else
gPttDebounceCounter = 0;
}
else
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
{ // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
Expand Down Expand Up @@ -2226,8 +2226,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
}
else
if (gPttWasReleased)
else if (gPttWasReleased)
{
if (bKeyHeld)
bFlag = true;
Expand All @@ -2249,9 +2248,9 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting

#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF)
#endif
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF)
#endif
{
char Code;

Expand Down Expand Up @@ -2306,7 +2305,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
}
}
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
else
if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed))
{
Expand All @@ -2323,14 +2322,15 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (!bKeyHeld)
gPttWasReleased = true;
}
#endif
#endif
}
else
if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
{
switch (gScreenToDisplay)
{
case DISPLAY_MAIN:

MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
// bKeyHeld = false; // allow the channel setting to be saved
break;
Expand Down Expand Up @@ -2361,16 +2361,15 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
else
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY)
#else
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY)
#else
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
{
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
}
else
if (!bKeyHeld && bKeyPressed)
else if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
}

Expand Down
50 changes: 24 additions & 26 deletions app/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
{
if (gInputBoxIndex > 0)
{
if (!bKeyHeld && bKeyPressed)
if (!bKeyHeld && bKeyPressed) // short pressed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}

if (bKeyHeld || !bKeyPressed)
if (bKeyHeld || !bKeyPressed) // held or released
{
if (bKeyHeld || bKeyPressed)
if (bKeyHeld || bKeyPressed) // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
{
if (!bKeyHeld)
if (!bKeyHeld) // won't ever pass
return;

if (!bKeyPressed)
if (!bKeyPressed) // won't ever pass
return;

if (gScreenToDisplay != DISPLAY_MENU &&
Expand All @@ -65,7 +65,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gRequestSaveSettings = true;
}
}
else
else // released
{
#ifdef ENABLE_FMRADIO
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
Expand All @@ -75,7 +75,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
return;
#endif

gWasFKeyPressed = !gWasFKeyPressed;
gWasFKeyPressed = !gWasFKeyPressed; // toggle F function

if (gWasFKeyPressed)
gKeyInputCountdown = key_input_timeout_500ms;
Expand All @@ -88,7 +88,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gUpdateStatus = true;
}
}
else
else // short pressed
{
if (gScreenToDisplay != DISPLAY_FM)
{
Expand All @@ -97,7 +97,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
}

#ifdef ENABLE_FMRADIO
if (gFM_ScanState == FM_SCAN_OFF)
if (gFM_ScanState == FM_SCAN_OFF) // not scanning
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
Expand All @@ -116,7 +116,6 @@ void GENERIC_Key_PTT(bool bKeyPressed)

if (!bKeyPressed || gSerialConfigCountDown_500ms > 0)
{ // PTT released

if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // we are transmitting .. stop

Expand Down Expand Up @@ -181,22 +180,22 @@ void GENERIC_Key_PTT(bool bKeyPressed)
goto cancel_tx;
}

#ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF)
{ // FM radio is scanning .. stop
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx;
}
#endif
#ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF)
{ // FM radio is scanning .. stop
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx;
}
#endif

#ifdef ENABLE_FMRADIO
if (gScreenToDisplay == DISPLAY_FM)
goto start_tx; // listening to the FM radio .. start TX'ing
#endif
#ifdef ENABLE_FMRADIO
if (gScreenToDisplay == DISPLAY_FM)
goto start_tx; // listening to the FM radio .. start TX'ing
#endif

if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0)
{ // already transmitting
Expand Down Expand Up @@ -255,7 +254,6 @@ void GENERIC_Key_PTT(bool bKeyPressed)
cancel_tx:
if (gPttIsPressed)
{
gPttIsPressed = false;
gPttWasPressed = true;
}

Expand Down

0 comments on commit a6ef758

Please sign in to comment.