Skip to content

Commit

Permalink
Added VOX enable/disable compile option
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Oct 4, 2023
1 parent 5f2e069 commit f4b637b
Show file tree
Hide file tree
Showing 25 changed files with 417 additions and 308 deletions.
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@ ENABLE_OVERLAY := 0
ENABLE_LTO := 1
ENABLE_UART := 1
ENABLE_AIRCOPY := 0
ENABLE_FMRADIO := 0
ENABLE_FMRADIO := 1
ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_VOX := 0
ENABLE_ALARM := 0
ENABLE_TX1750 := 0
ENABLE_TX1750 := 1
ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1
ENABLE_WIDE_RX := 1
ENABLE_TX_WHEN_AM := 0
ENABLE_F_CAL_MENU := 1
ENABLE_F_CAL_MENU := 0
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_MAIN_KEY_HOLD := 1
ENABLE_BOOT_BEEPS := 0
ENABLE_COMPANDER := 1
ENABLE_COMPANDER := 0
ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_CODE_SCAN_TIMEOUT := 0
ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 1
ENABLE_SQUELCH_MORE_SENSITIVE := 1
ENABLE_SQUELCH_MORE_SENSITIVE := 0
ENABLE_FASTER_CHANNEL_SCAN := 0
ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 1
Expand Down Expand Up @@ -201,6 +202,9 @@ endif
ifeq ($(ENABLE_VOICE),1)
CFLAGS += -DENABLE_VOICE
endif
ifeq ($(ENABLE_VOX),1)
CFLAGS += -DENABLE_VOX
endif
ifeq ($(ENABLE_ALARM),1)
CFLAGS += -DENABLE_ALARM
endif
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ENABLE_AIRCOPY := 0 easier to just enter frequency with but
ENABLE_FMRADIO := 0 WBFM VHF broadcast band receiver
ENABLE_NOAA := 0 everything NOAA (only of any use in the USA)
ENABLE_VOICE := 0 want to hear voices ?
ENABLE_VOX := 0
ENABLE_ALARM := 0 TX alarms
ENABLE_1750HZ := 0 side key 1750Hz TX tone (older style repeater access)
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
Expand Down
30 changes: 18 additions & 12 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,18 @@ void ACTION_Scan(bool bRestart)
}
}

void ACTION_Vox(void)
{
gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH;
gRequestSaveSettings = true;
gFlagReconfigureVfos = true;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_VOX;
#endif
gUpdateStatus = true;
}
#ifdef ENABLE_VOX
void ACTION_Vox(void)
{
gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH;
gRequestSaveSettings = true;
gFlagReconfigureVfos = true;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_VOX;
#endif
gUpdateStatus = true;
}
#endif

#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
static void ACTION_AlarmOr1750(const bool b1750)
Expand Down Expand Up @@ -268,7 +270,9 @@ void ACTION_Vox(void)
FM_TurnOff();

gInputBoxIndex = 0;
gVoxResumeCountdown = 80;
#ifdef ENABLE_VOX
gVoxResumeCountdown = 80;
#endif
gFlagReconfigureVfos = true;

gRequestDisplayScreen = DISPLAY_MAIN;
Expand Down Expand Up @@ -369,7 +373,9 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
ACTION_Scan(true);
break;
case ACTION_OPT_VOX:
ACTION_Vox();
#ifdef ENABLE_VOX
ACTION_Vox();
#endif
break;
case ACTION_OPT_ALARM:
#ifdef ENABLE_ALARM
Expand Down
4 changes: 3 additions & 1 deletion app/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
void ACTION_Power(void);
void ACTION_Monitor(void);
void ACTION_Scan(bool bFlag);
void ACTION_Vox(void);
#ifdef ENABLE_VOX
void ACTION_Vox(void);
#endif
#ifdef ENABLE_ALARM
//static void ACTION_AlarmOr1750(bool b1750)
#endif
Expand Down
206 changes: 109 additions & 97 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)

gEnableSpeaker = true;

if (gSetting_backlight_on_rx)
if (gSetting_backlight_on_tx_rx)
BACKLIGHT_TurnOn();

if (gScanState != SCAN_OFF)
Expand Down Expand Up @@ -850,36 +850,38 @@ void APP_CheckRadioInterrupts(void)
if (interrupt_status_bits & BK4819_REG_02_CTCSS_FOUND)
g_CTCSS_Lost = false;

if (interrupt_status_bits & BK4819_REG_02_VOX_LOST)
{
g_VOX_Lost = true;
gVoxPauseCountdown = 10;

if (gEeprom.VOX_SWITCH)
#ifdef ENABLE_VOX
if (interrupt_status_bits & BK4819_REG_02_VOX_LOST)
{
if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode)
{
gPowerSave_10ms = power_save2_10ms;
gPowerSaveCountdownExpired = 0;
}

if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms))
g_VOX_Lost = true;
gVoxPauseCountdown = 10;

if (gEeprom.VOX_SWITCH)
{
gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms;
gScheduleDualWatch = false;

// let the user see DW is not active
gDualWatchActive = false;
gUpdateStatus = true;
if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode)
{
gPowerSave_10ms = power_save2_10ms;
gPowerSaveCountdownExpired = 0;
}

if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms))
{
gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms;
gScheduleDualWatch = false;

// let the user see DW is not active
gDualWatchActive = false;
gUpdateStatus = true;
}
}
}
}

if (interrupt_status_bits & BK4819_REG_02_VOX_FOUND)
{
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}
if (interrupt_status_bits & BK4819_REG_02_VOX_FOUND)
{
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}
#endif

if (interrupt_status_bits & BK4819_REG_02_SQUELCH_LOST)
{
Expand Down Expand Up @@ -934,83 +936,85 @@ void APP_EndTransmission(void)
RADIO_SetupRegisters(false);
}

static void APP_HandleVox(void)
{
if (gSetting_KILLED)
return;

if (gVoxResumeCountdown == 0)
{
if (gVoxPauseCountdown)
return;
}
else
#ifdef ENABLE_VOX
static void APP_HandleVox(void)
{
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}

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

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

if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
return;

if (gVOX_NoiseDetected)
{
if (g_VOX_Lost)
gVoxStopCountdown_10ms = vox_stop_count_down_10ms;

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

if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected)
{
if (gFlagEndTransmission)
{
//if (gCurrentFunction != FUNCTION_FOREGROUND)
FUNCTION_Select(FUNCTION_FOREGROUND);
}
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}

#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
return;
#endif

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

if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
return;

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)
{
APP_EndTransmission();

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

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

gUpdateStatus = true;
gUpdateDisplay = true;
gFlagEndTransmission = false;
}

gUpdateStatus = true;
gUpdateDisplay = true;
gFlagEndTransmission = false;
return;
}
return;
}

if (g_VOX_Lost)
{
gVOX_NoiseDetected = true;

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

if (gCurrentFunction != FUNCTION_TRANSMIT && gSerialConfigCountDown_500ms == 0)

if (g_VOX_Lost)
{
gDTMF_ReplyState = DTMF_REPLY_NONE;
RADIO_PrepareTX();
gUpdateDisplay = true;
gVOX_NoiseDetected = true;

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

if (gCurrentFunction != FUNCTION_TRANSMIT && gSerialConfigCountDown_500ms == 0)
{
gDTMF_ReplyState = DTMF_REPLY_NONE;
RADIO_PrepareTX();
gUpdateDisplay = true;
}
}
}
}
#endif

void APP_Update(void)
{
Expand Down Expand Up @@ -1144,8 +1148,10 @@ void APP_Update(void)
}
#endif

if (gEeprom.VOX_SWITCH)
APP_HandleVox();
#ifdef ENABLE_VOX
if (gEeprom.VOX_SWITCH)
APP_HandleVox();
#endif

if (gSchedulePowerSave)
{
Expand Down Expand Up @@ -1210,8 +1216,10 @@ void APP_Update(void)
{
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();

if (gEeprom.VOX_SWITCH)
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
#ifdef ENABLE_VOX
if (gEeprom.VOX_SWITCH)
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
#endif

if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF &&
gScanState == SCAN_OFF &&
Expand Down Expand Up @@ -1447,11 +1455,13 @@ void APP_TimeSlice10ms(void)
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0)
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);

if (gVoxResumeCountdown > 0)
gVoxResumeCountdown--;

if (gVoxPauseCountdown > 0)
gVoxPauseCountdown--;
#ifdef ENABLE_VOX
if (gVoxResumeCountdown > 0)
gVoxResumeCountdown--;

if (gVoxPauseCountdown > 0)
gVoxPauseCountdown--;
#endif

if (gCurrentFunction == FUNCTION_TRANSMIT)
{
Expand Down Expand Up @@ -1997,7 +2007,9 @@ void APP_TimeSlice500ms(void)
RADIO_EnableCxCSS();
}

gVoxResumeCountdown = 80;
#ifdef ENABLE_VOX
gVoxResumeCountdown = 80;
#endif

SYSTEM_DelayMs(5);

Expand Down
Loading

0 comments on commit f4b637b

Please sign in to comment.