diff --git a/app/app.c b/app/app.c index ba549902..36dd9a5e 100644 --- a/app/app.c +++ b/app/app.c @@ -861,80 +861,79 @@ void APP_EndTransmission(void) } RADIO_SetupRegisters(false); - - if (gMonitor) - ACTION_Monitor(); // 1of11 } static void APP_HandleVox(void) { - if (!gSetting_KILLED) + if (gSetting_KILLED) + return; + + if (gVoxResumeCountdown == 0) { - if (gVoxResumeCountdown == 0) - { - if (gVoxPauseCountdown) - return; - } - else - { - g_VOX_Lost = false; - gVoxPauseCountdown = 0; - } + if (gVoxPauseCountdown) + return; + } + else + { + g_VOX_Lost = false; + gVoxPauseCountdown = 0; + } - if (gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_MONITOR && - gScanState == SCAN_OFF && - gCssScanMode == CSS_SCAN_MODE_OFF - #ifdef ENABLE_FMRADIO - && !gFmRadioMode - #endif - ) - { - if (gVOX_NoiseDetected) - { - if (g_VOX_Lost) - gVoxStopCountdown_10ms = 100; // 1 sec - else - if (gVoxStopCountdown_10ms == 0) - gVOX_NoiseDetected = false; + #ifdef ENABLE_FMRADIO + if (gFmRadioMode) + return; + #endif - if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) - { - if (gFlagEndTransmission) - { - FUNCTION_Select(FUNCTION_FOREGROUND); - } - else - { - APP_EndTransmission(); + if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) + return; - if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) - FUNCTION_Select(FUNCTION_FOREGROUND); - else - gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; - } + if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) + return; - gUpdateDisplay = true; - gFlagEndTransmission = false; + if (gVOX_NoiseDetected) + { + if (g_VOX_Lost) + gVoxStopCountdown_10ms = vox_stop_count_down_10ms; + else + if (gVoxStopCountdown_10ms == 0) + gVOX_NoiseDetected = false; - return; - } + if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) + { + if (gFlagEndTransmission) + { + FUNCTION_Select(FUNCTION_FOREGROUND); } else - if (g_VOX_Lost) { - gVOX_NoiseDetected = true; - - if (gCurrentFunction == FUNCTION_POWER_SAVE) - FUNCTION_Select(FUNCTION_FOREGROUND); + APP_EndTransmission(); - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) { - gDTMF_ReplyState = DTMF_REPLY_NONE; - RADIO_PrepareTX(); - gUpdateDisplay = true; + FUNCTION_Select(FUNCTION_FOREGROUND); } + else + gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; } + + gUpdateDisplay = true; + gFlagEndTransmission = false; + } + return; + } + + if (g_VOX_Lost) + { + gVOX_NoiseDetected = true; + + if (gCurrentFunction == FUNCTION_POWER_SAVE) + FUNCTION_Select(FUNCTION_FOREGROUND); + + if (gCurrentFunction != FUNCTION_TRANSMIT) + { + gDTMF_ReplyState = DTMF_REPLY_NONE; + RADIO_PrepareTX(); + gUpdateDisplay = true; } } } @@ -1452,6 +1451,7 @@ void APP_TimeSlice10ms(void) if (--gRTTECountdown == 0) { FUNCTION_Select(FUNCTION_FOREGROUND); + gUpdateDisplay = true; } } diff --git a/app/generic.c b/app/generic.c index 165c8991..ca05855e 100644 --- a/app/generic.c +++ b/app/generic.c @@ -132,6 +132,9 @@ void GENERIC_Key_PTT(bool bKeyPressed) RADIO_SetVfoState(VFO_STATE_NORMAL); + // beep when you release the PTT + //gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL; // 1of11 + gRequestDisplayScreen = DISPLAY_MAIN; return; } diff --git a/app/menu.c b/app/menu.c index e865a760..76e34266 100644 --- a/app/menu.c +++ b/app/menu.c @@ -210,6 +210,10 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) break; case MENU_SCR: + *pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1; + break; + case MENU_VOX: case MENU_TOT: case MENU_RP_STE: diff --git a/audio.c b/audio.c index 8cff55f2..9bf14031 100644 --- a/audio.c +++ b/audio.c @@ -76,9 +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_500HZ_60MS_DOUBLE_BEEP && Beep != BEEP_440HZ_500MS && !gEeprom.BEEP_CONTROL) return; #ifdef ENABLE_AIRCOPY diff --git a/driver/bk4819.c b/driver/bk4819.c index ab741535..d06bf6d4 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -814,7 +814,7 @@ void BK4819_EnableScramble(uint8_t Type) const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31); BK4819_WriteRegister(BK4819_REG_31, Value | (1u << 1)); - BK4819_WriteRegister(BK4819_REG_71, 0x68DC + (Type * 1032)); + BK4819_WriteRegister(BK4819_REG_71, 0x68DC + (Type * 1032)); // 0110 1000 1101 1100 } bool BK4819_CompanderEnabled(void) diff --git a/firmware.bin b/firmware.bin index d75f7d8c..5c1e4150 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 56d3bc02..5a694f20 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index c5a94cba..4bf29fae 100644 --- a/functions.c +++ b/functions.c @@ -84,19 +84,16 @@ void FUNCTION_Init(void) void FUNCTION_Select(FUNCTION_Type_t Function) { - FUNCTION_Type_t PreviousFunction = gCurrentFunction; - bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); + const FUNCTION_Type_t PreviousFunction = gCurrentFunction; + const bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); gCurrentFunction = Function; - if (bWasPowerSave) + if (bWasPowerSave && Function != FUNCTION_POWER_SAVE) { - if (Function != FUNCTION_POWER_SAVE) - { - BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); - gRxIdleMode = false; - UI_DisplayStatus(false); - } + BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); + gRxIdleMode = false; + UI_DisplayStatus(false); } switch (Function) @@ -130,7 +127,6 @@ void FUNCTION_Select(FUNCTION_Type_t Function) case FUNCTION_INCOMING: case FUNCTION_RECEIVE: -// gMonitor = false; break; case FUNCTION_POWER_SAVE: @@ -151,6 +147,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function) return; case FUNCTION_TRANSMIT: + + // if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11 + BK4819_DisableDTMF(); + #if defined(ENABLE_FMRADIO) if (gFmRadioMode) BK1080_Init(0, false); @@ -160,22 +160,32 @@ void FUNCTION_Select(FUNCTION_Type_t Function) if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE) { gAlarmState = ALARM_STATE_ALARM; + GUI_DisplayScreen(); + GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + SYSTEM_DelayMs(20); BK4819_PlayTone(500, 0); SYSTEM_DelayMs(2); + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + gEnableSpeaker = true; + SYSTEM_DelayMs(60); BK4819_ExitTxMute(); + gAlarmToneCounter = 0; break; } #endif GUI_DisplayScreen(); + RADIO_SetTxParameters(); + + // turn the LED on RED BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true); DTMF_Reply(); @@ -191,10 +201,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) break; } #endif - - // if the DTMF decoder is enabled, it destroys the TX audio !! .. 1of11 - BK4819_DisableDTMF(); - + if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); else diff --git a/misc.c b/misc.c index ece8db71..2aba9402 100644 --- a/misc.c +++ b/misc.c @@ -57,6 +57,8 @@ const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds const uint16_t power_save1_10ms = 100 / 10; // 100ms const uint16_t power_save2_10ms = 200 / 10; // 200ms +const uint16_t vox_stop_count_down_10ms = 1000 / 10; // 1 second + const uint16_t NOAA_countdown_10ms = 5000 / 10; // 5 seconds const uint16_t NOAA_countdown_2_10ms = 500 / 10; // 500ms const uint16_t NOAA_countdown_3_10ms = 200 / 10; // 200ms diff --git a/misc.h b/misc.h index 44a32202..fc40f507 100644 --- a/misc.h +++ b/misc.h @@ -109,6 +109,8 @@ extern const uint16_t battery_save_count_10ms; extern const uint16_t power_save1_10ms; extern const uint16_t power_save2_10ms; +extern const uint16_t vox_stop_count_down_10ms; + extern const uint16_t NOAA_countdown_10ms; extern const uint16_t NOAA_countdown_2_10ms; extern const uint16_t NOAA_countdown_3_10ms; diff --git a/ui/menu.c b/ui/menu.c index 2c181428..5e2e58a4 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -291,6 +291,21 @@ const char gSubMenu_BAT_TXT[3][8] = "PERCENT" }; +const char gSubMenu_SCRAMBLER[11][7] = +{ + "OFF", + "2600Hz", + "2700Hz", + "2800Hz", + "2900Hz", + "3000Hz", + "3100Hz", + "3200Hz", + "3300Hz", + "3400Hz", + "3500Hz" +}; + bool gIsInSubMenu; uint8_t gMenuCursor; int8_t gMenuScrollDirection; @@ -421,6 +436,9 @@ void UI_DisplayMenu(void) break; case MENU_SCR: + strcpy(String, gSubMenu_SCRAMBLER[gSubMenuSelection]); + break; + case MENU_VOX: if (gSubMenuSelection == 0) strcpy(String, "OFF"); diff --git a/ui/menu.h b/ui/menu.h index 96da38de..9fccd13e 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -146,6 +146,8 @@ extern const char gSubMenu_BACKLIGHT[8][7]; extern const char gSubMenu_AM_fix_test1[4][8]; #endif extern const char gSubMenu_BAT_TXT[3][8]; + +extern const char gSubMenu_SCRAMBLER[11][7]; extern bool gIsInSubMenu;