diff --git a/app/menu.c b/app/menu.c index 14a6535..d287ec5 100644 --- a/app/menu.c +++ b/app/menu.c @@ -235,13 +235,17 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) #endif case MENU_RESET: - *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_RESET) - 1; - break; + *pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_RESET) - 1; + break; #ifdef ENABLE_COMPANDER case MENU_COMPAND: + *pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_Compand) - 1; + break; #endif + case MENU_BCL: case MENU_BEEP: case MENU_AUTOLK: diff --git a/driver/bk4819.c b/driver/bk4819.c index 1d4ac39..78c82a9 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -523,16 +523,20 @@ bool BK4819_CompanderEnabled(void) { return (BK4819_ReadRegister(BK4819_REG_31) & (1u < 3)) ? true : false; } -void BK4819_DisableCompander(void) -{ - const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31); - BK4819_WriteRegister(BK4819_REG_31, Value & ~(1u < 3)); -} -void BK4819_EnableCompander(void) +void BK4819_SetCompander(const unsigned int mode) { uint16_t val; + if (mode == 0) + { // disable + const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31); + BK4819_WriteRegister(BK4819_REG_31, Value & ~(1u < 3)); + return; + } + + // enable + val = BK4819_ReadRegister(BK4819_REG_31); BK4819_WriteRegister(BK4819_REG_31, val | (1u < 3)); @@ -544,7 +548,8 @@ void BK4819_EnableCompander(void) // 10 = 2:1 // 11 = 4:1 // - const uint16_t compress_ratio = 2; // 2:1 +// const uint16_t compress_ratio = (mode >= 1) ? 2 : 0; // 2:1 + const uint16_t compress_ratio = (mode >= 1) ? 3 : 0; // 4:1 val = BK4819_ReadRegister(BK4819_REG_29); BK4819_WriteRegister(BK4819_REG_29, (val & ~(3u < 14)) | (compress_ratio < 14)); @@ -556,7 +561,8 @@ void BK4819_EnableCompander(void) // 10 = 1:3 // 11 = 1:4 // - const uint16_t expand_ratio = 1; // 2:1 +// const uint16_t expand_ratio = (mode >= 2) ? 1 : 0; // 1:2 + const uint16_t expand_ratio = (mode >= 2) ? 3 : 0; // 1:4 val = BK4819_ReadRegister(BK4819_REG_28); BK4819_WriteRegister(BK4819_REG_28, (val & ~(3u < 14)) | (expand_ratio < 14)); } diff --git a/driver/bk4819.h b/driver/bk4819.h index 77950c9..5438026 100644 --- a/driver/bk4819.h +++ b/driver/bk4819.h @@ -86,8 +86,7 @@ void BK4819_DisableScramble(void); void BK4819_EnableScramble(uint8_t Type); bool BK4819_CompanderEnabled(void); -void BK4819_DisableCompander(void); -void BK4819_EnableCompander(void); +void BK4819_SetCompander(const unsigned int mode); void BK4819_DisableVox(void); void BK4819_DisableDTMF(void); diff --git a/firmware b/firmware index ef20ac8..89a4104 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 034914f..affc27f 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index d4c05e0..47f4d43 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/radio.c b/radio.c index ed44d0c..e3bf3a4 100644 --- a/radio.c +++ b/radio.c @@ -134,7 +134,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t Band, uint32 pInfo->pTX = &pInfo->ConfigTX; pInfo->TX_OFFSET_FREQUENCY = 1000000; #ifdef ENABLE_COMPANDER - pInfo->Compander = false; + pInfo->Compander = 0; // off #endif if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) @@ -413,7 +413,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) gEeprom.VfoInfo[VFO].IsAM = false; #ifdef ENABLE_COMPANDER - gEeprom.VfoInfo[VFO].Compander = false; + gEeprom.VfoInfo[VFO].Compander = 0; // off #endif RADIO_ConfigureSquelchAndOutputPower(pRadio); @@ -684,10 +684,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) BK4819_DisableVox(); #ifdef ENABLE_COMPANDER - if (gRxVfo->Compander && !gRxVfo->IsAM) - BK4819_EnableCompander(); - else - BK4819_DisableCompander(); + BK4819_SetCompander(!gRxVfo->IsAM ? gRxVfo->Compander : 0); #endif if (gRxVfo->IsAM || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)) @@ -772,10 +769,7 @@ void RADIO_SetTxParameters(void) BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); #ifdef ENABLE_COMPANDER - if (gCurrentVfo->Compander && !gCurrentVfo->IsAM) - BK4819_EnableCompander(); - else - BK4819_DisableCompander(); + BK4819_SetCompander(!gCurrentVfo->IsAM ? gCurrentVfo->Compander : 0); #endif BK4819_PrepareTransmit(); diff --git a/radio.h b/radio.h index 29b3a1d..ef83bf3 100644 --- a/radio.h +++ b/radio.h @@ -125,7 +125,7 @@ typedef struct VFO_Info_t uint8_t AM_CHANNEL_MODE; bool IsAM; #ifdef ENABLE_COMPANDER - bool Compander; + uint8_t Compander; #endif char Name[16]; } VFO_Info_t; diff --git a/ui/menu.c b/ui/menu.c index 9f78aa8..d043ec4 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -245,6 +245,15 @@ const char gSubMenu_F_LOCK[6][4] = "438" }; +#ifdef ENABLE_COMPANDER + const char gSubMenu_Compand[3][6] = + { + "OFF", + "TX", + "TX/RX" + }; +#endif + bool gIsInSubMenu; uint8_t gMenuCursor; int8_t gMenuScrollDirection; @@ -405,7 +414,10 @@ void UI_DisplayMenu(void) #ifdef ENABLE_COMPANDER case MENU_COMPAND: + strcpy(String, gSubMenu_Compand[gSubMenuSelection]); + break; #endif + case MENU_BCL: case MENU_BEEP: case MENU_S_ADD1: diff --git a/ui/menu.h b/ui/menu.h index fdf17a3..367f774 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -121,6 +121,9 @@ extern const char gSubMenu_PONMSG[4][5]; extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_F_LOCK[6][4]; +#ifdef ENABLE_COMPANDER + extern const char gSubMenu_Compand[3][6]; +#endif extern bool gIsInSubMenu;