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

More voice scrambler menu options

This commit is contained in:
OneOfEleven 2023-11-04 01:59:17 +00:00
parent 935e552b02
commit 004c6dfea9
11 changed files with 106 additions and 77 deletions

View File

@ -21,7 +21,7 @@ ENABLE_AIRCOPY_RX_REBOOT := 0
ENABLE_FMRADIO_64_76 := 0
ENABLE_FMRADIO_76_90 := 0
ENABLE_FMRADIO_76_108 := 0
ENABLE_FMRADIO_875_108 := 0
ENABLE_FMRADIO_875_108 := 1
ENABLE_FMRADIO_64_108 := 0
# NOAA 1.2 kB
ENABLE_NOAA := 0
@ -78,7 +78,7 @@ ENABLE_RX_SIGNAL_BAR := 1
# Tx Audio Bar 300 B
ENABLE_TX_AUDIO_BAR := 0
# Side Button Menu 300 B
ENABLE_SIDE_BUTT_MENU := 1
ENABLE_SIDE_BUTT_MENU := 0
# Key Lock 400 B
ENABLE_KEYLOCK := 0
#ENABLE_PANADAPTER := 0

View File

@ -2716,7 +2716,8 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
if (g_current_vfo->channel.scrambler == 0 || !g_eeprom.config.setting.enable_scrambler)
BK4819_DisableScramble();
else
BK4819_EnableScramble(g_current_vfo->channel.scrambler - 1);
//BK4819_EnableScramble(g_current_vfo->channel.scrambler - 1);
BK4819_EnableScramble(2600 + ((g_current_vfo->channel.scrambler - 1) * 100));
}
}
else

View File

@ -498,7 +498,8 @@ void MENU_AcceptSetting(void)
g_tx_vfo->channel.scrambler = g_sub_menu_selection;
#if 0
if (g_sub_menu_selection > 0 && g_eeprom.config.setting.enable_scrambler)
BK4819_EnableScramble(g_sub_menu_selection - 1);
// BK4819_EnableScramble(g_sub_menu_selection - 1);
BK4819_EnableScramble(2600 + ((g_sub_menu_selection - 1) * 100));
else
BK4819_DisableScramble();
#endif
@ -856,7 +857,7 @@ void MENU_AcceptSetting(void)
case MENU_SCRAMBLER_EN:
g_eeprom.config.setting.enable_scrambler = g_sub_menu_selection;
g_flag_reconfigure_vfos = true;
g_flag_reconfigure_vfos = true;
break;
case MENU_TX_EN:

View File

@ -43,9 +43,9 @@ BK4819_filter_bandwidth_t m_bandwidth = BK4819_FILTER_BW_NARROW;
bool g_rx_idle_mode;
__inline uint16_t scale_freq(const uint16_t freq)
{
// return (((uint32_t)freq * 1032444u) + 50000u) / 100000u; // with rounding
return (((uint32_t)freq * 1353245u) + (1u << 16)) >> 17; // with rounding
{ // with rounding
// return (((uint32_t)freq * 1032444u) + 50000u) / 100000u;
return (((uint32_t)freq * 338311u) + (1u << 14)) >> 15; // max freq = 12695
}
void BK4819_Init(void)
@ -67,10 +67,7 @@ void BK4819_Init(void)
BK4819_EnableAGC(); // only do this in linear modulation modes, not FM
#endif
// BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable
// BK4819_WriteRegister(0x7D, 0xE940); // 111010010100 0000
BK4819_WriteRegister(0x7D, 0xE940 | 0x1f);
BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable
BK4819_set_mic_gain(31);
// REG_48 .. RX AF level
//
@ -96,6 +93,15 @@ void BK4819_Init(void)
(58u << 4) | // AF Rx Gain-2
( 8u << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
// squelch mode
// BK4819_WriteRegister(0x77, 0x88EF); // rssi + noise + glitch .. RT-890
// BK4819_WriteRegister(0x77, 0xA8EF); // rssi + noise + glitch .. default
BK4819_WriteRegister(0x77, 0xAAEF); // rssi + glitch
// BK4819_WriteRegister(0x77, 0xCCEF); // rssi + noise
// BK4819_WriteRegister(0x77, 0xFFEF); // rssi
// BK4819_WriteRegister(0x73, (0u << 11) | (1u << 4)); // disable AFC
BK4819_config_sub_audible();
#if 1
@ -154,7 +160,6 @@ void BK4819_Init(void)
BK4819_WriteRegister(0x53, 0xE678);
BK4819_WriteRegister(0x2C, 0x5705);
BK4819_WriteRegister(0x4B, 0x7102);
BK4819_WriteRegister(0x77, 0x88EF);
BK4819_WriteRegister(0x26, 0x13A0);
#endif
}
@ -498,7 +503,7 @@ void BK4819_SetFilterBandwidth(const BK4819_filter_bandwidth_t Bandwidth, const
val =
(0u << 15) | // 0
(4u << 12) | // *3 RF filter bandwidth
(4u << 9) | // *0 RF filter bandwidth when signal is weak
(2u << 9) | // *0 RF filter bandwidth when signal is weak
(6u << 6) | // *0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection
(1u << 3) | // 1
@ -525,7 +530,7 @@ void BK4819_SetFilterBandwidth(const BK4819_filter_bandwidth_t Bandwidth, const
val =
(0u << 15) | // 0
(4u << 12) | // *4 RF filter bandwidth
(4u << 9) | // *0 RF filter bandwidth when signal is weak
(2u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1
@ -767,13 +772,23 @@ void BK4819_DisableScramble(void)
BK4819_WriteRegister(0x31, Value & ~(1u << 1));
}
void BK4819_EnableScramble(uint8_t Type)
#if 0
void BK4819_EnableScramble(const uint8_t Type)
{
const uint16_t Value = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31, Value | (1u << 1));
BK4819_WriteRegister(0x71, 0x68DC + (Type * 1032)); // 0110 1000 1101 1100
BK4819_WriteRegister(0x71, (26 + Type) * 1032);
}
#else
void BK4819_EnableScramble(const uint16_t freq)
{
const uint16_t Value = BK4819_ReadRegister(0x31);
BK4819_WriteRegister(0x31, Value | (1u << 1));
BK4819_WriteRegister(0x71, scale_freq(freq));
}
#endif
bool BK4819_CompanderEnabled(void)
{
@ -1025,6 +1040,26 @@ void BK4819_Sleep(void)
BK4819_WriteRegister(0x37, 0x1D00); // 0 0 0111 0 1 0000 0 0 0 0
}
void BK4819_setTxAudio(const unsigned int mode)
{
switch (mode)
{
case 0:
break;
case 1:
BK4819_WriteRegister(0x53,0xE678); // ???
BK4819_WriteRegister(0x4B,0x7102); // enable TX audio AGC
BK4819_WriteRegister(0x27,0x7430); // ???
// BK4819_WriteRegister(0x29,0xAB2A);
break;
case 2:
BK4819_WriteRegister(0x4B,0x7120); // disable TX audio AGC
BK4819_WriteRegister(0x27,0xC430); // ???
// BK4819_WriteRegister(0x29,0xAB20);
break;
}
}
void BK4819_set_mic_gain(unsigned int level)
{
if (level > 31)
@ -1032,7 +1067,11 @@ void BK4819_set_mic_gain(unsigned int level)
// mic gain 0.5dB/step 0 to 31
BK4819_WriteRegister(0x7D, 0xE940 | level);
// BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable .. doesn't work
// BK4819_WriteRegister(0x19, BK4819_ReadRegister(0x19) & ~(1u << 15)); // enable mic AGC
// BK4819_setTxAudio(1);
}
void BK4819_TurnsOffTones_TurnsOnRX(void)
@ -1232,8 +1271,8 @@ void BK4819_PlayDTMF(char Code)
if (index < 16)
{
BK4819_WriteRegister(0x71, (((uint32_t)tones[0][index] * 103244u) + 5000u) / 10000u); // with rounding
BK4819_WriteRegister(0x72, (((uint32_t)tones[1][index] * 103244u) + 5000u) / 10000u); // with rounding
BK4819_WriteRegister(0x71, scale_freq(tones[0][index]));
BK4819_WriteRegister(0x72, scale_freq(tones[1][index]));
}
}
@ -1808,7 +1847,7 @@ void BK4819_reset_fsk(void)
//
// tone-2 = 1200Hz
//
BK4819_WriteRegister(0x72, ((1200u * 103244) + 5000) / 10000); // with rounding
BK4819_WriteRegister(0x72, scale_freq(1200));
// aircopy is done in direct FM mode
//
@ -2072,7 +2111,7 @@ void BK4819_reset_fsk(void)
( 1u << 7) | // 1
(96u << 0)); // 96
BK4819_WriteRegister(0x72, ((1200u * 103244) + 5000) / 10000); // with rounding
BK4819_WriteRegister(0x72, scale_freq(1200));
BK4819_WriteRegister(0x58,
(1u << 13) | // 1 FSK TX mode selection
@ -2230,12 +2269,14 @@ void BK4819_reset_fsk(void)
// REG_2B 0
//
// <10> 0 AF RX HPF 300Hz filter 0 = enable 1 = disable
// <9> 0 AF RX LPF 3kHz filter 0 = enable 1 = disable
// <8> 0 AF RX de-emphasis filter 0 = enable 1 = disable
// <2> 0 AF TX HPF 300Hz filter 0 = enable 1 = disable
// <1> 0 AF TX LPF filter 0 = enable 1 = disable
// <0> 0 AF TX pre-emphasis filter 0 = enable 1 = disable
// <15> 1 Enable CTCSS/CDCSS DC cancellation after FM Demodulation 1 = enable 0 = disable
// <14> 1 Enable AF DC cancellation after FM Demodulation 1 = enable 0 = disable
// <10> 0 AF RX HPF 300Hz filter 0 = enable 1 = disable
// <9> 0 AF RX LPF 3kHz filter 0 = enable 1 = disable
// <8> 0 AF RX de-emphasis filter 0 = enable 1 = disable
// <2> 0 AF TX HPF 300Hz filter 0 = enable 1 = disable
// <1> 0 AF TX LPF filter 0 = enable 1 = disable
// <0> 0 AF TX pre-emphasis filter 0 = enable 1 = disable
//
// disable the 300Hz HPF and FM pre-emphasis filter
//
@ -2302,7 +2343,7 @@ void BK4819_reset_fsk(void)
//
// tone-2 = 1200Hz
//
BK4819_WriteRegister(0x72, ((1200u * 103244) + 5000) / 10000); // with rounding
BK4819_WriteRegister(0x72, scale_freq(1200));
// REG_70
//

View File

@ -95,7 +95,8 @@ void BK4819_SetAF(BK4819_af_type_t AF);
void BK4819_RX_TurnOn(void);
void BK4819_set_rf_filter_path(uint32_t Frequency);
void BK4819_DisableScramble(void);
void BK4819_EnableScramble(uint8_t Type);
//void BK4819_EnableScramble(const uint8_t Type);
void BK4819_EnableScramble(const uint16_t freq);
bool BK4819_CompanderEnabled(void);
void BK4819_SetCompander(const unsigned int mode);

Binary file not shown.

Binary file not shown.

View File

@ -303,7 +303,8 @@ void FUNCTION_Select(function_type_t Function)
*/
if (g_current_vfo->channel.scrambler > 0 && g_eeprom.config.setting.enable_scrambler)
{
BK4819_EnableScramble(g_current_vfo->channel.scrambler - 1);
// BK4819_EnableScramble(g_current_vfo->channel.scrambler - 1);
BK4819_EnableScramble(2600 + ((g_current_vfo->channel.scrambler - 1) * 100));
}
break;

46
radio.c
View File

@ -408,18 +408,10 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
{
// uint8_t tx_power[3];
// uint16_t base;
// frequency_band_t band;
uint8_t squelch_level;
// *******************************
// squelch
// band = FREQUENCY_GetBand(p_vfo->p_rx->frequency);
// base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00;
squelch_level = (p_vfo->channel.squelch_level > 0) ? p_vfo->channel.squelch_level : g_eeprom.config.setting.squelch_level;
const unsigned int squelch_level = (p_vfo->channel.squelch_level > 0) ? p_vfo->channel.squelch_level : g_eeprom.config.setting.squelch_level;
// note that 'noise' and 'glitch' values are inverted compared to 'rssi' values
@ -436,18 +428,6 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
}
else
{ // squelch >= 1
#if 0
Base += squelch_level; // my eeprom squelch-1
// VHF UHF
EEPROM_ReadBuffer(Base + 0x00, &p_vfo->squelch_open_rssi_thresh, 1); // 50 10
EEPROM_ReadBuffer(Base + 0x10, &p_vfo->squelch_close_rssi_thresh, 1); // 40 5
EEPROM_ReadBuffer(Base + 0x20, &p_vfo->squelch_open_noise_thresh, 1); // 65 90
EEPROM_ReadBuffer(Base + 0x30, &p_vfo->squelch_close_noise_thresh, 1); // 70 100
EEPROM_ReadBuffer(Base + 0x40, &p_vfo->squelch_close_glitch_thresh, 1); // 90 90 BUG ??? .. these 2 swapped ?
EEPROM_ReadBuffer(Base + 0x50, &p_vfo->squelch_open_glitch_thresh, 1); // 100 100 " "
#else
unsigned int band = (unsigned int)FREQUENCY_GetBand(p_vfo->p_rx->frequency);
band = (band < BAND4_174MHz) ? 1 : 0;
@ -459,18 +439,15 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
p_vfo->squelch_open_glitch_thresh = g_eeprom.calib.squelch_band[band].open_glitch_thresh[squelch_level];
p_vfo->squelch_close_glitch_thresh = g_eeprom.calib.squelch_band[band].close_glitch_thresh[squelch_level];
#endif
// *********
// used in AM mode
int16_t rssi_open = p_vfo->squelch_open_rssi_thresh; // 0 ~ 255
int16_t rssi_close = p_vfo->squelch_close_rssi_thresh; // 0 ~ 255
// used in FM mode
int16_t noise_open = p_vfo->squelch_open_noise_thresh; // 127 ~ 0
int16_t noise_close = p_vfo->squelch_close_noise_thresh; // 127 ~ 0
// used in both modes ?
int16_t glitch_open = p_vfo->squelch_open_glitch_thresh; // 255 ~ 0
int16_t glitch_close = p_vfo->squelch_close_glitch_thresh; // 255 ~ 0
@ -482,19 +459,19 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
// getting the best general settings here is experimental, bare with me
#if 0
// rssi_open = (rssi_open * 8) / 9;
rssi_open = (rssi_open * 8) / 9;
noise_open = (noise_open * 9) / 8;
glitch_open = (glitch_open * 9) / 8;
#else
// even more sensitive .. use when RX bandwidths are fixed (no weak signal auto adjust)
// rssi_open = (rssi_open * 1) / 2;
rssi_open = (rssi_open * 1) / 2;
noise_open = (noise_open * 2) / 1;
glitch_open = (glitch_open * 2) / 1;
#endif
#else
// more sensitive .. use when RX bandwidths are fixed (no weak signal auto adjust)
// rssi_open = (rssi_open * 3) / 4;
rssi_open = (rssi_open * 3) / 4;
noise_open = (noise_open * 4) / 3;
glitch_open = (glitch_open * 4) / 3;
#endif
@ -503,14 +480,14 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
// ensure the 'close' threshold is lower than the 'open' threshold
// ie, maintain a minimum level of hysteresis
// rssi_close = (rssi_open * 4) / 6;
rssi_close = (rssi_open * 4) / 6;
noise_close = (noise_open * 6) / 4;
glitch_close = (glitch_open * 6) / 4;
// if (rssi_open < 8)
// rssi_open = 8;
// if (rssi_close > (rssi_open - 8))
// rssi_close = rssi_open - 8;
if (rssi_open < 8)
rssi_open = 8;
if (rssi_close > (rssi_open - 8))
rssi_close = rssi_open - 8;
if (noise_open > (127 - 4))
noise_open = 127 - 4;
@ -814,7 +791,8 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
}
if (g_rx_vfo->channel.scrambler > 0 && g_eeprom.config.setting.enable_scrambler)
BK4819_EnableScramble(g_rx_vfo->channel.scrambler - 1);
// BK4819_EnableScramble(g_rx_vfo->channel.scrambler - 1);
BK4819_EnableScramble(2600 + ((g_rx_vfo->channel.scrambler - 1) * 100));
else
BK4819_DisableScramble();
}

View File

@ -367,9 +367,9 @@ const char g_sub_menu_dis_en[2][9] =
"ENABLED"
};
const char g_sub_menu_scrambler[11][7] =
const char g_sub_menu_scrambler[16][7] =
{
"OFF",
"OFF", // 0
"2600Hz",
"2700Hz",
"2800Hz",
@ -379,7 +379,12 @@ const char g_sub_menu_scrambler[11][7] =
"3200Hz",
"3300Hz",
"3400Hz",
"3500Hz"
"3500Hz", // 10
"3600Hz",
"3700Hz",
"3800Hz",
"3900Hz",
"4000Hz" // 15
};
#ifdef ENABLE_SIDE_BUTT_MENU
@ -707,7 +712,8 @@ void UI_DisplayMenu(void)
#if 1
if (g_sub_menu_selection > 0 && g_eeprom.config.setting.enable_scrambler)
BK4819_EnableScramble(g_sub_menu_selection - 1);
// BK4819_EnableScramble(g_sub_menu_selection - 1);
BK4819_EnableScramble(2600 + ((g_sub_menu_selection - 1) * 100));
else
BK4819_DisableScramble();
#endif

View File

@ -194,7 +194,7 @@ extern const char g_sub_menu_rx_tx[4][6];
#endif
extern const char g_sub_menu_bat_text[3][8];
extern const char g_sub_menu_dis_en[2][9];
extern const char g_sub_menu_scrambler[11][7];
extern const char g_sub_menu_scrambler[16][7];
#ifdef ENABLE_SIDE_BUTT_MENU
extern const char g_sub_menu_side_butt[9][16];
#endif