Skip to content

Commit

Permalink
Added 30 sec TX timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Sep 28, 2023
1 parent 81bc398 commit 618d696
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 67 deletions.
9 changes: 5 additions & 4 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,13 +963,14 @@ void APP_Update(void)
#endif

if (gCurrentFunction == FUNCTION_TRANSMIT && gTxTimeoutReached)
{ // transmitting, but just timed out
{ // transmitter timed out
gTxTimeoutReached = false;

gTxTimeoutReached = false;
gFlagEndTransmission = true;

APP_EndTransmission();
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);

AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP);

RADIO_SetVfoState(VFO_STATE_TIMEOUT);
GUI_DisplayScreen();
}
Expand Down
11 changes: 7 additions & 4 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,12 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
*pMax = ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1;
break;

case MENU_VOX:
case MENU_TOT:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_TOT) - 1;
break;

case MENU_VOX:
case MENU_RP_STE:
*pMin = 0;
*pMax = 10;
Expand Down Expand Up @@ -317,13 +321,12 @@ void MENU_AcceptSetting(void)
break;

case MENU_STEP:
gTxVfo->STEP_SETTING = gSubMenuSelection;
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gTxVfo->STEP_SETTING = gSubMenuSelection;
gRequestSaveChannel = 1;
gRequestSaveChannel = 1;
return;
}
gTxVfo->STEP_SETTING = gSubMenuSelection;
return;

case MENU_TXP:
Expand Down
12 changes: 9 additions & 3 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
uint16_t ToneFrequency;
uint16_t Duration;

if (Beep != BEEP_500HZ_60MS_DOUBLE_BEEP && Beep != BEEP_440HZ_500MS && !gEeprom.BEEP_CONTROL)
if (Beep != BEEP_880HZ_60MS_TRIPLE_BEEP && Beep != BEEP_500HZ_60MS_DOUBLE_BEEP && Beep != BEEP_440HZ_500MS && !gEeprom.BEEP_CONTROL)
return;

#ifdef ENABLE_AIRCOPY
Expand Down Expand Up @@ -122,6 +122,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
ToneFrequency = 440;
break;
case BEEP_880HZ_40MS_OPTIONAL:
case BEEP_880HZ_60MS_TRIPLE_BEEP:
ToneFrequency = 880;
break;
}
Expand All @@ -136,15 +137,19 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)

switch (Beep)
{
case BEEP_880HZ_60MS_TRIPLE_BEEP:
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);

case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
case BEEP_500HZ_60MS_DOUBLE_BEEP:
BK4819_ExitTxMute();
SYSTEM_DelayMs(60);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);

// Fallthrough

case BEEP_1KHZ_60MS_OPTIONAL:
BK4819_ExitTxMute();
Duration = 60;
Expand All @@ -166,6 +171,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
SYSTEM_DelayMs(Duration);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);

GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);

gVoxResumeCountdown = 80;
Expand Down
3 changes: 2 additions & 1 deletion audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ enum BEEP_Type_t
BEEP_440HZ_500MS,
BEEP_500HZ_60MS_DOUBLE_BEEP,
BEEP_440HZ_40MS_OPTIONAL,
BEEP_880HZ_40MS_OPTIONAL
BEEP_880HZ_40MS_OPTIONAL,
BEEP_880HZ_60MS_TRIPLE_BEEP
};

typedef enum BEEP_Type_t BEEP_Type_t;
Expand Down
10 changes: 6 additions & 4 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void BK4819_Init(void)
BK4819_WriteRegister(BK4819_REG_36, 0x0022);

BK4819_SetAGC(0);
// BK4819_SetAGC(1);

BK4819_WriteRegister(BK4819_REG_19, 0b0001000001000001); // <15> MIC AGC 1 = disable 0 = enable

Expand Down Expand Up @@ -239,9 +240,9 @@ void BK4819_SetAGC(uint8_t Value)
//
// <9:8> = LNA Gain Short
// 3 = 0dB
// 2 = -11dB
// 1 = -16dB
// 0 = -19dB
// 2 = -24dB // was -11
// 1 = -30dB // was -16
// 0 = -33dB // was -19
//
// <7:5> = LNA Gain
// 7 = 0dB
Expand Down Expand Up @@ -286,7 +287,8 @@ void BK4819_SetAGC(uint8_t Value)
}
else
if (Value == 1)
{
{ // what does this do ?????????

unsigned int i;

// REG_10
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ void Main(void)
gNextTimeslice = false;
}

if (gNextTimeslice500ms)
if (gNextTimeslice_500ms)
{
APP_TimeSlice500ms();
gNextTimeslice500ms = false;
gNextTimeslice_500ms = false;
}
}
}
9 changes: 6 additions & 3 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ volatile uint16_t gDualWatchCountdown_10ms;
volatile bool gDualWatchCountdownExpired = true;
bool gDualWatchActive = false;

volatile bool gNextTimeslice500ms;
volatile uint16_t gTxTimerCountdown;
volatile bool gNextTimeslice_500ms;

volatile uint16_t gTxTimerCountdown_500ms;
volatile bool gTxTimeoutReached;

volatile uint16_t gTailNoteEliminationCountdown_10ms;

#ifdef ENABLE_NOAA
volatile uint16_t gNOAA_Countdown_10ms;
#endif
Expand Down Expand Up @@ -220,7 +224,6 @@ volatile bool gNextTimeslice;
volatile uint8_t gFoundCDCSSCountdown_10ms;
volatile uint8_t gFoundCTCSSCountdown_10ms;
volatile uint16_t gVoxStopCountdown_10ms;
volatile bool gTxTimeoutReached;
volatile bool gNextTimeslice40ms;
#ifdef ENABLE_NOAA
volatile uint16_t gNOAACountdown_10ms = 0;
Expand Down
9 changes: 6 additions & 3 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,13 @@ extern volatile uint16_t gDualWatchCountdown_10ms;
extern volatile bool gDualWatchCountdownExpired;
extern bool gDualWatchActive;

extern volatile bool gNextTimeslice500ms;
extern volatile uint16_t gTxTimerCountdown;
extern volatile bool gNextTimeslice_500ms;

extern volatile uint16_t gTxTimerCountdown_500ms;
extern volatile bool gTxTimeoutReached;

extern volatile uint16_t gTailNoteEliminationCountdown_10ms;

#ifdef ENABLE_FMRADIO
extern volatile uint16_t gFmPlayCountdown_10ms;
#endif
Expand Down Expand Up @@ -282,7 +286,6 @@ extern uint8_t gShowChPrefix;
extern volatile uint8_t gFoundCDCSSCountdown_10ms;
extern volatile uint8_t gFoundCTCSSCountdown_10ms;
extern volatile uint16_t gVoxStopCountdown_10ms;
extern volatile bool gTxTimeoutReached;
extern volatile bool gNextTimeslice40ms;
#ifdef ENABLE_NOAA
extern volatile uint16_t gNOAACountdown_10ms;
Expand Down
79 changes: 42 additions & 37 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t Band, uint32
#ifdef ENABLE_COMPANDER
pInfo->Compander = 0; // off
#endif

if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz))
{
pInfo->AM_CHANNEL_MODE = true;
Expand Down Expand Up @@ -223,7 +223,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
// Band = BAND6_400MHz;
Band = FREQUENCY_GetBand(gEeprom.ScreenChannel[VFO]); // 111 bug fix, or have I broke it ?
}

if (IS_MR_CHANNEL(Channel))
{
gEeprom.VfoInfo[VFO].Band = Band;
Expand Down Expand Up @@ -466,27 +466,27 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
{
pInfo->SquelchOpenRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 11) / 12;
pInfo->SquelchCloseRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 9) / 10;

pInfo->SquelchOpenNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 9) / 8;
pInfo->SquelchCloseNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 10) / 9;

pInfo->SquelchOpenGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 9) / 8;
pInfo->SquelchCloseGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 10) / 9;
}
else
{
pInfo->SquelchOpenRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 3) / 4;
pInfo->SquelchCloseRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 9) / 10;

pInfo->SquelchOpenNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 4) / 3;
pInfo->SquelchCloseNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 10) / 9;

pInfo->SquelchOpenGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 4) / 3;
pInfo->SquelchCloseGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 10) / 9;
}
}
#endif

if (pInfo->SquelchOpenNoiseThresh > 127)
pInfo->SquelchOpenNoiseThresh = 127;
if (pInfo->SquelchCloseNoiseThresh > 127)
Expand Down Expand Up @@ -537,7 +537,7 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo)
if (Frequency > UpperLimitFrequencyBandTable[ARRAY_SIZE(UpperLimitFrequencyBandTable) - 1])
Frequency = UpperLimitFrequencyBandTable[ARRAY_SIZE(UpperLimitFrequencyBandTable) - 1];
#endif

pInfo->freq_config_TX.Frequency = Frequency;
}

Expand Down Expand Up @@ -598,7 +598,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#endif
break;
}

BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, false);

BK4819_SetupPowerAmplifier(0, 0);
Expand Down Expand Up @@ -662,7 +662,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
default:
case CODE_TYPE_OFF:
BK4819_SetCTCSSFrequency(670);

//#ifndef ENABLE_CTCSS_TAIL_PHASE_SHIFT
BK4819_SetTailDetection(550); // QS's 55Hz tone method
//#else
Expand All @@ -687,7 +687,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
| BK4819_REG_3F_CTCSS_LOST
| BK4819_REG_3F_SQUELCH_FOUND
| BK4819_REG_3F_SQUELCH_LOST;

break;

case CODE_TYPE_DIGITAL:
Expand Down Expand Up @@ -924,10 +924,13 @@ void RADIO_SetVfoState(VfoState_t State)

void RADIO_PrepareTX(void)
{
VfoState_t State = VFO_STATE_NORMAL; // default to OK to TX

if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
{ // dual-RX is enabled

gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms;
gScheduleDualWatch = false;
gScheduleDualWatch = false;

if (!gRxVfoIsActive)
{
Expand All @@ -944,13 +947,11 @@ void RADIO_PrepareTX(void)
RADIO_SelectCurrentVfo();

#ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_OFF ||
if (gAlarmState == ALARM_STATE_OFF ||
gAlarmState == ALARM_STATE_TX1750 ||
(gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE))
#endif
{
VfoState_t State;

#ifndef ENABLE_TX_WHEN_AM
if (gCurrentVfo->IsAM)
{ // not allowed to TX if in AM mode
Expand All @@ -963,38 +964,36 @@ void RADIO_PrepareTX(void)
State = VFO_STATE_TX_DISABLE;
}
else
if (TX_FREQUENCY_Check(gCurrentVfo->pTX->Frequency) == 0 || gCurrentVfo->CHANNEL_SAVE <= FREQ_CHANNEL_LAST)
{
//if (TX_FREQUENCY_Check(gCurrentVfo->pTX->Frequency) == 0 || gCurrentVfo->CHANNEL_SAVE <= FREQ_CHANNEL_LAST)
if (TX_FREQUENCY_Check(gCurrentVfo->pTX->Frequency) == 0)
{ // TX frequency is allowed
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE)
State = VFO_STATE_BUSY;
State = VFO_STATE_BUSY; // busy RX'ing a station
else
if (gBatteryDisplayLevel == 0)
State = VFO_STATE_BAT_LOW;
else
// if (gBatteryDisplayLevel >= 6)
if (gBatteryDisplayLevel >= 11)
State = VFO_STATE_VOLTAGE_HIGH;
State = VFO_STATE_BAT_LOW; // charge your battery !
else
goto Skip;
//if (gBatteryDisplayLevel >= 6)
if (gBatteryDisplayLevel >= 11) // I've increased the battery level bar resolution
State = VFO_STATE_VOLTAGE_HIGH; // over voltage .. this is being a pain
}
else
{
State = VFO_STATE_TX_DISABLE;
}

RADIO_SetVfoState(State);
State = VFO_STATE_TX_DISABLE; // TX frequency not allowed
}

if (State != VFO_STATE_NORMAL)
{ // TX not allowed
RADIO_SetVfoState(State);
#ifdef ENABLE_ALARM
gAlarmState = ALARM_STATE_OFF;
#endif

gDTMF_ReplyState = DTMF_REPLY_NONE;

AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
return;
}

Skip:
// TX is allowed

if (gDTMF_ReplyState == DTMF_REPLY_ANI)
{
if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF)
Expand All @@ -1012,13 +1011,19 @@ void RADIO_PrepareTX(void)

FUNCTION_Select(FUNCTION_TRANSMIT);

gTxTimerCountdown_500ms = 0; // no timeout
#ifdef ENABLE_ALARM
gTxTimerCountdown = (gAlarmState == ALARM_STATE_OFF) ? gEeprom.TX_TIMEOUT_TIMER * 120 : 0;
#else
gTxTimerCountdown = gEeprom.TX_TIMEOUT_TIMER * 120;
if (gAlarmState == ALARM_STATE_OFF)
#endif

{
if (gEeprom.TX_TIMEOUT_TIMER == 1)
gTxTimerCountdown_500ms = 60; // 30 sec
else
if (gEeprom.TX_TIMEOUT_TIMER >= 2)
gTxTimerCountdown_500ms = (gEeprom.TX_TIMEOUT_TIMER - 1) * 120; // minutes
}
gTxTimeoutReached = false;

gFlagEndTransmission = false;
gRTTECountdown = 0;
gDTMF_ReplyState = DTMF_REPLY_NONE;
Expand Down
Loading

0 comments on commit 618d696

Please sign in to comment.