diff --git a/Makefile b/Makefile index 9035bc3..42ffbcd 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ ENABLE_OVERLAY := 0 ENABLE_LTO := 1 # UART Programming 2.9 kB ENABLE_UART := 1 -ENABLE_UART_DEBUG := 0 +ENABLE_UART_DEBUG := 1 # AirCopy 2.5 kB ENABLE_AIRCOPY := 0 ENABLE_AIRCOPY_REMEMBER_FREQ := 1 @@ -27,7 +27,7 @@ ENABLE_NOAA := 0 ENABLE_VOICE := 0 ENABLE_MUTE_RADIO_FOR_VOICE := 0 # Tx on Voice 1.0 kB -ENABLE_VOX := 1 +ENABLE_VOX := 0 ENABLE_VOX_MORE_SENSITIVE := 1 ENABLE_REDUCE_LOW_MID_TX_POWER := 1 # Tx Alarm 600 B @@ -63,7 +63,7 @@ ENABLE_FREQ_SEARCH_LNA := 1 ENABLE_FREQ_SEARCH_TIMEOUT := 0 ENABLE_CODE_SEARCH_TIMEOUT := 0 ENABLE_SCAN_IGNORE_LIST := 1 -ENABLE_SCAN_RANGES := 1 +ENABLE_SCAN_RANGES := 0 # Kill and Revive 400 B ENABLE_KILL_REVIVE := 0 # AM Fix 800 B diff --git a/app/app.c b/app/app.c index 3c73175..a69888f 100644 --- a/app/app.c +++ b/app/app.c @@ -474,10 +474,10 @@ bool APP_start_listening(void) if (g_scan_state_dir != SCAN_STATE_DIR_OFF) { // we're RF scanning - g_rx_vfo->freq_in_channel = 0xff; + g_current_vfo->freq_in_channel = 0xff; if (IS_FREQ_CHANNEL(g_scan_next_channel)) - g_rx_vfo->freq_in_channel = SETTINGS_find_channel(g_rx_vfo->freq_config_rx.frequency); + g_current_vfo->freq_in_channel = SETTINGS_find_channel(g_current_vfo->freq_config_rx.frequency); switch (g_eeprom.config.setting.carrier_search_mode) { @@ -502,12 +502,12 @@ bool APP_start_listening(void) } #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_mode) + if (IS_NOAA_CHANNEL(g_current_vfo->channel_save) && g_noaa_mode) { - g_rx_vfo->channel_save = g_noaa_channel + NOAA_CHANNEL_FIRST; - g_rx_vfo->p_rx->frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel]; - g_rx_vfo->p_tx->frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel]; - g_eeprom.config.setting.indices.vfo[chan].screen = g_rx_vfo->channel_save; + g_current_vfo->channel_save = g_noaa_channel + NOAA_CHANNEL_FIRST; + g_current_vfo->p_rx->frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel]; + g_current_vfo->p_tx->frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel]; + g_eeprom.config.setting.indices.vfo[chan].screen = g_current_vfo->channel_save; g_noaa_tick_10ms = 5000 / 10; // 5 sec g_schedule_noaa = false; } @@ -527,7 +527,7 @@ bool APP_start_listening(void) } // AF gain - original QS values -// if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM) +// if (g_current_vfo->channel.mod_mode != MOD_MODE_FM) // { // BK4819_write_reg(0x48, 0xB3A8); // 1011 0011 1010 1000 // } @@ -550,12 +550,16 @@ bool APP_start_listening(void) #ifdef ENABLE_VOICE #ifdef MUTE_AUDIO_FOR_VOICE if (g_voice_write_index == 0) - AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); + AUDIO_set_mod_mode(g_current_vfo->channel.mod_mode); #else - AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); + AUDIO_set_mod_mode(g_current_vfo->channel.mod_mode); #endif #else - AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); + AUDIO_set_mod_mode(g_current_vfo->channel.mod_mode); + #endif + + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_printf("mode %u\r\n", g_current_vfo->channel.mod_mode); #endif GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); @@ -1391,8 +1395,8 @@ void APP_check_keys(void) { // only the up and down keys are made repeatable // key repeat max 10ms speed if user is moving up/down in freq/channel - const bool freq_chan = IS_FREQ_CHANNEL(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen); - const uint8_t repeat_10ms = (g_manual_scanning && g_monitor_enabled && freq_chan && g_current_display_screen == DISPLAY_MAIN) ? 1 : key_repeat_10ms; + const bool freq_chan = IS_FREQ_CHANNEL(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen); + const uint8_t repeat_10ms = (g_manual_scanning && g_monitor_enabled && freq_chan && g_current_display_screen == DISPLAY_MAIN) ? 2 : key_repeat_10ms; if (++g_key_debounce_repeat >= (key_long_press_10ms + repeat_10ms)) { // key repeat diff --git a/app/main.c b/app/main.c index be94821..6b4b9d6 100644 --- a/app/main.c +++ b/app/main.c @@ -218,18 +218,26 @@ void processFKeyFunction(const key_code_t Key) { case KEY_0: // FM - if (g_scan_state_dir != SCAN_STATE_DIR_OFF) - APP_stop_scan(); - if (g_fkey_pressed) { if (++g_tx_vfo->channel.mod_mode >= MOD_MODE_LEN) g_tx_vfo->channel.mod_mode = 0; - g_request_save_channel = 1; + + AUDIO_set_mod_mode(g_tx_vfo->channel.mod_mode); + + if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save)) + if (g_scan_state_dir == SCAN_STATE_DIR_OFF) + g_request_save_vfo = true; + + g_request_display_screen = DISPLAY_MAIN; } else { + #ifdef ENABLE_FMRADIO + if (g_scan_state_dir != SCAN_STATE_DIR_OFF) + APP_stop_scan(); + ACTION_FM(); #else diff --git a/audio.c b/audio.c index 7e68b40..6e11ff7 100644 --- a/audio.c +++ b/audio.c @@ -83,8 +83,8 @@ void AUDIO_set_mod_mode(const mod_mode_t mode) switch (mode) { default: - case MOD_MODE_FM: af_mode = BK4819_AF_FM; break; - case MOD_MODE_AM: af_mode = BK4819_AF_AM; break; + case MOD_MODE_FM: af_mode = BK4819_AF_FM; break; + case MOD_MODE_AM: af_mode = BK4819_AF_AM; break; case MOD_MODE_DSB: af_mode = BK4819_AF_BASEBAND1; break; } BK4819_SetAF(af_mode); diff --git a/firmware.bin b/firmware.bin index 10687c8..8f898e2 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 8b85d16..1ade51f 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/radio.c b/radio.c index 747705f..d64ac82 100644 --- a/radio.c +++ b/radio.c @@ -632,7 +632,7 @@ void RADIO_select_vfos(void) void RADIO_setup_registers(bool switch_to_function_foreground) { - BK4819_filter_bandwidth_t Bandwidth = g_rx_vfo->channel.channel_bandwidth; + BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel.channel_bandwidth; uint16_t interrupt_mask; uint32_t Frequency; @@ -661,7 +661,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) BK4819_SetFilterBandwidth(Bandwidth); BK4819_EnableAFC(); #else - if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM) + if (g_current_vfo->channel.mod_mode != MOD_MODE_FM) { BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER); // sideband BK4819_DisableAFC(); @@ -708,25 +708,25 @@ void RADIO_setup_registers(bool switch_to_function_foreground) BK4819_write_reg(0x3F, 0); // disable interrupts #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_mode) + if (IS_NOAA_CHANNEL(g_current_vfo->channel_save) && g_noaa_mode) Frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel]; else #endif - Frequency = g_rx_vfo->p_rx->frequency; + Frequency = g_current_vfo->p_rx->frequency; BK4819_set_rf_frequency(Frequency, false); BK4819_set_rf_filter_path(Frequency); BK4819_SetupSquelch( - g_rx_vfo->squelch_open_rssi_thresh, g_rx_vfo->squelch_close_rssi_thresh, - g_rx_vfo->squelch_open_noise_thresh, g_rx_vfo->squelch_close_noise_thresh, - g_rx_vfo->squelch_close_glitch_thresh, g_rx_vfo->squelch_open_glitch_thresh); + g_current_vfo->squelch_open_rssi_thresh, g_current_vfo->squelch_close_rssi_thresh, + g_current_vfo->squelch_open_noise_thresh, g_current_vfo->squelch_close_noise_thresh, + g_current_vfo->squelch_close_glitch_thresh, g_current_vfo->squelch_open_glitch_thresh); // enable the RX front end BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true); // AF RX Gain and DAC -// if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM) +// if (g_current_vfo->channel.mod_mode != MOD_MODE_FM) // { // BK4819_write_reg(0x48, 0xB3A8); // 1011 0011 1010 1000 // } @@ -748,29 +748,29 @@ void RADIO_setup_registers(bool switch_to_function_foreground) #ifdef ENABLE_VOICE #ifdef MUTE_AUDIO_FOR_VOICE if (g_voice_write_index == 0) - AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); + AUDIO_set_mod_mode(g_current_vfo->channel.mod_mode); #else - AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); + AUDIO_set_mod_mode(g_current_vfo->channel.mod_mode); #endif #else - AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); + AUDIO_set_mod_mode(g_current_vfo->channel.mod_mode); #endif } } interrupt_mask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST; - if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) + if (IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save)) { - if (g_rx_vfo->channel.mod_mode == MOD_MODE_FM) + if (g_current_vfo->channel.mod_mode == MOD_MODE_FM) { // FM uint8_t code_type = g_selected_code_type; uint8_t code = g_selected_code; if (g_css_scan_mode == CSS_SCAN_MODE_OFF) { - code_type = g_rx_vfo->p_rx->code_type; - code = g_rx_vfo->p_rx->code; + code_type = g_current_vfo->p_rx->code_type; + code = g_current_vfo->p_rx->code; } switch (code_type) @@ -812,7 +812,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) } if (g_eeprom.config.setting.enable_scrambler) - BK4819_set_scrambler(g_rx_vfo->channel.scrambler); + BK4819_set_scrambler(g_current_vfo->channel.scrambler); else BK4819_set_scrambler(0); } @@ -843,7 +843,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) BK4819_DisableVox(); // RX expander - BK4819_SetCompander((g_rx_vfo->channel.mod_mode == MOD_MODE_FM && g_rx_vfo->channel.compand >= 2) ? g_rx_vfo->channel.compand : 0); + BK4819_SetCompander((g_current_vfo->channel.mod_mode == MOD_MODE_FM && g_current_vfo->channel.compand >= 2) ? g_current_vfo->channel.compand : 0); BK4819_EnableDTMF(); interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;