Simplify APP_EndTransmission

* Unify Roger-Beep selection
 * Extract function for DTMF EoT
This commit is contained in:
Juan Antonio
2023-12-22 18:24:40 +01:00
committed by egzumer
parent 34f2168856
commit 1f4f026162
7 changed files with 97 additions and 86 deletions

View File

@@ -731,14 +731,14 @@ static void CheckRadioInterrupts(void)
} }
void APP_EndTransmission(void) void APP_EndTransmission(void)
{ // back to RX mode {
// back to RX mode
RADIO_SendEndOfTransmission(); RADIO_SendEndOfTransmission();
// send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
RADIO_EnableCxCSS();
RADIO_SetupRegisters(false);
if (gMonitor) if (gMonitor) {
gFlagReconfigureVfos = true; //turn the monitor back on //turn the monitor back on
gFlagReconfigureVfos = true;
}
} }
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
@@ -884,37 +884,32 @@ 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 (!SCANNER_IsScanning() && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) if (!SCANNER_IsScanning()
{ && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF
&& gScheduleDualWatch
&& gScanStateDir == SCAN_OFF
&& !gPttIsPressed
&& gCurrentFunction != FUNCTION_POWER_SAVE
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gScheduleDualWatch && gVoiceWriteIndex == 0) && gVoiceWriteIndex == 0
#else
if (gScheduleDualWatch)
#endif #endif
{
if (gScanStateDir == SCAN_OFF)
{
if (!gPttIsPressed &&
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
!gFmRadioMode && && !gFmRadioMode
#endif #endif
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
gDTMF_CallState == DTMF_CALL_STATE_NONE && && gDTMF_CallState == DTMF_CALL_STATE_NONE
#endif #endif
gCurrentFunction != FUNCTION_POWER_SAVE) ) {
{ DualwatchAlternate(); // toggle between the two VFO's
DualwatchAlternate(); // toggle between the two VFO's
if (gRxVfoIsActive && gScreenToDisplay == DISPLAY_MAIN) if (gRxVfoIsActive && gScreenToDisplay == DISPLAY_MAIN) {
GUI_SelectNextDisplay(DISPLAY_MAIN); GUI_SelectNextDisplay(DISPLAY_MAIN);
gRxVfoIsActive = false;
gScanPauseMode = false;
gRxReceptionMode = RX_MODE_NONE;
gScheduleDualWatch = false;
}
}
} }
gRxVfoIsActive = false;
gScanPauseMode = false;
gRxReceptionMode = RX_MODE_NONE;
gScheduleDualWatch = false;
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@@ -1024,17 +1019,17 @@ void APP_Update(void)
// called every 10ms // called every 10ms
static void CheckKeys(void) static void CheckKeys(void)
{ {
if (0
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
|| gSetting_KILLED if(gSetting_KILLED){
#endif
#ifdef ENABLE_AIRCOPY
|| (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)
#endif
)
return; return;
}
#endif
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY){
return;
}
#endif
// -------------------- PTT ------------------------ // -------------------- PTT ------------------------
if (gPttIsPressed) if (gPttIsPressed)
@@ -1577,7 +1572,6 @@ static void ALARM_Off(void)
if (gAlarmState == ALARM_STATE_TXALARM) { if (gAlarmState == ALARM_STATE_TXALARM) {
RADIO_SendEndOfTransmission(); RADIO_SendEndOfTransmission();
RADIO_EnableCxCSS();
} }
gAlarmState = ALARM_STATE_OFF; gAlarmState = ALARM_STATE_OFF;

View File

@@ -78,6 +78,41 @@ void DTMF_clear_RX(void)
} }
#endif #endif
void DTMF_SendEndOfTransmission(void)
{
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) {
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
}
if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
#ifdef ENABLE_DTMF_CALLING
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
#endif
) { // end-of-tx
if (gEeprom.DTMF_SIDE_TONE)
{
AUDIO_AudioPathOn();
gEnableSpeaker = true;
SYSTEM_DelayMs(60);
}
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE);
BK4819_PlayDTMFString(
gEeprom.DTMF_DOWN_CODE,
0,
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME,
gEeprom.DTMF_HASH_CODE_PERSIST_TIME,
gEeprom.DTMF_CODE_PERSIST_TIME,
gEeprom.DTMF_CODE_INTERVAL_TIME);
AUDIO_AudioPathOff();
gEnableSpeaker = false;
}
BK4819_ExitDTMF_TX(true);
}
bool DTMF_ValidateCodes(char *pCode, const unsigned int size) bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
{ {
unsigned int i; unsigned int i;

View File

@@ -114,4 +114,6 @@ bool DTMF_FindContact(const char *pContact, char *pResult);
void DTMF_HandleRequest(void); void DTMF_HandleRequest(void);
#endif #endif
void DTMF_SendEndOfTransmission(void);
#endif #endif

View File

@@ -1688,7 +1688,7 @@ void BK4819_PrepareFSKReceive(void)
BK4819_WriteRegister(BK4819_REG_59, 0x3068); BK4819_WriteRegister(BK4819_REG_59, 0x3068);
} }
void BK4819_PlayRogerNormal(void) static void BK4819_PlayRogerNormal(void)
{ {
#if 0 #if 0
const uint32_t tone1_Hz = 500; const uint32_t tone1_Hz = 500;
@@ -1699,6 +1699,7 @@ void BK4819_PlayRogerNormal(void)
const uint32_t tone2_Hz = 1310; const uint32_t tone2_Hz = 1310;
#endif #endif
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
@@ -1723,6 +1724,7 @@ void BK4819_PlayRogerNormal(void)
BK4819_WriteRegister(BK4819_REG_30, 0xC1FE); // 1 1 0000 0 1 1111 1 1 1 0 BK4819_WriteRegister(BK4819_REG_30, 0xC1FE); // 1 1 0000 0 1 1111 1 1 1 0
} }
void BK4819_PlayRogerMDC(void) void BK4819_PlayRogerMDC(void)
{ {
struct reg_value { struct reg_value {
@@ -1771,6 +1773,15 @@ void BK4819_PlayRogerMDC(void)
BK4819_WriteRegister(BK4819_REG_58, 0x0000); BK4819_WriteRegister(BK4819_REG_58, 0x0000);
} }
void BK4819_PlayRoger(void)
{
if (gEeprom.ROGER == ROGER_MODE_ROGER) {
BK4819_PlayRogerNormal();
} else if (gEeprom.ROGER == ROGER_MODE_MDC) {
BK4819_PlayRogerMDC();
}
}
void BK4819_Enable_AfDac_DiscMode_TxDsp(void) void BK4819_Enable_AfDac_DiscMode_TxDsp(void)
{ {
BK4819_WriteRegister(BK4819_REG_30, 0x0000); BK4819_WriteRegister(BK4819_REG_30, 0x0000);

View File

@@ -163,7 +163,6 @@ void BK4819_SendFSKData(uint16_t *pData);
void BK4819_PrepareFSKReceive(void); void BK4819_PrepareFSKReceive(void);
void BK4819_PlayRoger(void); void BK4819_PlayRoger(void);
void BK4819_PlayRogerMDC(void);
void BK4819_Enable_AfDac_DiscMode_TxDsp(void); void BK4819_Enable_AfDac_DiscMode_TxDsp(void);
@@ -172,4 +171,3 @@ void BK4819_SetScrambleFrequencyControlWord(uint32_t Frequency);
void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code); void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code);
#endif #endif

50
radio.c
View File

@@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "driver/bk4819-regs.h"
#include <string.h> #include <string.h>
#include "am_fix.h" #include "am_fix.h"
@@ -1085,6 +1086,16 @@ void RADIO_EnableCxCSS(void)
SYSTEM_DelayMs(200); SYSTEM_DelayMs(200);
} }
void RADIO_SendEndOfTransmission(void)
{
BK4819_PlayRoger();
DTMF_SendEndOfTransmission();
// send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
RADIO_EnableCxCSS();
RADIO_SetupRegisters(false);
}
void RADIO_PrepareCssTX(void) void RADIO_PrepareCssTX(void)
{ {
RADIO_PrepareTX(); RADIO_PrepareTX();
@@ -1094,42 +1105,3 @@ void RADIO_PrepareCssTX(void)
RADIO_EnableCxCSS(); RADIO_EnableCxCSS();
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
} }
void RADIO_SendEndOfTransmission(void)
{
if (gEeprom.ROGER == ROGER_MODE_ROGER)
BK4819_PlayRoger();
else if (gEeprom.ROGER == ROGER_MODE_MDC)
BK4819_PlayRogerMDC();
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
#ifdef ENABLE_DTMF_CALLING
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
#endif
) { // end-of-tx
if (gEeprom.DTMF_SIDE_TONE)
{
AUDIO_AudioPathOn();
gEnableSpeaker = true;
SYSTEM_DelayMs(60);
}
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE);
BK4819_PlayDTMFString(
gEeprom.DTMF_DOWN_CODE,
0,
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME,
gEeprom.DTMF_HASH_CODE_PERSIST_TIME,
gEeprom.DTMF_CODE_PERSIST_TIME,
gEeprom.DTMF_CODE_INTERVAL_TIME);
AUDIO_AudioPathOff();
gEnableSpeaker = false;
}
BK4819_ExitDTMF_TX(true);
}

View File

@@ -168,5 +168,4 @@ void RADIO_EnableCxCSS(void);
void RADIO_PrepareCssTX(void); void RADIO_PrepareCssTX(void);
void RADIO_SendEndOfTransmission(void); void RADIO_SendEndOfTransmission(void);
#endif #endif