0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-29 14:51:26 +03:00

modulation mode update

This commit is contained in:
OneOfEleven 2023-10-30 01:51:41 +00:00
parent 0596b74719
commit ff642dfb8d
14 changed files with 95 additions and 38 deletions

View File

@ -86,7 +86,7 @@ static void APP_update_rssi(const int vfo)
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// add RF gain adjust compensation // add RF gain adjust compensation
if (g_eeprom.vfo_info[vfo].am_mode && g_setting_am_fix) if (g_eeprom.vfo_info[vfo].am_mode > 0 && g_setting_am_fix)
rssi -= rssi_gain_diff[vfo]; rssi -= rssi_gain_diff[vfo];
#endif #endif
@ -532,7 +532,7 @@ bool APP_start_listening(void)
} }
// AF gain - original QS values // AF gain - original QS values
// if (g_rx_vfo->am_mode) // if (g_rx_vfo->am_mode > 0)
// { // {
// BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000 // BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000
// } // }
@ -550,12 +550,12 @@ bool APP_start_listening(void)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
#ifdef MUTE_AUDIO_FOR_VOICE #ifdef MUTE_AUDIO_FOR_VOICE
if (g_voice_write_index == 0) if (g_voice_write_index == 0)
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); AUDIO_set_mod_mode(g_rx_vfo->am_mode);
#else #else
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); AUDIO_set_mod_mode(g_rx_vfo->am_mode);
#endif #endif
#else #else
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); AUDIO_set_mod_mode(g_rx_vfo->am_mode);
#endif #endif
// enable the speaker // enable the speaker
@ -2439,7 +2439,7 @@ void APP_time_slice_10ms(void)
#endif #endif
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (g_rx_vfo->am_mode && g_setting_am_fix) if (g_rx_vfo->am_mode > 0 && g_setting_am_fix)
AM_fix_10ms(g_eeprom.rx_vfo); AM_fix_10ms(g_eeprom.rx_vfo);
#endif #endif

View File

@ -209,7 +209,12 @@ void processFKeyFunction(const key_code_t Key)
if (g_fkey_pressed) if (g_fkey_pressed)
{ {
#if 0
g_tx_vfo->am_mode = (g_tx_vfo->am_mode + 1) & 1u; g_tx_vfo->am_mode = (g_tx_vfo->am_mode + 1) & 1u;
#else
if (++g_tx_vfo->am_mode >= 4)
g_tx_vfo->am_mode = 0;
#endif
g_request_save_channel = 1; g_request_save_channel = 1;
} }
else else

View File

@ -257,11 +257,15 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_DTMF_ST: case MENU_DTMF_ST:
case MENU_DTMF_DCD: case MENU_DTMF_DCD:
case MENU_DTMF_LIVE_DEC: case MENU_DTMF_LIVE_DEC:
case MENU_MOD_MODE:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1; *pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1;
break; break;
case MENU_MOD_MODE:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_mod_mode) - 1;
break;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
case MENU_NOAA_SCAN: case MENU_NOAA_SCAN:
#endif #endif

22
audio.c
View File

@ -76,6 +76,20 @@
beep_type_t g_beep_to_play = BEEP_NONE; beep_type_t g_beep_to_play = BEEP_NONE;
void AUDIO_set_mod_mode(const unsigned int mode)
{
BK4819_af_type_t af_mode;
switch (mode)
{
default:
case 0: af_mode = BK4819_AF_FM; break;
case 1: af_mode = BK4819_AF_AM; break;
case 2: af_mode = BK4819_AF_BASEBAND1; break;
case 3: af_mode = BK4819_AF_BASEBAND2; break;
}
BK4819_SetAF(af_mode);
}
void AUDIO_PlayBeep(beep_type_t Beep) void AUDIO_PlayBeep(beep_type_t Beep)
{ {
const uint16_t tone_val = BK4819_ReadRegister(0x71); const uint16_t tone_val = BK4819_ReadRegister(0x71);
@ -224,10 +238,6 @@ void AUDIO_PlayBeep(beep_type_t Beep)
BK4819_WriteRegister(0x71, tone_val); BK4819_WriteRegister(0x71, tone_val);
// BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
// BK4819_SetAF(BK4819_AF_MUTE);
// BK4819_WriteRegister(0x47, af_val);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Mute(false); BK1080_Mute(false);
@ -327,7 +337,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
SYSTEM_DelayMs(Delay * 10); SYSTEM_DelayMs(Delay * 10);
if (g_current_function == FUNCTION_RECEIVE) if (g_current_function == FUNCTION_RECEIVE)
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); AUDIO_set_mod_mode(g_rx_vfo->am_mode);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
@ -475,7 +485,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
// unmute the radios audio // unmute the radios audio
if (g_current_function == FUNCTION_RECEIVE) if (g_current_function == FUNCTION_RECEIVE)
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); AUDIO_set_mod_mode(g_rx_vfo->am_mode);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)

View File

@ -36,6 +36,7 @@ typedef enum beep_type_e beep_type_t;
extern beep_type_t g_beep_to_play; extern beep_type_t g_beep_to_play;
void AUDIO_set_mod_mode(const unsigned int mode);
void AUDIO_PlayBeep(beep_type_t Beep); void AUDIO_PlayBeep(beep_type_t Beep);
enum { enum {

Binary file not shown.

Binary file not shown.

View File

@ -52,7 +52,7 @@ void FUNCTION_Init(void)
{ {
g_current_code_type = g_selected_code_type; g_current_code_type = g_selected_code_type;
if (g_css_scan_mode == CSS_SCAN_MODE_OFF) if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
g_current_code_type = g_rx_vfo->am_mode ? CODE_TYPE_NONE : g_rx_vfo->p_rx->code_type; g_current_code_type = (g_rx_vfo->am_mode > 0) ? CODE_TYPE_NONE : g_rx_vfo->p_rx->code_type;
} }
else else
g_current_code_type = CODE_TYPE_CONTINUOUS_TONE; g_current_code_type = CODE_TYPE_CONTINUOUS_TONE;

30
radio.c
View File

@ -373,7 +373,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
if (Channel <= USER_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
EEPROM_ReadBuffer(0x0F50 + (Channel * 16), p_vfo->name, 10); // only 10 bytes used EEPROM_ReadBuffer(0x0F50 + (Channel * 16), p_vfo->name, 10); // only 10 bytes used
if (p_vfo->am_mode) if (p_vfo->am_mode > 0)
{ // freq/chan is in AM mode { // freq/chan is in AM mode
// disable stuff, even though it can all still be used with AM ??? // disable stuff, even though it can all still be used with AM ???
p_vfo->scrambling_type = 0; p_vfo->scrambling_type = 0;
@ -385,7 +385,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
RADIO_ConfigureSquelchAndOutputPower(p_vfo); RADIO_ConfigureSquelchAndOutputPower(p_vfo);
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (p_vfo->am_mode && g_setting_am_fix) if (p_vfo->am_mode > 0 && g_setting_am_fix)
{ {
AM_fix_reset(VFO); AM_fix_reset(VFO);
AM_fix_10ms(VFO); AM_fix_10ms(VFO);
@ -396,7 +396,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0)); BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
} }
#else #else
if (p_vfo->am_mode) if (p_vfo->am_mode > 0)
{ {
BK4819_EnableAGC(); BK4819_EnableAGC();
} }
@ -650,8 +650,15 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// BK4819_SetFilterBandwidth(Bandwidth, g_rx_vfo->am_mode && g_setting_am_fix); #if 0
// BK4819_SetFilterBandwidth(Bandwidth, g_rx_vfo->am_mode > 0 && g_setting_am_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
#else
if (g_rx_vfo->am_mode > 1)
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER, false);
else
BK4819_SetFilterBandwidth(Bandwidth, true);
#endif
#else #else
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
#endif #endif
@ -695,7 +702,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true);
// AF RX Gain and DAC // AF RX Gain and DAC
// if (g_rx_vfo->am_mode) // if (g_rx_vfo->am_mode > 0)
// { // {
// BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000 // BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000
// } // }
@ -871,8 +878,15 @@ void RADIO_enableTX(const bool fsk_tx)
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// BK4819_SetFilterBandwidth(Bandwidth, g_current_vfo->am_mode && g_setting_am_fix); #if 0
// BK4819_SetFilterBandwidth(Bandwidth, g_current_vfo->am_mode > 0 && g_setting_am_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
#else
if (g_current_vfo->am_mode > 1)
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER, false);
else
BK4819_SetFilterBandwidth(Bandwidth, true);
#endif
#else #else
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
#endif #endif
@ -984,8 +998,8 @@ void RADIO_PrepareTX(void)
RADIO_SelectCurrentVfo(); RADIO_SelectCurrentVfo();
#ifndef ENABLE_TX_WHEN_AM #ifndef ENABLE_TX_WHEN_AM
if (g_current_vfo->am_mode) if (g_current_vfo->am_mode > 0)
{ // not allowed to TX if in AM mode { // not allowed to TX if not in FM mode
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
else else

View File

@ -277,7 +277,7 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c
#endif #endif
m_channel.tx_offset_dir = p_vfo->tx_offset_freq_dir; m_channel.tx_offset_dir = p_vfo->tx_offset_freq_dir;
// m_channel.unused3:2 // m_channel.unused3:2
m_channel.am_mode = p_vfo->am_mode & 1u; m_channel.am_mode = p_vfo->am_mode;
// m_channel.unused4:3 // m_channel.unused4:3
m_channel.frequency_reverse = p_vfo->frequency_reverse; m_channel.frequency_reverse = p_vfo->frequency_reverse;
m_channel.channel_bandwidth = p_vfo->channel_bandwidth; m_channel.channel_bandwidth = p_vfo->channel_bandwidth;

View File

@ -156,8 +156,13 @@ typedef struct {
#else #else
uint8_t unused3:2; // uint8_t unused3:2; //
#endif #endif
#if 0
uint8_t am_mode:1; // uint8_t am_mode:1; //
uint8_t unused4:3; // uint8_t unused4:3; //
#else
uint8_t am_mode:2; //
uint8_t unused4:2; //
#endif
// [12] // [12]
uint8_t frequency_reverse:1; // reverse repeater uint8_t frequency_reverse:1; // reverse repeater
uint8_t channel_bandwidth:1; // wide/narrow uint8_t channel_bandwidth:1; // wide/narrow

View File

@ -838,9 +838,17 @@ void UI_DisplayMain(void)
// ************ // ************
str[0] = '\0'; str[0] = '\0';
if (g_eeprom.vfo_info[vfo_num].am_mode) if (g_eeprom.vfo_info[vfo_num].am_mode > 0)
{ // show the AM symbol {
strcpy(str, "AM"); //strcpy(str, g_sub_menu_mod_mode[g_eeprom.vfo_info[vfo_num].am_mode]);
switch (g_eeprom.vfo_info[vfo_num].am_mode)
{
default:
case 0: strcpy(str, "FM"); break;
case 1: strcpy(str, "AM"); break;
case 2: strcpy(str, "LS"); break;
case 3: strcpy(str, "US"); break;
}
} }
else else
{ // or show the CTCSS/DCS symbol { // or show the CTCSS/DCS symbol
@ -855,7 +863,7 @@ void UI_DisplayMain(void)
#ifdef ENABLE_TX_WHEN_AM #ifdef ENABLE_TX_WHEN_AM
if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM)
#else #else
if ((state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) && !g_eeprom.vfo_info[vfo_num].am_mode) // not allowed to TX if in AM mode if ((state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) && g_eeprom.vfo_info[vfo_num].am_mode == 0) // not allowed to TX if not in FM mode
#endif #endif
{ {
if (FREQUENCY_tx_freq_check(g_eeprom.vfo_info[vfo_num].p_tx->frequency) == 0) if (FREQUENCY_tx_freq_check(g_eeprom.vfo_info[vfo_num].p_tx->frequency) == 0)
@ -949,7 +957,7 @@ void UI_DisplayMain(void)
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
// show the AM-FIX debug data // show the AM-FIX debug data
if (rx && g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix) if (rx && g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode > 0 && g_setting_am_fix)
{ {
g_center_line = CENTER_LINE_AM_FIX_DATA; g_center_line = CENTER_LINE_AM_FIX_DATA;
AM_fix_print_data(g_eeprom.rx_vfo, str); AM_fix_print_data(g_eeprom.rx_vfo, str);

View File

@ -174,6 +174,14 @@ const unsigned int g_hidden_menu_count = 9;
// *************************************************************************************** // ***************************************************************************************
const char g_sub_menu_mod_mode[4][4] =
{
"FM",
"AM",
"LSB",
"USB"
};
const char g_sub_menu_tx_power[3][7] = const char g_sub_menu_tx_power[3][7] =
{ {
"LOW", "LOW",
@ -722,7 +730,8 @@ void UI_DisplayMenu(void)
break; break;
case MENU_MOD_MODE: case MENU_MOD_MODE:
strcpy(str, (g_sub_menu_selection == 0) ? "FM" : "AM"); // strcpy(str, (g_sub_menu_selection == 0) ? "FM" : "AM");
strcpy(str, g_sub_menu_mod_mode[g_sub_menu_selection]);
break; break;
#ifdef ENABLE_AM_FIX_TEST1 #ifdef ENABLE_AM_FIX_TEST1

View File

@ -162,6 +162,7 @@ enum
extern const t_menu_item g_menu_list[]; extern const t_menu_item g_menu_list[];
extern uint8_t g_menu_list_sorted[]; extern uint8_t g_menu_list_sorted[];
extern const char g_sub_menu_mod_mode[4][4];
extern const char g_sub_menu_tx_power[3][7]; extern const char g_sub_menu_tx_power[3][7];
extern const char g_sub_menu_shift_dir[3][4]; extern const char g_sub_menu_shift_dir[3][4];
extern const char g_sub_menu_bandwidth[2][7]; extern const char g_sub_menu_bandwidth[2][7];