diff --git a/app/menu.c b/app/menu.c index b847043..65e5cd8 100644 --- a/app/menu.c +++ b/app/menu.c @@ -395,21 +395,20 @@ void MENU_AcceptSetting(void) case MENU_CHAN_SQL: g_tx_vfo->squelch_level = g_sub_menu_selection; - g_vfo_configure_mode = VFO_CONFIGURE; - break; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + return; case MENU_STEP: g_tx_vfo->step_setting = step_freq_table_sorted[g_sub_menu_selection]; - if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save)) - { - g_request_save_channel = 1; - return; - } + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; return; case MENU_TX_POWER: g_tx_vfo->output_power = g_sub_menu_selection; - g_request_save_channel = 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; return; case MENU_TX_CDCSS: @@ -479,17 +478,17 @@ void MENU_AcceptSetting(void) case MENU_SHIFT_DIR: g_tx_vfo->tx_offset_freq_dir = g_sub_menu_selection; - g_request_save_channel = 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; return; case MENU_OFFSET: g_tx_vfo->tx_offset_freq = g_sub_menu_selection; - g_request_save_channel = 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; return; case MENU_BANDWIDTH: g_tx_vfo->channel_bandwidth = g_sub_menu_selection; - g_request_save_channel = 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; return; case MENU_SCRAMBLER: @@ -500,12 +499,12 @@ void MENU_AcceptSetting(void) else BK4819_DisableScramble(); #endif - g_request_save_channel= 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; return; case MENU_BUSY_CHAN_LOCK: g_tx_vfo->busy_channel_lock = g_sub_menu_selection; - g_request_save_channel = 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; return; case MENU_MEM_SAVE: @@ -700,7 +699,6 @@ void MENU_AcceptSetting(void) case MENU_PTT_ID: g_tx_vfo->dtmf_ptt_id_tx_mode = g_sub_menu_selection; - g_request_save_channel = 1; if (g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN || g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH || g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO) @@ -708,6 +706,7 @@ void MENU_AcceptSetting(void) g_eeprom.roger_mode = ROGER_MODE_OFF; break; } + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; return; case MENU_BAT_TXT: @@ -717,7 +716,7 @@ void MENU_AcceptSetting(void) case MENU_DTMF_DCD: g_tx_vfo->dtmf_decoding_enable = g_sub_menu_selection; DTMF_clear_RX(); - g_request_save_channel = 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; return; case MENU_DTMF_LIVE_DEC: @@ -755,15 +754,15 @@ void MENU_AcceptSetting(void) g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO) { g_tx_vfo->dtmf_ptt_id_tx_mode = PTT_ID_OFF; // // disable PTT ID tail - g_request_save_channel = 1; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; } } break; case MENU_MOD_MODE: g_tx_vfo->am_mode = g_sub_menu_selection; - g_request_save_channel = 1; - return; + g_request_save_channel = IS_FREQ_CHANNEL(g_tx_vfo->channel_save) ? 2 : 1; + return; #ifdef ENABLE_AM_FIX case MENU_AM_FIX: diff --git a/firmware.bin b/firmware.bin index 7c4f6c0..045aef2 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 9a33ed3..0d2013b 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/settings.c b/settings.c index d482473..a45956c 100644 --- a/settings.c +++ b/settings.c @@ -347,7 +347,7 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c unsigned int eeprom_addr = channel * 16; t_channel m_channel; - if (p_vfo == NULL || IS_NOAA_CHANNEL(channel)) + if (IS_NOAA_CHANNEL(channel)) return; if (mode < 2 && channel <= USER_CHANNEL_LAST) @@ -360,35 +360,47 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c // UART_printf("sav_chan %04X %3u %u %u\r\n", eeprom_addr, channel, vfo, mode); #endif - memset(&m_channel, 0, sizeof(m_channel)); - m_channel.frequency = p_vfo->freq_config_rx.frequency; - m_channel.offset = p_vfo->tx_offset_freq; - m_channel.rx_ctcss_cdcss_code = p_vfo->freq_config_rx.code; - m_channel.tx_ctcss_cdcss_code = p_vfo->freq_config_tx.code; - m_channel.rx_ctcss_cdcss_type = p_vfo->freq_config_rx.code_type; -// m_channel.unused1:2 - m_channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type; -// m_channel.unused2:2 - 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.unused4:3 - m_channel.frequency_reverse = p_vfo->frequency_reverse; - m_channel.channel_bandwidth = p_vfo->channel_bandwidth; - m_channel.tx_power = p_vfo->output_power; - m_channel.busy_channel_lock = p_vfo->busy_channel_lock; -// m_channel.unused5:1 - m_channel.compand = p_vfo->compand; - m_channel.dtmf_decoding_enable = p_vfo->dtmf_decoding_enable; - m_channel.dtmf_ptt_id_tx_mode = p_vfo->dtmf_ptt_id_tx_mode; -// m_channel.unused6:4 - m_channel.step_setting = p_vfo->step_setting; - m_channel.scrambler = p_vfo->scrambling_type; - m_channel.squelch_level = 0; + // **************** + if (p_vfo != NULL) + { + memset(&m_channel, 0, sizeof(m_channel)); + m_channel.frequency = p_vfo->freq_config_rx.frequency; + m_channel.offset = p_vfo->tx_offset_freq; + m_channel.rx_ctcss_cdcss_code = p_vfo->freq_config_rx.code; + m_channel.tx_ctcss_cdcss_code = p_vfo->freq_config_tx.code; + m_channel.rx_ctcss_cdcss_type = p_vfo->freq_config_rx.code_type; +// m_channel.unused1:2 + m_channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type; +// m_channel.unused2:2 + 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.unused4:3 + m_channel.frequency_reverse = p_vfo->frequency_reverse; + m_channel.channel_bandwidth = p_vfo->channel_bandwidth; + m_channel.tx_power = p_vfo->output_power; + m_channel.busy_channel_lock = p_vfo->busy_channel_lock; +// m_channel.unused5:1 + m_channel.compand = p_vfo->compand; + m_channel.dtmf_decoding_enable = p_vfo->dtmf_decoding_enable; + m_channel.dtmf_ptt_id_tx_mode = p_vfo->dtmf_ptt_id_tx_mode; +// m_channel.unused6:4 + m_channel.step_setting = p_vfo->step_setting; + m_channel.scrambler = p_vfo->scrambling_type; + m_channel.squelch_level = 0; + } + else + if (channel <= USER_CHANNEL_LAST) + { // user channel + memset(&m_channel, 0xff, sizeof(m_channel)); + } + EEPROM_WriteBuffer8(eeprom_addr + 0, (uint8_t *)(&m_channel) + 0); EEPROM_WriteBuffer8(eeprom_addr + 8, (uint8_t *)(&m_channel) + 8); + // **************** + SETTINGS_save_chan_attribs_name(channel, p_vfo); if (channel <= USER_CHANNEL_LAST) @@ -396,16 +408,17 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c const unsigned int eeprom_addr = 0x0F50 + (channel * 16); uint8_t name[16]; - memset(name, 0, sizeof(name)); + memset(name, (p_vfo != NULL) ? 0x00 : 0xff, sizeof(name)); #ifndef ENABLE_KEEP_MEM_NAME // clear/reset the channel name EEPROM_WriteBuffer8(eeprom_addr + 0, name + 0); EEPROM_WriteBuffer8(eeprom_addr + 8, name + 8); #else - if (mode >= 3) - { // save the channel name + if (p_vfo != NULL) memmove(name, p_vfo->name, 10); + if (mode >= 3 || p_vfo == NULL) + { // save the channel name EEPROM_WriteBuffer8(eeprom_addr + 0, name + 0); EEPROM_WriteBuffer8(eeprom_addr + 8, name + 8); } @@ -415,12 +428,13 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_t *p_vfo) { - if (p_vfo == NULL || channel >= ARRAY_SIZE(g_user_channel_attributes)) + if (channel >= ARRAY_SIZE(g_user_channel_attributes)) return; if (IS_NOAA_CHANNEL(channel)) return; + if (p_vfo != NULL) { // channel attributes const uint8_t attribs = @@ -429,19 +443,32 @@ void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_ ((3u) << 4) | ((p_vfo->band & 7u) << 0); - const unsigned int index = channel & ~7u; // eeprom writes are always 8 bytes in length + const unsigned int index = channel & ~7ul; // eeprom writes are always 8 bytes in length g_user_channel_attributes[channel] = attribs; // remember new attributes EEPROM_WriteBuffer8(0x0D60 + index, g_user_channel_attributes + index); } - + else + { + const unsigned int index = channel & ~7ul; // eeprom writes are always 8 bytes in length + g_user_channel_attributes[channel] = 0xff; + EEPROM_WriteBuffer8(0x0D60 + index, g_user_channel_attributes + index); + } + if (channel <= USER_CHANNEL_LAST) { // user memory channel const unsigned int index = channel * 16; uint8_t name[16]; - memset(name, 0, sizeof(name)); - memmove(name, p_vfo->name, 10); - + if (p_vfo != NULL) + { + memset(name, 0, sizeof(name)); + memmove(name, p_vfo->name, 10); + } + else + { + memset(name, 0xff, sizeof(name)); + } + EEPROM_WriteBuffer8(0x0F50 + 0 + index, name + 0); EEPROM_WriteBuffer8(0x0F50 + 8 + index, name + 8); } diff --git a/ui/menu.c b/ui/menu.c index f5e9b44..a688fc7 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -547,7 +547,7 @@ void UI_DisplayMenu(void) if (g_sub_menu_selection == 0) strcpy(String, "USE\nMAIN SQL"); else - sprintf(String, "%d\n ", g_sub_menu_selection); + sprintf(String, "\n ", g_sub_menu_selection); break; case MENU_MIC_GAIN: