diff --git a/app/app.c b/app/app.c index b5becc2..d51f210 100644 --- a/app/app.c +++ b/app/app.c @@ -86,7 +86,7 @@ static void APP_update_rssi(const int vfo) #ifdef ENABLE_AM_FIX // 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]; #endif @@ -532,7 +532,7 @@ bool APP_start_listening(void) } // 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 // } @@ -550,12 +550,12 @@ bool APP_start_listening(void) #ifdef ENABLE_VOICE #ifdef MUTE_AUDIO_FOR_VOICE 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 - BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); + AUDIO_set_mod_mode(g_rx_vfo->am_mode); #endif #else - BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); + AUDIO_set_mod_mode(g_rx_vfo->am_mode); #endif // enable the speaker @@ -2439,7 +2439,7 @@ void APP_time_slice_10ms(void) #endif #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); #endif diff --git a/app/main.c b/app/main.c index 27aff14..32a9868 100644 --- a/app/main.c +++ b/app/main.c @@ -209,7 +209,12 @@ void processFKeyFunction(const key_code_t Key) if (g_fkey_pressed) { - g_tx_vfo->am_mode = (g_tx_vfo->am_mode + 1) & 1u; + #if 0 + 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; } else diff --git a/app/menu.c b/app/menu.c index a5da416..d5dd151 100644 --- a/app/menu.c +++ b/app/menu.c @@ -257,11 +257,15 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) case MENU_DTMF_ST: case MENU_DTMF_DCD: case MENU_DTMF_LIVE_DEC: - case MENU_MOD_MODE: *pMin = 0; *pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1; break; + case MENU_MOD_MODE: + *pMin = 0; + *pMax = ARRAY_SIZE(g_sub_menu_mod_mode) - 1; + break; + #ifdef ENABLE_NOAA case MENU_NOAA_SCAN: #endif diff --git a/audio.c b/audio.c index 4398d30..3ae78d4 100644 --- a/audio.c +++ b/audio.c @@ -76,6 +76,20 @@ 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) { 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_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 if (g_fm_radio_mode) BK1080_Mute(false); @@ -327,8 +337,8 @@ void AUDIO_PlayBeep(beep_type_t Beep) SYSTEM_DelayMs(Delay * 10); 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 if (g_fm_radio_mode) BK1080_Mute(false); @@ -347,9 +357,9 @@ void AUDIO_PlayBeep(beep_type_t Beep) return; } - g_voice_read_index = 1; + g_voice_read_index = 1; g_play_next_voice_tick_10ms = Delay; - g_flag_play_queued_voice = false; + g_flag_play_queued_voice = false; return; @@ -475,8 +485,8 @@ void AUDIO_PlayBeep(beep_type_t Beep) // unmute the radios audio 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 if (g_fm_radio_mode) BK1080_Mute(false); diff --git a/audio.h b/audio.h index cc4f6c5..8d04dd2 100644 --- a/audio.h +++ b/audio.h @@ -36,6 +36,7 @@ typedef enum beep_type_e beep_type_t; extern beep_type_t g_beep_to_play; +void AUDIO_set_mod_mode(const unsigned int mode); void AUDIO_PlayBeep(beep_type_t Beep); enum { diff --git a/firmware.bin b/firmware.bin index 1c47866..3e2e638 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 81edb15..881d8a7 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 3d7c947..9bffa8b 100644 --- a/functions.c +++ b/functions.c @@ -52,7 +52,7 @@ void FUNCTION_Init(void) { g_current_code_type = g_selected_code_type; 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 g_current_code_type = CODE_TYPE_CONTINUOUS_TONE; diff --git a/radio.c b/radio.c index 906ea9b..e252792 100644 --- a/radio.c +++ b/radio.c @@ -373,7 +373,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur if (Channel <= USER_CHANNEL_LAST) 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 // disable stuff, even though it can all still be used with AM ??? 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); #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_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)); } #else - if (p_vfo->am_mode) + if (p_vfo->am_mode > 0) { BK4819_EnableAGC(); } @@ -650,8 +650,15 @@ void RADIO_setup_registers(bool switch_to_function_foreground) case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #ifdef ENABLE_AM_FIX -// BK4819_SetFilterBandwidth(Bandwidth, g_rx_vfo->am_mode && g_setting_am_fix); - BK4819_SetFilterBandwidth(Bandwidth, true); + #if 0 +// BK4819_SetFilterBandwidth(Bandwidth, g_rx_vfo->am_mode > 0 && g_setting_am_fix); + 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 BK4819_SetFilterBandwidth(Bandwidth, false); #endif @@ -695,7 +702,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true); // 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 // } @@ -871,8 +878,15 @@ void RADIO_enableTX(const bool fsk_tx) case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #ifdef ENABLE_AM_FIX -// BK4819_SetFilterBandwidth(Bandwidth, g_current_vfo->am_mode && g_setting_am_fix); - BK4819_SetFilterBandwidth(Bandwidth, true); + #if 0 +// BK4819_SetFilterBandwidth(Bandwidth, g_current_vfo->am_mode > 0 && g_setting_am_fix); + 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 BK4819_SetFilterBandwidth(Bandwidth, false); #endif @@ -984,8 +998,8 @@ void RADIO_PrepareTX(void) RADIO_SelectCurrentVfo(); #ifndef ENABLE_TX_WHEN_AM - if (g_current_vfo->am_mode) - { // not allowed to TX if in AM mode + if (g_current_vfo->am_mode > 0) + { // not allowed to TX if not in FM mode State = VFO_STATE_TX_DISABLE; } else diff --git a/settings.c b/settings.c index b25c995..72d39c4 100644 --- a/settings.c +++ b/settings.c @@ -277,7 +277,7 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c #endif m_channel.tx_offset_dir = p_vfo->tx_offset_freq_dir; // 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.frequency_reverse = p_vfo->frequency_reverse; m_channel.channel_bandwidth = p_vfo->channel_bandwidth; diff --git a/settings.h b/settings.h index e684436..04f25f3 100644 --- a/settings.h +++ b/settings.h @@ -156,8 +156,13 @@ typedef struct { #else uint8_t unused3:2; // #endif - uint8_t am_mode:1; // - uint8_t unused4:3; // + #if 0 + uint8_t am_mode:1; // + uint8_t unused4:3; // + #else + uint8_t am_mode:2; // + uint8_t unused4:2; // + #endif // [12] uint8_t frequency_reverse:1; // reverse repeater uint8_t channel_bandwidth:1; // wide/narrow diff --git a/ui/main.c b/ui/main.c index 6a0ad12..cf79bee 100644 --- a/ui/main.c +++ b/ui/main.c @@ -838,9 +838,17 @@ void UI_DisplayMain(void) // ************ str[0] = '\0'; - if (g_eeprom.vfo_info[vfo_num].am_mode) - { // show the AM symbol - strcpy(str, "AM"); + if (g_eeprom.vfo_info[vfo_num].am_mode > 0) + { + //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 { // or show the CTCSS/DCS symbol @@ -855,7 +863,7 @@ void UI_DisplayMain(void) #ifdef ENABLE_TX_WHEN_AM if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) #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 { 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) // 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; AM_fix_print_data(g_eeprom.rx_vfo, str); diff --git a/ui/menu.c b/ui/menu.c index 1244276..9f8f503 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -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] = { "LOW", @@ -722,7 +730,8 @@ void UI_DisplayMenu(void) break; 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; #ifdef ENABLE_AM_FIX_TEST1 diff --git a/ui/menu.h b/ui/menu.h index ac14b5f..13cf7f3 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -162,6 +162,7 @@ enum extern const t_menu_item g_menu_list[]; 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_shift_dir[3][4]; extern const char g_sub_menu_bandwidth[2][7];