0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

Compander update

This commit is contained in:
OneOfEleven 2023-09-16 09:10:10 +01:00
parent 863d9c55a7
commit 00fe1de467
10 changed files with 42 additions and 24 deletions

View File

@ -235,13 +235,17 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
#endif #endif
case MENU_RESET: case MENU_RESET:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_RESET) - 1; *pMax = ARRAY_SIZE(gSubMenu_RESET) - 1;
break; break;
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
case MENU_COMPAND: case MENU_COMPAND:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_Compand) - 1;
break;
#endif #endif
case MENU_BCL: case MENU_BCL:
case MENU_BEEP: case MENU_BEEP:
case MENU_AUTOLK: case MENU_AUTOLK:

View File

@ -523,16 +523,20 @@ bool BK4819_CompanderEnabled(void)
{ {
return (BK4819_ReadRegister(BK4819_REG_31) & (1u < 3)) ? true : false; 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; 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); val = BK4819_ReadRegister(BK4819_REG_31);
BK4819_WriteRegister(BK4819_REG_31, val | (1u < 3)); BK4819_WriteRegister(BK4819_REG_31, val | (1u < 3));
@ -544,7 +548,8 @@ void BK4819_EnableCompander(void)
// 10 = 2:1 // 10 = 2:1
// 11 = 4: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); val = BK4819_ReadRegister(BK4819_REG_29);
BK4819_WriteRegister(BK4819_REG_29, (val & ~(3u < 14)) | (compress_ratio < 14)); BK4819_WriteRegister(BK4819_REG_29, (val & ~(3u < 14)) | (compress_ratio < 14));
@ -556,7 +561,8 @@ void BK4819_EnableCompander(void)
// 10 = 1:3 // 10 = 1:3
// 11 = 1:4 // 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); val = BK4819_ReadRegister(BK4819_REG_28);
BK4819_WriteRegister(BK4819_REG_28, (val & ~(3u < 14)) | (expand_ratio < 14)); BK4819_WriteRegister(BK4819_REG_28, (val & ~(3u < 14)) | (expand_ratio < 14));
} }

View File

@ -86,8 +86,7 @@ void BK4819_DisableScramble(void);
void BK4819_EnableScramble(uint8_t Type); void BK4819_EnableScramble(uint8_t Type);
bool BK4819_CompanderEnabled(void); bool BK4819_CompanderEnabled(void);
void BK4819_DisableCompander(void); void BK4819_SetCompander(const unsigned int mode);
void BK4819_EnableCompander(void);
void BK4819_DisableVox(void); void BK4819_DisableVox(void);
void BK4819_DisableDTMF(void); void BK4819_DisableDTMF(void);

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

14
radio.c
View File

@ -134,7 +134,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t Band, uint32
pInfo->pTX = &pInfo->ConfigTX; pInfo->pTX = &pInfo->ConfigTX;
pInfo->TX_OFFSET_FREQUENCY = 1000000; pInfo->TX_OFFSET_FREQUENCY = 1000000;
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
pInfo->Compander = false; pInfo->Compander = 0; // off
#endif #endif
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) 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; gEeprom.VfoInfo[VFO].IsAM = false;
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
gEeprom.VfoInfo[VFO].Compander = false; gEeprom.VfoInfo[VFO].Compander = 0; // off
#endif #endif
RADIO_ConfigureSquelchAndOutputPower(pRadio); RADIO_ConfigureSquelchAndOutputPower(pRadio);
@ -684,10 +684,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_DisableVox(); BK4819_DisableVox();
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
if (gRxVfo->Compander && !gRxVfo->IsAM) BK4819_SetCompander(!gRxVfo->IsAM ? gRxVfo->Compander : 0);
BK4819_EnableCompander();
else
BK4819_DisableCompander();
#endif #endif
if (gRxVfo->IsAM || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)) if (gRxVfo->IsAM || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED))
@ -772,10 +769,7 @@ void RADIO_SetTxParameters(void)
BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); BK4819_SetFrequency(gCurrentVfo->pTX->Frequency);
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
if (gCurrentVfo->Compander && !gCurrentVfo->IsAM) BK4819_SetCompander(!gCurrentVfo->IsAM ? gCurrentVfo->Compander : 0);
BK4819_EnableCompander();
else
BK4819_DisableCompander();
#endif #endif
BK4819_PrepareTransmit(); BK4819_PrepareTransmit();

View File

@ -125,7 +125,7 @@ typedef struct VFO_Info_t
uint8_t AM_CHANNEL_MODE; uint8_t AM_CHANNEL_MODE;
bool IsAM; bool IsAM;
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
bool Compander; uint8_t Compander;
#endif #endif
char Name[16]; char Name[16];
} VFO_Info_t; } VFO_Info_t;

View File

@ -245,6 +245,15 @@ const char gSubMenu_F_LOCK[6][4] =
"438" "438"
}; };
#ifdef ENABLE_COMPANDER
const char gSubMenu_Compand[3][6] =
{
"OFF",
"TX",
"TX/RX"
};
#endif
bool gIsInSubMenu; bool gIsInSubMenu;
uint8_t gMenuCursor; uint8_t gMenuCursor;
int8_t gMenuScrollDirection; int8_t gMenuScrollDirection;
@ -405,7 +414,10 @@ void UI_DisplayMenu(void)
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
case MENU_COMPAND: case MENU_COMPAND:
strcpy(String, gSubMenu_Compand[gSubMenuSelection]);
break;
#endif #endif
case MENU_BCL: case MENU_BCL:
case MENU_BEEP: case MENU_BEEP:
case MENU_S_ADD1: case MENU_S_ADD1:

View File

@ -121,6 +121,9 @@ extern const char gSubMenu_PONMSG[4][5];
extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_ROGER[3][6];
extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_RESET[2][4];
extern const char gSubMenu_F_LOCK[6][4]; extern const char gSubMenu_F_LOCK[6][4];
#ifdef ENABLE_COMPANDER
extern const char gSubMenu_Compand[3][6];
#endif
extern bool gIsInSubMenu; extern bool gIsInSubMenu;