mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 06:39:49 +03:00
fix dual watch bug + other stuff
This commit is contained in:
40
app/action.c
40
app/action.c
@ -104,8 +104,8 @@ void ACTION_Monitor(void)
|
||||
BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
// if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_is_noaa_mode)
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_is_noaa_mode)
|
||||
// if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_noaa_mode)
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_mode)
|
||||
g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
|
||||
@ -121,10 +121,10 @@ void ACTION_Monitor(void)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
|
||||
#ifdef g_power_save_expired
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode)
|
||||
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF && g_noaa_mode)
|
||||
{
|
||||
g_noaa_tick_10ms = noaa_tick_10ms;
|
||||
g_schedule_noaa = false;
|
||||
@ -177,7 +177,7 @@ void ACTION_Scan(bool bRestart)
|
||||
else
|
||||
{ // scan without auto store
|
||||
g_fm_auto_scan = false;
|
||||
Frequency = g_eeprom.fm_frequency_playing;
|
||||
Frequency = g_eeprom.config.setting.fm_radio.selected_frequency;
|
||||
}
|
||||
g_fm_channel_position = 0;
|
||||
|
||||
@ -218,11 +218,11 @@ void ACTION_Scan(bool bRestart)
|
||||
if (g_scan_next_channel <= USER_CHANNEL_LAST)
|
||||
{ // channel mode
|
||||
|
||||
if (g_eeprom.scan_list_default < 2)
|
||||
if (g_eeprom.config.setting.scan_list_default < 2)
|
||||
{ // keep scanning but toggle between scan lists
|
||||
|
||||
//g_eeprom.scan_list_default = (g_eeprom.scan_list_default + 1) % 3;
|
||||
g_eeprom.scan_list_default++;
|
||||
//g_eeprom.config.setting.scan_list_default = (g_eeprom.config.setting.scan_list_default + 1) % 3;
|
||||
g_eeprom.config.setting.scan_list_default++;
|
||||
|
||||
// jump to the next channel
|
||||
APP_channel_next(true, g_scan_state_dir);
|
||||
@ -234,7 +234,7 @@ void ACTION_Scan(bool bRestart)
|
||||
return;
|
||||
}
|
||||
|
||||
g_eeprom.scan_list_default = 0; // back to scan list 1 - the next time we start scanning
|
||||
g_eeprom.config.setting.scan_list_default = 0; // back to scan list 1 - the next time we start scanning
|
||||
}
|
||||
|
||||
// stop scanning
|
||||
@ -263,7 +263,7 @@ void ACTION_Scan(bool bRestart)
|
||||
#endif
|
||||
|
||||
// clear the other vfo's rssi level (to hide the antenna symbol)
|
||||
g_vfo_rssi_bar_level[(g_eeprom.rx_vfo + 1) & 1u] = 0;
|
||||
g_vfo_rssi_bar_level[(g_rx_vfo_num + 1) & 1u] = 0;
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
@ -280,7 +280,7 @@ void ACTION_Scan(bool bRestart)
|
||||
// if (!bRestart)
|
||||
if (!bRestart && g_scan_next_channel <= USER_CHANNEL_LAST)
|
||||
{ // channel mode, keep scanning but toggle between scan lists
|
||||
g_eeprom.scan_list_default = (g_eeprom.scan_list_default + 1) % 3;
|
||||
g_eeprom.config.setting.scan_list_default = (g_eeprom.config.setting.scan_list_default + 1) % 3;
|
||||
|
||||
// jump to the next channel
|
||||
APP_channel_next(true, g_scan_state_dir);
|
||||
@ -300,13 +300,13 @@ void ACTION_Scan(bool bRestart)
|
||||
#ifdef ENABLE_VOX
|
||||
void ACTION_Vox(void)
|
||||
{
|
||||
g_eeprom.vox_switch = !g_eeprom.vox_switch;
|
||||
g_request_save_settings = true;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
g_eeprom.config.setting.vox_switch = (g_eeprom.config.setting.vox_switch + 1) & 1u;
|
||||
g_request_save_settings = true;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_VOX;
|
||||
g_another_voice_id = VOICE_ID_VOX;
|
||||
#endif
|
||||
g_update_status = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -378,14 +378,14 @@ void ACTION_process(const key_code_t Key, const bool key_pressed, const bool key
|
||||
|
||||
if (Key == KEY_SIDE1)
|
||||
{
|
||||
Short = g_eeprom.key1_short_press_action;
|
||||
Long = g_eeprom.key1_long_press_action;
|
||||
Short = g_eeprom.config.setting.key1_short;
|
||||
Long = g_eeprom.config.setting.key1_long;
|
||||
}
|
||||
else
|
||||
if (Key == KEY_SIDE2)
|
||||
{
|
||||
Short = g_eeprom.key2_short_press_action;
|
||||
Long = g_eeprom.key2_long_press_action;
|
||||
Short = g_eeprom.config.setting.key2_short;
|
||||
Long = g_eeprom.config.setting.key2_long;
|
||||
}
|
||||
|
||||
if (!key_held && key_pressed)
|
||||
|
@ -114,6 +114,7 @@ void AIRCOPY_start_fsk_tx(const int request_block_num)
|
||||
if (request_block_num < 0)
|
||||
{
|
||||
EEPROM_ReadBuffer(eeprom_addr, &g_fsk_buffer[tx_size], 64);
|
||||
// memcpy(&g_fsk_buffer[tx_size], ((uint8_t *)&g_eeprom) + eeprom_addr, 64);
|
||||
tx_size += 64 / 2;
|
||||
}
|
||||
|
||||
@ -590,6 +591,7 @@ void AIRCOPY_process_fsk_rx_10ms(void)
|
||||
}
|
||||
|
||||
EEPROM_WriteBuffer8(eeprom_addr, data); // 8 bytes at a time
|
||||
// memcpy(((uint8_t *)&g_eeprom) + eeprom_addr, data, 8);
|
||||
|
||||
data += write_size / sizeof(data[0]);
|
||||
eeprom_addr += write_size;
|
||||
|
323
app/app.c
323
app/app.c
@ -83,7 +83,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 > 0 && g_setting_am_fix)
|
||||
if (g_current_vfo->am_mode > 0 && g_eeprom.config.setting.am_fix)
|
||||
rssi -= rssi_gain_diff[vfo];
|
||||
#endif
|
||||
|
||||
@ -113,11 +113,11 @@ static void APP_check_for_new_receive(void)
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
}
|
||||
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_OFF)
|
||||
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF)
|
||||
{ // dual watch is disabled
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (g_is_noaa_mode)
|
||||
if (g_noaa_mode)
|
||||
{
|
||||
g_noaa_tick_10ms = noaa_tick_3_10ms;
|
||||
g_schedule_noaa = false;
|
||||
@ -132,7 +132,7 @@ static void APP_check_for_new_receive(void)
|
||||
if (g_rx_reception_mode != RX_MODE_NONE)
|
||||
goto done;
|
||||
|
||||
g_dual_watch_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_dual_watch_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_scan_pause_time_mode = false;
|
||||
|
||||
g_update_status = true;
|
||||
@ -162,7 +162,7 @@ done:
|
||||
}
|
||||
#endif
|
||||
}
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
APP_update_rssi(g_rx_vfo_num);
|
||||
g_update_rssi = true;
|
||||
// }
|
||||
}
|
||||
@ -214,7 +214,7 @@ static void APP_process_new_receive(void)
|
||||
{ // not code scanning
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
|
||||
#else
|
||||
if (g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
@ -226,7 +226,7 @@ static void APP_process_new_receive(void)
|
||||
{
|
||||
if (g_rx_reception_mode == RX_MODE_DETECTED)
|
||||
{
|
||||
g_dual_watch_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_dual_watch_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_rx_reception_mode = RX_MODE_LISTENING;
|
||||
|
||||
g_update_status = true;
|
||||
@ -262,12 +262,12 @@ static void APP_process_rx(void)
|
||||
{
|
||||
if (g_squelch_open || g_monitor_enabled)
|
||||
{
|
||||
switch (g_eeprom.scan_resume_mode)
|
||||
switch (g_eeprom.config.setting.carrier_search_mode)
|
||||
{
|
||||
case SCAN_RESUME_TIME: // stay only for a limited time
|
||||
break;
|
||||
case SCAN_RESUME_CARRIER: // stay untill the carrier goes away
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_scan_pause_time_mode = false;
|
||||
break;
|
||||
case SCAN_RESUME_STOP: // stop scan once we find any signal
|
||||
@ -311,7 +311,7 @@ static void APP_process_rx(void)
|
||||
|
||||
if (g_squelch_open || g_monitor_enabled)
|
||||
{
|
||||
if (g_setting_backlight_on_tx_rx >= 2)
|
||||
if (g_eeprom.config.setting.backlight_on_tx_rx >= 2)
|
||||
backlight_turn_on(backlight_tx_rx_time_500ms); // keep the backlight on while we're receiving
|
||||
|
||||
if (!g_end_of_rx_detected_maybe && IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
|
||||
@ -319,7 +319,7 @@ static void APP_process_rx(void)
|
||||
switch (g_current_code_type)
|
||||
{
|
||||
case CODE_TYPE_NONE:
|
||||
if (g_eeprom.squelch_level > 0)
|
||||
if (g_eeprom.config.setting.squelch_level > 0)
|
||||
{
|
||||
if (g_cxcss_tail_found)
|
||||
{
|
||||
@ -381,7 +381,7 @@ static void APP_process_rx(void)
|
||||
if (!g_end_of_rx_detected_maybe &&
|
||||
Mode == END_OF_RX_MODE_NONE &&
|
||||
g_next_time_slice_40ms &&
|
||||
g_eeprom.tail_note_elimination &&
|
||||
g_eeprom.config.setting.tail_tone_elimination &&
|
||||
(g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL) &&
|
||||
BK4819_GetCTCType() == 1)
|
||||
{
|
||||
@ -410,7 +410,7 @@ Skip:
|
||||
break;
|
||||
|
||||
case END_OF_RX_MODE_TTE:
|
||||
if (g_eeprom.tail_note_elimination)
|
||||
if (g_eeprom.config.setting.tail_tone_elimination)
|
||||
{
|
||||
if (!g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
@ -426,12 +426,12 @@ Skip:
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
{ // we're RF scanning
|
||||
|
||||
switch (g_eeprom.scan_resume_mode)
|
||||
switch (g_eeprom.config.setting.carrier_search_mode)
|
||||
{
|
||||
case SCAN_RESUME_TIME: // stay only for a limited time
|
||||
break;
|
||||
case SCAN_RESUME_CARRIER: // stay untill the carrier goes away
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_scan_pause_time_mode = false;
|
||||
break;
|
||||
case SCAN_RESUME_STOP: // stop scan once we find any signal
|
||||
@ -443,18 +443,18 @@ Skip:
|
||||
|
||||
bool APP_start_listening(void)
|
||||
{
|
||||
const unsigned int chan = g_eeprom.rx_vfo;
|
||||
const unsigned int chan = g_rx_vfo_num;
|
||||
// const unsigned int chan = g_rx_vfo->channel_save;
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_setting_radio_disabled)
|
||||
if (g_eeprom.config.setting.radio_disabled)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (g_squelch_open)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
|
||||
|
||||
if (g_setting_backlight_on_tx_rx >= 2)
|
||||
if (g_eeprom.config.setting.backlight_on_tx_rx >= 2)
|
||||
backlight_turn_on(backlight_tx_rx_time_500ms);
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
@ -470,20 +470,20 @@ bool APP_start_listening(void)
|
||||
g_rx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
if (IS_FREQ_CHANNEL(g_scan_next_channel))
|
||||
g_rx_vfo->freq_in_channel = BOARD_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
g_rx_vfo->freq_in_channel = SETTINGS_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
|
||||
switch (g_eeprom.scan_resume_mode)
|
||||
switch (g_eeprom.config.setting.carrier_search_mode)
|
||||
{
|
||||
case SCAN_RESUME_TIME:
|
||||
if (!g_scan_pause_time_mode)
|
||||
{
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_scan_pause_time_mode = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCAN_RESUME_CARRIER:
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_scan_pause_time_mode = false;
|
||||
break;
|
||||
|
||||
@ -495,12 +495,12 @@ bool APP_start_listening(void)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_is_noaa_mode)
|
||||
if (IS_NOAA_CHANNEL(g_rx_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.screen_channel[chan] = g_rx_vfo->channel_save;
|
||||
g_eeprom.config.setting.indices.vfo[chan].screen = g_rx_vfo->channel_save;
|
||||
g_noaa_tick_10ms = 5000 / 10; // 5 sec
|
||||
g_schedule_noaa = false;
|
||||
}
|
||||
@ -511,10 +511,10 @@ bool APP_start_listening(void)
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||
g_eeprom.dual_watch != DUAL_WATCH_OFF)
|
||||
g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
|
||||
{ // dual watch is active
|
||||
|
||||
g_dual_watch_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_dual_watch_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
|
||||
g_rx_vfo_is_active = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
@ -527,10 +527,10 @@ bool APP_start_listening(void)
|
||||
// else
|
||||
{
|
||||
BK4819_WriteRegister(0x48,
|
||||
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
|
||||
( 0u << 10) | // AF Rx Gain-1
|
||||
(g_eeprom.volume_gain << 4) | // AF Rx Gain-2
|
||||
(g_eeprom.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
||||
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
|
||||
( 0u << 10) | // AF Rx Gain-1
|
||||
(g_eeprom.calib.volume_gain << 4) | // AF Rx Gain-2
|
||||
(g_eeprom.calib.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
||||
}
|
||||
|
||||
FUNCTION_Select(FUNCTION_RECEIVE);
|
||||
@ -617,10 +617,10 @@ void APP_stop_scan(void)
|
||||
|
||||
if (g_scan_restore_channel != 0xff)
|
||||
{
|
||||
g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_restore_channel;
|
||||
g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_scan_restore_channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_rx_vfo_num].user = g_scan_restore_channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_rx_vfo_num].screen = g_scan_restore_channel;
|
||||
|
||||
RADIO_configure_channel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(g_rx_vfo_num, VFO_CONFIGURE_RELOAD);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
}
|
||||
@ -632,7 +632,7 @@ void APP_stop_scan(void)
|
||||
g_rx_vfo->freq_config_rx.frequency = g_scan_restore_frequency;
|
||||
|
||||
// find the first channel that contains this frequency
|
||||
g_rx_vfo->freq_in_channel = BOARD_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
g_rx_vfo->freq_in_channel = SETTINGS_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
|
||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
@ -648,7 +648,7 @@ void APP_stop_scan(void)
|
||||
{ // frequency mode
|
||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
SETTINGS_save_channel(g_rx_vfo->channel_save, g_eeprom.rx_vfo, g_rx_vfo, 1);
|
||||
SETTINGS_save_channel(g_rx_vfo->channel_save, g_rx_vfo_num, g_rx_vfo, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -716,9 +716,10 @@ static void APP_next_freq(void)
|
||||
static void APP_next_channel(void)
|
||||
{
|
||||
static unsigned int prevChannel = 0;
|
||||
const bool enabled = (g_eeprom.scan_list_default < 2) ? g_eeprom.scan_list_enabled[g_eeprom.scan_list_default] : true;
|
||||
const int chan1 = (g_eeprom.scan_list_default < 2) ? g_eeprom.scan_list_priority_ch1[g_eeprom.scan_list_default] : -1;
|
||||
const int chan2 = (g_eeprom.scan_list_default < 2) ? g_eeprom.scan_list_priority_ch2[g_eeprom.scan_list_default] : -1;
|
||||
const unsigned int index = g_eeprom.config.setting.scan_list_default;
|
||||
const bool enabled = (index < 2) ? !!g_eeprom.config.setting.priority_scan_list[index].enabled : true;
|
||||
const int chan1 = (index < 2) ? g_eeprom.config.setting.priority_scan_list[index].channel[0] : -1;
|
||||
const int chan2 = (index < 2) ? g_eeprom.config.setting.priority_scan_list[index].channel[1] : -1;
|
||||
const unsigned int prev_chan = g_scan_next_channel;
|
||||
unsigned int chan = 0;
|
||||
|
||||
@ -757,10 +758,10 @@ static void APP_next_channel(void)
|
||||
// this bit doesn't yet work if the other VFO is a frequency
|
||||
case SCAN_NEXT_CHAN_DUAL_WATCH:
|
||||
// dual watch is enabled - include the other VFO in the scan
|
||||
// if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
|
||||
// if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
|
||||
// {
|
||||
// chan = (g_eeprom.rx_vfo + 1) & 1u;
|
||||
// chan = g_eeprom.screen_channel[chan];
|
||||
// chan = (g_rx_vfo + 1) & 1u;
|
||||
// chan = g_eeprom.config.setting.indices.vfo[chan].screen;
|
||||
// if (chan <= USER_CHANNEL_LAST)
|
||||
// {
|
||||
// g_scan_current_scan_list = SCAN_NEXT_CHAN_DUAL_WATCH;
|
||||
@ -782,7 +783,7 @@ static void APP_next_channel(void)
|
||||
|
||||
if (!enabled || chan == 0xff)
|
||||
{
|
||||
chan = RADIO_FindNextChannel(g_scan_next_channel + g_scan_state_dir, g_scan_state_dir, (g_eeprom.scan_list_default < 2) ? true : false, g_eeprom.scan_list_default);
|
||||
chan = RADIO_FindNextChannel(g_scan_next_channel + g_scan_state_dir, g_scan_state_dir, (index < 2) ? true : false, index);
|
||||
if (chan == 0xFF)
|
||||
{ // no valid channel found
|
||||
|
||||
@ -799,10 +800,10 @@ static void APP_next_channel(void)
|
||||
// UART_printf("APP_next_channel %u\r\n", g_scan_next_channel);
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_next_channel;
|
||||
g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_scan_next_channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_rx_vfo_num].user = g_scan_next_channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_rx_vfo_num].screen = g_scan_next_channel;
|
||||
|
||||
RADIO_configure_channel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(g_rx_vfo_num, VFO_CONFIGURE_RELOAD);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
@ -830,40 +831,63 @@ static void APP_next_channel(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void APP_toggle_dual_watch_vfo(void)
|
||||
static bool APP_toggle_dual_watch_vfo(void)
|
||||
{
|
||||
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF)
|
||||
return false;
|
||||
if (g_current_function == FUNCTION_FOREGROUND && g_current_function == FUNCTION_POWER_SAVE)
|
||||
return false;
|
||||
if (g_current_display_screen == DISPLAY_SEARCH)
|
||||
return false;
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
return false;
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
return false;
|
||||
if (g_ptt_is_pressed)
|
||||
return false;
|
||||
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
return false;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
// if (g_fm_radio_mode)
|
||||
// return false;
|
||||
#endif
|
||||
if (g_dual_watch_tick_10ms > 0)
|
||||
return false;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("dual wot\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (g_is_noaa_mode)
|
||||
if (g_noaa_mode)
|
||||
{
|
||||
if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) || IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1]))
|
||||
g_eeprom.rx_vfo = (g_eeprom.rx_vfo + 1) & 1;
|
||||
if (IS_NOT_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[0].screen) || IS_NOT_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[1].screen))
|
||||
g_rx_vfo_num = (g_rx_vfo_num + 1) & 1u;
|
||||
else
|
||||
g_eeprom.rx_vfo = 0;
|
||||
g_rx_vfo_num = 0;
|
||||
|
||||
g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.rx_vfo];
|
||||
g_rx_vfo = &g_vfo_info[g_rx_vfo_num];
|
||||
|
||||
if (g_eeprom.vfo_info[0].channel_save >= NOAA_CHANNEL_FIRST)
|
||||
if (g_vfo_info[0].channel_save >= NOAA_CHANNEL_FIRST)
|
||||
APP_next_noaa();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{ // toggle between VFO's
|
||||
g_eeprom.rx_vfo = (g_eeprom.rx_vfo + 1) & 1;
|
||||
g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.rx_vfo];
|
||||
g_rx_vfo_num = (g_rx_vfo_num + 1) & 1u;
|
||||
g_rx_vfo = &g_vfo_info[g_rx_vfo_num];
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
RADIO_setup_registers(false);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
g_dual_watch_tick_10ms = g_is_noaa_mode ? dual_watch_delay_noaa_10ms : dual_watch_delay_toggle_10ms;
|
||||
g_dual_watch_tick_10ms = g_noaa_mode ? dual_watch_delay_noaa_10ms : dual_watch_delay_toggle_10ms;
|
||||
#else
|
||||
g_dual_watch_tick_10ms = dual_watch_delay_toggle_10ms;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void APP_process_radio_interrupts(void)
|
||||
@ -884,7 +908,16 @@ void APP_process_radio_interrupts(void)
|
||||
int_bits = BK4819_ReadRegister(0x02);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("reg_c int_bits %04X\r\n", reg_c, int_bits);
|
||||
{
|
||||
int i;
|
||||
UART_printf("int bits %04X %04X ", reg_c, int_bits);
|
||||
for (i = 15; i >= 0; i--)
|
||||
UART_printf("%c", (reg_c & (1u << i)) ? '#' : '.');
|
||||
UART_SendText(" ");
|
||||
for (i = 15; i >= 0; i--)
|
||||
UART_printf("%c", (int_bits & (1u << i)) ? '#' : '.');
|
||||
UART_SendText("\r\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (int_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
|
||||
@ -892,7 +925,7 @@ void APP_process_radio_interrupts(void)
|
||||
const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
|
||||
if (c != 0xff && g_current_function != FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (g_setting_live_dtmf_decoder)
|
||||
if (g_eeprom.config.setting.dtmf_live_decoder)
|
||||
{
|
||||
size_t len = strlen(g_dtmf_rx_live);
|
||||
if (len >= (sizeof(g_dtmf_rx_live) - 1))
|
||||
@ -905,9 +938,9 @@ void APP_process_radio_interrupts(void)
|
||||
g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
|
||||
#else
|
||||
if (g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
@ -921,7 +954,7 @@ void APP_process_radio_interrupts(void)
|
||||
g_dtmf_rx[g_dtmf_rx_index] = 0;
|
||||
g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it
|
||||
g_dtmf_rx_pending = true;
|
||||
|
||||
|
||||
DTMF_HandleRequest();
|
||||
}
|
||||
}
|
||||
@ -980,7 +1013,7 @@ void APP_process_radio_interrupts(void)
|
||||
g_vox_lost = true;
|
||||
g_vox_pause_tick_10ms = 10;
|
||||
|
||||
if (g_eeprom.vox_switch)
|
||||
if (g_eeprom.config.setting.vox_switch)
|
||||
{
|
||||
if (g_current_function == FUNCTION_POWER_SAVE && !g_rx_idle_mode)
|
||||
{
|
||||
@ -988,7 +1021,7 @@ void APP_process_radio_interrupts(void)
|
||||
g_power_save_expired = false;
|
||||
}
|
||||
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
|
||||
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF &&
|
||||
(g_dual_watch_tick_10ms == 0 || g_dual_watch_tick_10ms < dual_watch_delay_after_vox_10ms))
|
||||
{
|
||||
g_dual_watch_tick_10ms = dual_watch_delay_after_vox_10ms;
|
||||
@ -1017,7 +1050,7 @@ void APP_process_radio_interrupts(void)
|
||||
UART_SendText("sq close\r\n");
|
||||
#endif
|
||||
|
||||
//APP_update_rssi(g_eeprom.rx_vfo);
|
||||
//APP_update_rssi(g_rx_vfo);
|
||||
g_update_rssi = true;
|
||||
|
||||
g_update_display = true;
|
||||
@ -1031,12 +1064,12 @@ void APP_process_radio_interrupts(void)
|
||||
UART_SendText("sq open\r\n");
|
||||
#endif
|
||||
|
||||
//APP_update_rssi(g_eeprom.rx_vfo);
|
||||
//APP_update_rssi(g_rx_vfo_num);
|
||||
g_update_rssi = true;
|
||||
|
||||
if (g_monitor_enabled)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
|
||||
|
||||
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
@ -1054,8 +1087,8 @@ void APP_end_tx(void)
|
||||
if (g_current_vfo->p_tx->code_type != CODE_TYPE_NONE)
|
||||
{ // CTCSS/CDCSS is enabled
|
||||
|
||||
//if (g_eeprom.tail_note_elimination && g_eeprom.repeater_tail_tone_elimination > 0)
|
||||
if (g_eeprom.tail_note_elimination)
|
||||
//if (g_eeprom.config.setting.tail_tone_elimination && g_eeprom.config.setting.repeater_tail_tone_elimination > 0)
|
||||
if (g_eeprom.config.setting.tail_tone_elimination)
|
||||
{ // send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
|
||||
RADIO_enable_CxCSS_tail();
|
||||
}
|
||||
@ -1079,7 +1112,7 @@ void APP_end_tx(void)
|
||||
static void APP_process_vox(void)
|
||||
{
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_setting_radio_disabled)
|
||||
if (g_eeprom.config.setting.radio_disabled)
|
||||
return;
|
||||
#endif
|
||||
|
||||
@ -1126,10 +1159,10 @@ void APP_end_tx(void)
|
||||
{
|
||||
APP_end_tx();
|
||||
|
||||
if (g_eeprom.repeater_tail_tone_elimination == 0)
|
||||
if (g_eeprom.config.setting.repeater_tail_tone_elimination == 0)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
else
|
||||
g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10;
|
||||
g_rtte_count_down = g_eeprom.config.setting.repeater_tail_tone_elimination * 10;
|
||||
}
|
||||
|
||||
g_update_status = true;
|
||||
@ -1165,7 +1198,7 @@ void APP_check_keys(void)
|
||||
key_code_t key;
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_setting_radio_disabled)
|
||||
if (g_eeprom.config.setting.radio_disabled)
|
||||
return;
|
||||
#endif
|
||||
|
||||
@ -1176,23 +1209,23 @@ void APP_check_keys(void)
|
||||
{ // PTT pressed
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_setting_tx_enable && g_current_function != FUNCTION_TRANSMIT && g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_eeprom.config.setting.tx_enable && g_current_function != FUNCTION_TRANSMIT && g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
#else
|
||||
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_setting_tx_enable && g_current_function != FUNCTION_TRANSMIT)
|
||||
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_eeprom.config.setting.tx_enable && g_current_function != FUNCTION_TRANSMIT)
|
||||
#endif
|
||||
{
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (!g_setting_radio_disabled)
|
||||
if (!g_eeprom.config.setting.radio_disabled)
|
||||
#endif
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms debounce
|
||||
{ // start TX'ing
|
||||
|
||||
|
||||
g_boot_tick_10ms = 0; // cancel the boot-up screen
|
||||
g_ptt_is_pressed = ptt_pressed;
|
||||
g_ptt_was_released = false;
|
||||
g_ptt_debounce = 3;
|
||||
|
||||
|
||||
APP_process_key(KEY_PTT, true, false);
|
||||
}
|
||||
}
|
||||
@ -1202,9 +1235,9 @@ void APP_check_keys(void)
|
||||
{ // PTT released
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_setting_tx_enable || g_current_function == FUNCTION_TRANSMIT || g_setting_radio_disabled)
|
||||
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_eeprom.config.setting.tx_enable || g_current_function == FUNCTION_TRANSMIT || g_eeprom.config.setting.radio_disabled)
|
||||
#else
|
||||
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_setting_tx_enable || g_current_function == FUNCTION_TRANSMIT)
|
||||
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_eeprom.config.setting.tx_enable || g_current_function == FUNCTION_TRANSMIT)
|
||||
#endif
|
||||
{
|
||||
if (--g_ptt_debounce <= 0)
|
||||
@ -1319,7 +1352,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 uint8_t repeat_10ms = (g_manual_scanning && g_monitor_enabled && 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) ? 1 : key_repeat_10ms;
|
||||
|
||||
if (++g_key_debounce_repeat >= (key_long_press_10ms + repeat_10ms))
|
||||
{ // key repeat
|
||||
@ -1384,7 +1418,7 @@ void APP_cancel_user_input_modes(void)
|
||||
if (!g_squelch_open && !g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
if (g_eeprom.alarm_mode == ALARM_MODE_TONE)
|
||||
if (g_eeprom.config.setting.alarm_mode == ALARM_MODE_TONE)
|
||||
{
|
||||
RADIO_tx_eot();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
@ -1570,7 +1604,7 @@ void APP_process_scan(void)
|
||||
MENU_SelectNextCode();
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa)
|
||||
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF && g_noaa_mode && g_schedule_noaa)
|
||||
{
|
||||
APP_next_noaa();
|
||||
|
||||
@ -1580,28 +1614,12 @@ void APP_process_scan(void)
|
||||
g_schedule_noaa = false;
|
||||
}
|
||||
#endif
|
||||
switch (g_flash_light_state)
|
||||
case FLASHLIGHT_SOS:
|
||||
|
||||
// toggle between the VFO's if dual watch is enabled
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
|
||||
g_dual_watch_tick_10ms == 0 &&
|
||||
!g_ptt_is_pressed &&
|
||||
#ifdef ENABLE_FMRADIO
|
||||
!g_fm_radio_mode &&
|
||||
#endif
|
||||
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
|
||||
g_current_display_screen != DISPLAY_SEARCH &&
|
||||
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||
g_current_function != FUNCTION_POWER_SAVE &&
|
||||
(g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_POWER_SAVE))
|
||||
if (APP_toggle_dual_watch_vfo())
|
||||
{
|
||||
APP_toggle_dual_watch_vfo(); // toggle between the two VFO's
|
||||
|
||||
if (g_rx_vfo_is_active && g_current_display_screen == DISPLAY_MAIN)
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
|
||||
|
||||
g_rx_vfo_is_active = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
}
|
||||
@ -1658,7 +1676,7 @@ void APP_process_transmit(void)
|
||||
|
||||
BK4819_SetScrambleFrequencyControlWord((Tone <= 1500) ? Tone : (1500 * 2) - Tone);
|
||||
|
||||
if (g_eeprom.alarm_mode == ALARM_MODE_TONE && g_alarm_running_counter_10ms == 512)
|
||||
if (g_eeprom.config.setting.alarm_mode == ALARM_MODE_TONE && g_alarm_running_counter_10ms == 512)
|
||||
{
|
||||
g_alarm_running_counter_10ms = 0;
|
||||
|
||||
@ -1713,7 +1731,7 @@ void APP_process_functions(void)
|
||||
break;
|
||||
|
||||
case FUNCTION_TRANSMIT:
|
||||
if (g_setting_backlight_on_tx_rx == 1 || g_setting_backlight_on_tx_rx == 3)
|
||||
if (g_eeprom.config.setting.backlight_on_tx_rx == 1 || g_eeprom.config.setting.backlight_on_tx_rx == 3)
|
||||
backlight_turn_on(backlight_tx_rx_time_500ms);
|
||||
break;
|
||||
|
||||
@ -1750,7 +1768,7 @@ void APP_process_power_save(void)
|
||||
g_fkey_pressed ||
|
||||
g_key_pressed != KEY_INVALID ||
|
||||
g_key_held ||
|
||||
g_eeprom.battery_save == 0 ||
|
||||
g_eeprom.config.setting.battery_save_ratio == 0 ||
|
||||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
|
||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||
g_current_display_screen != DISPLAY_MAIN ||
|
||||
@ -1761,9 +1779,9 @@ void APP_process_power_save(void)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[0]) ||
|
||||
IS_NOAA_CHANNEL(g_eeprom.screen_channel[1]) ||
|
||||
g_is_noaa_mode)
|
||||
if (IS_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[0].screen) ||
|
||||
IS_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[1].screen) ||
|
||||
g_noaa_mode)
|
||||
{
|
||||
power_save = false;
|
||||
}
|
||||
@ -1786,6 +1804,8 @@ void APP_process_power_save(void)
|
||||
|
||||
g_schedule_power_save = false;
|
||||
|
||||
// **************************
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (g_voice_write_index != 0)
|
||||
return;
|
||||
@ -1805,17 +1825,12 @@ void APP_process_power_save(void)
|
||||
BK4819_Conditional_RX_TurnOn();
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
if (g_eeprom.vox_switch)
|
||||
BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold);
|
||||
if (g_eeprom.config.setting.vox_switch)
|
||||
BK4819_EnableVox(g_vox_threshold[1], g_vox_threshold[0]);
|
||||
#endif
|
||||
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
|
||||
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{ // dual watch mode, toggle between the two VFO's
|
||||
APP_toggle_dual_watch_vfo();
|
||||
if (APP_toggle_dual_watch_vfo())
|
||||
g_update_rssi = false;
|
||||
}
|
||||
|
||||
FUNCTION_Init();
|
||||
|
||||
@ -1823,17 +1838,17 @@ void APP_process_power_save(void)
|
||||
g_rx_idle_mode = false; // RX is awake
|
||||
}
|
||||
else
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_OFF ||
|
||||
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF ||
|
||||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
|
||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||
g_update_rssi)
|
||||
{ // dual watch mode, go back to sleep
|
||||
{ // go back to sleep
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
APP_update_rssi(g_rx_vfo_num);
|
||||
|
||||
// go back to sleep
|
||||
|
||||
g_power_save_tick_10ms = g_eeprom.battery_save * 10;
|
||||
g_power_save_tick_10ms = g_eeprom.config.setting.battery_save_ratio * 10;
|
||||
g_rx_idle_mode = true;
|
||||
|
||||
BK4819_DisableVox();
|
||||
@ -1841,11 +1856,9 @@ void APP_process_power_save(void)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false);
|
||||
}
|
||||
else
|
||||
if (APP_toggle_dual_watch_vfo())
|
||||
{
|
||||
// toggle between the two VFO's
|
||||
APP_toggle_dual_watch_vfo();
|
||||
|
||||
g_update_rssi = true;
|
||||
g_update_rssi = true;
|
||||
g_power_save_tick_10ms = power_save1_10ms;
|
||||
}
|
||||
|
||||
@ -1945,14 +1958,14 @@ void APP_time_slice_500ms(void)
|
||||
// g_update_display = true; // can't do this if not FM scanning, it causes audio clicks
|
||||
#endif
|
||||
|
||||
if (g_backlight_count_down > 0 &&
|
||||
if (g_backlight_tick_500ms > 0 &&
|
||||
!g_ask_to_save &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||
g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
{
|
||||
if (g_current_display_screen != DISPLAY_MENU || g_menu_cursor != MENU_AUTO_BACKLITE) // don't turn off backlight if user is in backlight menu option
|
||||
if (--g_backlight_count_down == 0)
|
||||
if (g_eeprom.backlight < (ARRAY_SIZE(g_sub_menu_backlight) - 1))
|
||||
if (--g_backlight_tick_500ms == 0)
|
||||
if (g_eeprom.config.setting.backlight_time < (ARRAY_SIZE(g_sub_menu_backlight) - 1))
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
|
||||
}
|
||||
|
||||
@ -1960,7 +1973,7 @@ void APP_time_slice_500ms(void)
|
||||
{
|
||||
BOARD_ADC_GetBatteryInfo(&g_usb_current_voltage, &g_usb_current);
|
||||
|
||||
if (g_usb_current > 500 || g_battery_calibration[3] < g_usb_current_voltage)
|
||||
if (g_usb_current > 500 || g_eeprom.calib.battery[3] < g_usb_current_voltage)
|
||||
{
|
||||
#ifdef ENABLE_OVERLAY
|
||||
overlay_FLASH_RebootToBootloader();
|
||||
@ -1984,7 +1997,7 @@ void APP_time_slice_500ms(void)
|
||||
// update every 2 sec
|
||||
if ((g_battery_check_counter & 3) == 0)
|
||||
{
|
||||
if (g_charging_with_type_c || g_setting_battery_text > 0)
|
||||
if (g_charging_with_type_c || g_eeprom.config.setting.battery_text > 0)
|
||||
g_update_status = true;
|
||||
|
||||
#ifdef ENABLE_SHOW_CHARGE_LEVEL
|
||||
@ -2010,7 +2023,7 @@ void APP_time_slice_500ms(void)
|
||||
{
|
||||
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
if (g_eeprom.auto_keypad_lock &&
|
||||
if (g_eeprom.config.setting.auto_key_lock != 0 &&
|
||||
g_key_lock_tick_500ms > 0 &&
|
||||
!g_dtmf_input_mode &&
|
||||
g_input_box_index == 0 &&
|
||||
@ -2018,8 +2031,8 @@ void APP_time_slice_500ms(void)
|
||||
{
|
||||
if (--g_key_lock_tick_500ms == 0)
|
||||
{ // lock the keyboard
|
||||
g_eeprom.key_lock = true;
|
||||
g_update_status = true;
|
||||
g_eeprom.config.setting.key_lock = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -2028,9 +2041,9 @@ void APP_time_slice_500ms(void)
|
||||
{
|
||||
g_menu_tick_10ms = 0;
|
||||
|
||||
if (g_eeprom.backlight == 0)
|
||||
if (g_eeprom.config.setting.backlight_time == 0)
|
||||
{
|
||||
g_backlight_count_down = 0;
|
||||
g_backlight_tick_500ms = 0;
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||
}
|
||||
|
||||
@ -2088,7 +2101,7 @@ void APP_time_slice_500ms(void)
|
||||
}
|
||||
|
||||
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
APP_update_rssi(g_rx_vfo_num);
|
||||
|
||||
if (g_low_battery)
|
||||
{
|
||||
@ -2129,7 +2142,7 @@ void APP_time_slice_500ms(void)
|
||||
|
||||
ST7565_HardwareReset();
|
||||
|
||||
if (g_eeprom.backlight < (ARRAY_SIZE(g_sub_menu_backlight) - 1))
|
||||
if (g_eeprom.config.setting.backlight_time < (ARRAY_SIZE(g_sub_menu_backlight) - 1))
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight off
|
||||
}
|
||||
#ifdef ENABLE_VOICE
|
||||
@ -2196,7 +2209,7 @@ void APP_time_slice_500ms(void)
|
||||
{
|
||||
if (--g_dtmf_auto_reset_time_500ms == 0)
|
||||
{
|
||||
if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED && g_eeprom.dtmf_auto_reset_time >= DTMF_HOLD_MAX)
|
||||
if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED && g_eeprom.config.setting.dtmf.auto_reset_time >= DTMF_HOLD_MAX)
|
||||
g_dtmf_call_state = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed
|
||||
else
|
||||
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
|
||||
@ -2282,8 +2295,8 @@ void APP_time_slice_10ms(void)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (g_rx_vfo->am_mode > 0 && g_setting_am_fix)
|
||||
AM_fix_10ms(g_eeprom.rx_vfo);
|
||||
if (g_rx_vfo->am_mode > 0 && g_eeprom.config.setting.am_fix)
|
||||
AM_fix_10ms(g_rx_vfo_num);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
@ -2308,10 +2321,10 @@ void APP_time_slice_10ms(void)
|
||||
|
||||
if (g_flag_save_channel)
|
||||
{
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_save_channel ? 1 : 0);
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.config.setting.tx_vfo_num, g_tx_vfo, g_flag_save_channel ? 1 : 0);
|
||||
g_flag_save_channel = false;
|
||||
|
||||
RADIO_configure_channel(g_eeprom.tx_vfo, VFO_CONFIGURE);
|
||||
RADIO_configure_channel(g_eeprom.config.setting.tx_vfo_num, VFO_CONFIGURE);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
@ -2350,7 +2363,7 @@ void APP_time_slice_10ms(void)
|
||||
if (g_current_function == FUNCTION_TRANSMIT)
|
||||
{ // transmitting
|
||||
#ifdef ENABLE_TX_AUDIO_BAR
|
||||
if (g_setting_mic_bar && (g_flash_light_blink_tick_10ms % (150 / 10)) == 0 && !g_update_display) // once every 150ms
|
||||
if (g_eeprom.config.setting.mic_bar && (g_flash_light_blink_tick_10ms % (150 / 10)) == 0 && !g_update_display) // once every 150ms
|
||||
UI_DisplayAudioBar(true);
|
||||
#endif
|
||||
}
|
||||
@ -2383,7 +2396,7 @@ void APP_time_slice_10ms(void)
|
||||
if (g_vox_pause_tick_10ms > 0)
|
||||
g_vox_pause_tick_10ms--;
|
||||
|
||||
if (g_eeprom.vox_switch)
|
||||
if (g_eeprom.config.setting.vox_switch)
|
||||
APP_process_vox();
|
||||
#endif
|
||||
|
||||
@ -2435,7 +2448,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
// remember the current backlight state (on / off)
|
||||
const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
|
||||
if (Key == KEY_EXIT && !backlight_was_on && g_eeprom.backlight > 0)
|
||||
if (Key == KEY_EXIT && !backlight_was_on && g_eeprom.config.setting.backlight_time > 0)
|
||||
{ // just turn the back light on for now so the user can see what's what
|
||||
if (!key_pressed && !key_held)
|
||||
{ // key has been released
|
||||
@ -2459,7 +2472,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
// keep the auto keylock at bay
|
||||
if (g_eeprom.auto_keypad_lock)
|
||||
if (g_eeprom.config.setting.auto_key_lock != 0)
|
||||
g_key_lock_tick_500ms = key_lock_timeout_500ms;
|
||||
#endif
|
||||
|
||||
@ -2471,8 +2484,8 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
|
||||
// ********************
|
||||
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
if (g_eeprom.key_lock && g_current_function != FUNCTION_TRANSMIT && Key != KEY_PTT)
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
if (g_eeprom.config.setting.key_lock && g_current_function != FUNCTION_TRANSMIT && Key != KEY_PTT)
|
||||
{ // keyboard is locked
|
||||
|
||||
if (Key == KEY_F)
|
||||
@ -2483,7 +2496,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
|
||||
if (key_held)
|
||||
{ // unlock the keypad
|
||||
g_eeprom.key_lock = false;
|
||||
g_eeprom.config.setting.g_eeprom.key_lock = false;
|
||||
g_request_save_settings = true;
|
||||
g_update_status = true;
|
||||
|
||||
@ -2514,7 +2527,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// key beep
|
||||
// if (Key != KEY_PTT && !key_held && key_pressed)
|
||||
@ -2647,7 +2660,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
|
||||
BK4819_ExitDTMF_TX(false);
|
||||
|
||||
if (g_current_vfo->scrambling_type == 0 || !g_setting_scramble_enable)
|
||||
if (g_current_vfo->scrambling_type == 0 || !g_eeprom.config.setting.enable_scrambler)
|
||||
BK4819_DisableScramble();
|
||||
else
|
||||
BK4819_EnableScramble(g_current_vfo->scrambling_type - 1);
|
||||
@ -2655,7 +2668,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_eeprom.dtmf_side_tone)
|
||||
if (g_eeprom.config.setting.dtmf.side_tone)
|
||||
{ // user will here the DTMF tones in speaker
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
@ -2663,9 +2676,9 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
BK4819_DisableScramble();
|
||||
|
||||
if (Code == 0xFE)
|
||||
BK4819_TransmitTone(g_eeprom.dtmf_side_tone, 1750);
|
||||
BK4819_TransmitTone(g_eeprom.config.setting.dtmf.side_tone, 1750);
|
||||
else
|
||||
BK4819_PlayDTMFEx(g_eeprom.dtmf_side_tone, Code);
|
||||
BK4819_PlayDTMFEx(g_eeprom.config.setting.dtmf.side_tone, Code);
|
||||
}
|
||||
}
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
@ -2674,10 +2687,10 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
{
|
||||
APP_alarm_off();
|
||||
|
||||
if (g_eeprom.repeater_tail_tone_elimination == 0)
|
||||
if (g_eeprom.config.setting.repeater_tail_tone_elimination == 0)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
else
|
||||
g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10;
|
||||
g_rtte_count_down = g_eeprom.config.setting.repeater_tail_tone_elimination * 10;
|
||||
|
||||
if (Key == KEY_PTT)
|
||||
g_ptt_was_pressed = true;
|
||||
@ -2800,7 +2813,7 @@ Skip:
|
||||
{
|
||||
if (!key_held)
|
||||
{
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_request_save_channel);
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.config.setting.tx_vfo_num, g_tx_vfo, g_request_save_channel);
|
||||
|
||||
if (g_current_display_screen != DISPLAY_SEARCH)
|
||||
if (g_vfo_configure_mode == VFO_CONFIGURE_NONE) // don't wipe previous variable setting
|
||||
@ -2826,7 +2839,7 @@ Skip:
|
||||
}
|
||||
else
|
||||
{
|
||||
RADIO_configure_channel(g_eeprom.tx_vfo, g_vfo_configure_mode);
|
||||
RADIO_configure_channel(g_eeprom.config.setting.tx_vfo_num, g_vfo_configure_mode);
|
||||
}
|
||||
|
||||
if (g_request_display_screen == DISPLAY_INVALID)
|
||||
@ -2847,7 +2860,7 @@ Skip:
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
// g_tx_vfo->freq_in_channel = BOARD_find_channel(frequency);
|
||||
// g_tx_vfo->freq_in_channel = SETTINGS_find_channel(frequency);
|
||||
|
||||
g_dtmf_auto_reset_time_500ms = 0;
|
||||
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
|
||||
|
51
app/dtmf.c
51
app/dtmf.c
@ -93,9 +93,10 @@ bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
|
||||
bool DTMF_GetContact(const int Index, char *pContact)
|
||||
{
|
||||
int i = -1;
|
||||
if (Index >= 0 && Index < MAX_DTMF_CONTACTS && pContact != NULL)
|
||||
if (Index >= 0 && Index < (int)ARRAY_SIZE(g_eeprom.config.dtmf_contact))
|
||||
{
|
||||
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
||||
memcpy(pContact, &g_eeprom.config.dtmf_contact[Index], 16);
|
||||
// EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
|
||||
i = (int)pContact[0] - ' ';
|
||||
}
|
||||
return (i < 0 || i >= 95) ? false : true;
|
||||
@ -159,7 +160,7 @@ bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned
|
||||
{
|
||||
if (pMsg[i] != pTemplate[i])
|
||||
{
|
||||
if (!bCheckGroup || pMsg[i] != g_eeprom.dtmf_group_call_code)
|
||||
if (!bCheckGroup || pMsg[i] != g_eeprom.config.setting.dtmf.group_call_code)
|
||||
return false;
|
||||
g_dtmf_IsGroupCall = true;
|
||||
}
|
||||
@ -172,7 +173,7 @@ dtmf_call_mode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < size; i++)
|
||||
if (pMsg[i] == g_eeprom.dtmf_group_call_code)
|
||||
if (pMsg[i] == g_eeprom.config.setting.dtmf.group_call_code)
|
||||
break;
|
||||
|
||||
return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
|
||||
@ -213,7 +214,7 @@ void DTMF_HandleRequest(void)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_radio_disabled)
|
||||
if (!g_rx_vfo->dtmf_decoding_enable && !g_eeprom.config.setting.radio_disabled)
|
||||
#else
|
||||
if (!g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
@ -228,16 +229,16 @@ void DTMF_HandleRequest(void)
|
||||
if (g_dtmf_rx_index >= 9)
|
||||
{ // look for the RADIO DISABLE code
|
||||
|
||||
sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.kill_code);
|
||||
sprintf(String, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.kill_code);
|
||||
|
||||
Offset = g_dtmf_rx_index - strlen(String);
|
||||
|
||||
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
|
||||
{ // bugger
|
||||
|
||||
if (g_eeprom.permit_remote_kill)
|
||||
if (g_eeprom.config.setting.dtmf.permit_remote_kill != 0)
|
||||
{
|
||||
g_setting_radio_disabled = true; // :(
|
||||
g_eeprom.config.setting.radio_disabled = true; // :(
|
||||
|
||||
DTMF_clear_RX();
|
||||
|
||||
@ -269,14 +270,14 @@ void DTMF_HandleRequest(void)
|
||||
if (g_dtmf_rx_index >= 9)
|
||||
{ // look for the REVIVE code
|
||||
|
||||
sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.revive_code);
|
||||
sprintf(String, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.revive_code);
|
||||
|
||||
Offset = g_dtmf_rx_index - strlen(String);
|
||||
|
||||
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
|
||||
{ // shit, we're back !
|
||||
|
||||
g_setting_radio_disabled = false;
|
||||
g_eeprom.config.setting.radio_disabled = false;
|
||||
|
||||
DTMF_clear_RX();
|
||||
|
||||
@ -318,7 +319,7 @@ void DTMF_HandleRequest(void)
|
||||
g_dtmf_rx_index >= 9)
|
||||
{ // waiting for a reply
|
||||
|
||||
sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.dtmf_separate_code, "AAAAA");
|
||||
sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.config.setting.dtmf.separate_code, "AAAAA");
|
||||
|
||||
Offset = g_dtmf_rx_index - strlen(String);
|
||||
|
||||
@ -331,7 +332,7 @@ void DTMF_HandleRequest(void)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_setting_radio_disabled)
|
||||
if (g_eeprom.config.setting.radio_disabled)
|
||||
return; // we've been disabled
|
||||
#endif
|
||||
|
||||
@ -340,7 +341,7 @@ void DTMF_HandleRequest(void)
|
||||
|
||||
g_dtmf_IsGroupCall = false;
|
||||
|
||||
sprintf(String, "%s%c", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code);
|
||||
sprintf(String, "%s%c", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code);
|
||||
|
||||
Offset = g_dtmf_rx_index - strlen(String) - 3;
|
||||
|
||||
@ -358,7 +359,7 @@ void DTMF_HandleRequest(void)
|
||||
|
||||
g_update_display = true;
|
||||
|
||||
switch (g_eeprom.dtmf_decode_response)
|
||||
switch (g_eeprom.config.setting.dtmf.decode_response)
|
||||
{
|
||||
case DTMF_DEC_RESPONSE_BOTH:
|
||||
g_dtmf_decode_ring_tick_500ms = dtmf_decode_ring_500ms;
|
||||
@ -386,7 +387,7 @@ void DTMF_HandleRequest(void)
|
||||
|
||||
bool DTMF_Reply(void)
|
||||
{
|
||||
const uint16_t Delay = (g_eeprom.dtmf_preload_time < 150) ? 150 : g_eeprom.dtmf_preload_time;
|
||||
const uint16_t delay_ms = ((g_eeprom.config.setting.dtmf.preload_time < 15) ? 15 : g_eeprom.config.setting.dtmf.preload_time) * 10;
|
||||
const char *pString = NULL;
|
||||
char String[23];
|
||||
|
||||
@ -399,7 +400,7 @@ bool DTMF_Reply(void)
|
||||
}
|
||||
else
|
||||
{ // append our ID code onto the end of the DTMF code to send
|
||||
sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.dtmf_separate_code, g_eeprom.ani_dtmf_id);
|
||||
sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.ani_id);
|
||||
pString = String;
|
||||
}
|
||||
break;
|
||||
@ -409,7 +410,7 @@ bool DTMF_Reply(void)
|
||||
break;
|
||||
|
||||
case DTMF_REPLY_AAAAA:
|
||||
sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, "AAAAA");
|
||||
sprintf(String, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, "AAAAA");
|
||||
pString = String;
|
||||
break;
|
||||
|
||||
@ -425,7 +426,7 @@ bool DTMF_Reply(void)
|
||||
}
|
||||
|
||||
// send TX-UP DTMF
|
||||
pString = g_eeprom.dtmf_key_up_code;
|
||||
pString = g_eeprom.config.setting.dtmf.key_up_code;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -434,22 +435,22 @@ bool DTMF_Reply(void)
|
||||
if (pString == NULL)
|
||||
return false;
|
||||
|
||||
if (g_eeprom.dtmf_side_tone)
|
||||
if (g_eeprom.config.setting.dtmf.side_tone)
|
||||
{ // the user will also hear the transmitted tones
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
|
||||
SYSTEM_DelayMs(Delay);
|
||||
SYSTEM_DelayMs(delay_ms);
|
||||
|
||||
BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone);
|
||||
BK4819_EnterDTMF_TX(g_eeprom.config.setting.dtmf.side_tone);
|
||||
|
||||
BK4819_PlayDTMFString(
|
||||
pString,
|
||||
1,
|
||||
g_eeprom.dtmf_first_code_persist_time,
|
||||
g_eeprom.dtmf_hash_code_persist_time,
|
||||
g_eeprom.dtmf_code_persist_time,
|
||||
g_eeprom.dtmf_code_interval_time);
|
||||
g_eeprom.config.setting.dtmf.first_code_persist_time * 10,
|
||||
g_eeprom.config.setting.dtmf.hash_code_persist_time * 10,
|
||||
g_eeprom.config.setting.dtmf.code_persist_time * 10,
|
||||
g_eeprom.config.setting.dtmf.code_interval_time * 10);
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
|
120
app/fm.c
120
app/fm.c
@ -37,7 +37,6 @@
|
||||
#define STATE_USER_MODE 1
|
||||
#define STATE_SAVE 2
|
||||
|
||||
uint16_t g_fm_channels[20];
|
||||
bool g_fm_radio_mode;
|
||||
fm_scan_state_dir_t g_fm_scan_state_dir;
|
||||
bool g_fm_auto_scan;
|
||||
@ -51,19 +50,19 @@ volatile bool g_fm_schedule;
|
||||
|
||||
bool FM_check_valid_channel(const unsigned int Channel)
|
||||
{
|
||||
return (Channel < ARRAY_SIZE(g_fm_channels) && (g_fm_channels[Channel] >= BK1080_freq_lower && g_fm_channels[Channel] < BK1080_freq_upper)) ? true : false;
|
||||
return (Channel < ARRAY_SIZE(g_eeprom.config.setting.fm_channel) && (g_eeprom.config.setting.fm_channel[Channel] >= BK1080_freq_lower && g_eeprom.config.setting.fm_channel[Channel] < BK1080_freq_upper)) ? true : false;
|
||||
}
|
||||
|
||||
unsigned int FM_find_next_channel(unsigned int Channel, const fm_scan_state_dir_t scan_state_dir)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(g_fm_channels); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(g_eeprom.config.setting.fm_channel); i++)
|
||||
{
|
||||
if (Channel > ARRAY_SIZE(g_fm_channels))
|
||||
Channel = ARRAY_SIZE(g_fm_channels) - 1;
|
||||
if (Channel > ARRAY_SIZE(g_eeprom.config.setting.fm_channel))
|
||||
Channel = ARRAY_SIZE(g_eeprom.config.setting.fm_channel) - 1;
|
||||
else
|
||||
if (Channel >= ARRAY_SIZE(g_fm_channels))
|
||||
if (Channel >= ARRAY_SIZE(g_eeprom.config.setting.fm_channel))
|
||||
Channel = 0;
|
||||
|
||||
if (FM_check_valid_channel(Channel))
|
||||
@ -77,19 +76,17 @@ unsigned int FM_find_next_channel(unsigned int Channel, const fm_scan_state_dir_
|
||||
|
||||
int FM_configure_channel_state(void)
|
||||
{
|
||||
g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
|
||||
|
||||
if (g_eeprom.fm_channel_mode)
|
||||
if (g_eeprom.config.setting.fm_radio.channel_mode != 0)
|
||||
{
|
||||
const uint8_t Channel = FM_find_next_channel(g_eeprom.fm_selected_channel, FM_CHANNEL_UP);
|
||||
const uint8_t Channel = FM_find_next_channel(g_eeprom.config.setting.fm_radio.selected_channel, FM_CHANNEL_UP);
|
||||
if (Channel == 0xFF)
|
||||
{
|
||||
g_eeprom.fm_channel_mode = false;
|
||||
g_eeprom.config.setting.fm_radio.channel_mode = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_eeprom.fm_selected_channel = Channel;
|
||||
g_eeprom.fm_frequency_playing = g_fm_channels[Channel];
|
||||
g_eeprom.config.setting.fm_radio.selected_channel = Channel;
|
||||
g_eeprom.config.setting.fm_radio.selected_frequency = g_eeprom.config.setting.fm_channel[Channel];
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -99,12 +96,11 @@ void FM_erase_channels(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uint8_t Template[8];
|
||||
|
||||
memset(Template, 0xFF, sizeof(Template));
|
||||
for (i = 0; i < 5; i++)
|
||||
EEPROM_WriteBuffer8(0x0E40 + (i * 8), Template);
|
||||
|
||||
memset(g_fm_channels, 0xFF, sizeof(g_fm_channels));
|
||||
memset(&g_eeprom.config.setting.fm_channel, 0xff, sizeof(g_eeprom.config.setting.fm_channel));
|
||||
}
|
||||
|
||||
void FM_tune(uint16_t frequency, const fm_scan_state_dir_t scan_state_dir, const bool flag)
|
||||
@ -117,7 +113,7 @@ void FM_tune(uint16_t frequency, const fm_scan_state_dir_t scan_state_dir, const
|
||||
g_fm_found_frequency = false;
|
||||
g_ask_to_save = false;
|
||||
g_ask_to_delete = false;
|
||||
g_eeprom.fm_frequency_playing = frequency;
|
||||
g_eeprom.config.setting.fm_radio.selected_frequency = frequency;
|
||||
|
||||
if (!flag)
|
||||
{ // wrap-a-around
|
||||
@ -129,12 +125,12 @@ void FM_tune(uint16_t frequency, const fm_scan_state_dir_t scan_state_dir, const
|
||||
if (frequency >= BK1080_freq_upper)
|
||||
frequency = BK1080_freq_lower;
|
||||
|
||||
g_eeprom.fm_frequency_playing = frequency;
|
||||
g_eeprom.config.setting.fm_radio.selected_frequency = frequency;
|
||||
}
|
||||
|
||||
g_fm_scan_state_dir = scan_state_dir;
|
||||
|
||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||
BK1080_SetFrequency(g_eeprom.config.setting.fm_radio.selected_frequency);
|
||||
|
||||
if (g_fm_resume_tick_500ms < 10)
|
||||
g_fm_resume_tick_500ms = 10; // update display for next 5 seconds
|
||||
@ -147,18 +143,18 @@ void FM_stop_scan(void)
|
||||
|
||||
g_fm_scan_state_dir = FM_SCAN_STATE_DIR_OFF;
|
||||
|
||||
if (g_fm_auto_scan || g_eeprom.fm_channel_mode)
|
||||
if (g_fm_auto_scan || g_eeprom.config.setting.fm_radio.channel_mode != 0)
|
||||
{ // switch to channel mode
|
||||
g_eeprom.fm_channel_mode = true;
|
||||
g_eeprom.fm_selected_channel = 0;
|
||||
g_eeprom.config.setting.fm_radio.channel_mode = 1;
|
||||
g_eeprom.config.setting.fm_radio.selected_channel = 0;
|
||||
FM_configure_channel_state();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_eeprom.fm_channel_mode = false;
|
||||
{ // frequency mode
|
||||
g_eeprom.config.setting.fm_radio.channel_mode = 0;
|
||||
}
|
||||
|
||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||
BK1080_SetFrequency(g_eeprom.config.setting.fm_radio.selected_frequency);
|
||||
|
||||
SETTINGS_save_fm();
|
||||
|
||||
@ -209,15 +205,15 @@ Bail:
|
||||
|
||||
void FM_scan(void)
|
||||
{
|
||||
if (!FM_check_frequency_lock(g_eeprom.fm_frequency_playing, BK1080_freq_lower))
|
||||
if (!FM_check_frequency_lock(g_eeprom.config.setting.fm_radio.selected_frequency, BK1080_freq_lower))
|
||||
{
|
||||
if (!g_fm_auto_scan)
|
||||
{
|
||||
g_fm_play_tick_10ms = 0;
|
||||
g_fm_found_frequency = true;
|
||||
|
||||
if (!g_eeprom.fm_channel_mode)
|
||||
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
|
||||
// if (g_eeprom.config.setting.fm_radio.channel_mode == 0)
|
||||
// g_eeprom.config.setting.fm_radio.selected_frequency = g_eeprom.fm_frequency_playing;
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
@ -225,10 +221,10 @@ void FM_scan(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_fm_channel_position < ARRAY_SIZE(g_fm_channels))
|
||||
g_fm_channels[g_fm_channel_position++] = g_eeprom.fm_frequency_playing;
|
||||
if (g_fm_channel_position < ARRAY_SIZE(g_eeprom.config.setting.fm_channel))
|
||||
g_eeprom.config.setting.fm_channel[g_fm_channel_position++] = g_eeprom.config.setting.fm_radio.selected_frequency;
|
||||
|
||||
if (g_fm_channel_position >= ARRAY_SIZE(g_fm_channels))
|
||||
if (g_fm_channel_position >= ARRAY_SIZE(g_eeprom.config.setting.fm_channel))
|
||||
{
|
||||
FM_stop_scan();
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
@ -236,10 +232,10 @@ void FM_scan(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_fm_auto_scan && g_eeprom.fm_frequency_playing >= (BK1080_freq_upper - 1u))
|
||||
if (g_fm_auto_scan && g_eeprom.config.setting.fm_radio.selected_frequency >= (BK1080_freq_upper - 1u))
|
||||
FM_stop_scan();
|
||||
else
|
||||
FM_tune(g_eeprom.fm_frequency_playing, g_fm_scan_state_dir, false);
|
||||
FM_tune(g_eeprom.config.setting.fm_radio.selected_frequency, g_fm_scan_state_dir, false);
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
}
|
||||
@ -255,7 +251,7 @@ void FM_turn_on(void)
|
||||
g_fm_resume_tick_500ms = fm_resume_500ms; // update display again in 'n' seconds
|
||||
|
||||
// enable the FM radio chip/audio
|
||||
BK1080_Init(g_eeprom.fm_frequency_playing, true);
|
||||
BK1080_Init(g_eeprom.config.setting.fm_radio.selected_frequency, true);
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
@ -285,13 +281,13 @@ void FM_turn_off(void)
|
||||
|
||||
void FM_toggle_chan_freq_mode(void)
|
||||
{
|
||||
g_eeprom.fm_channel_mode = !g_eeprom.fm_channel_mode;
|
||||
g_eeprom.config.setting.fm_radio.channel_mode = (g_eeprom.config.setting.fm_radio.channel_mode + 1) & 1u;
|
||||
|
||||
FM_stop_scan();
|
||||
|
||||
if (!FM_configure_channel_state())
|
||||
{
|
||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||
BK1080_SetFrequency(g_eeprom.config.setting.fm_radio.selected_frequency);
|
||||
g_request_save_fm = true;
|
||||
}
|
||||
}
|
||||
@ -344,7 +340,7 @@ static void FM_Key_DIGITS(const key_code_t Key, const bool key_pressed, const bo
|
||||
if (g_fm_scan_state_dir != FM_SCAN_STATE_DIR_OFF)
|
||||
return;
|
||||
|
||||
State = g_eeprom.fm_channel_mode ? STATE_USER_MODE : STATE_FREQ_MODE;
|
||||
State = (g_eeprom.config.setting.fm_radio.channel_mode != 0) ? STATE_USER_MODE : STATE_FREQ_MODE;
|
||||
}
|
||||
|
||||
INPUTBOX_append(Key);
|
||||
@ -379,14 +375,14 @@ static void FM_Key_DIGITS(const key_code_t Key, const bool key_pressed, const bo
|
||||
if (Frequency >= BK1080_freq_upper)
|
||||
Frequency = BK1080_freq_upper - 1u;
|
||||
|
||||
g_eeprom.fm_selected_frequency = (uint16_t)Frequency;
|
||||
g_eeprom.config.setting.fm_radio.selected_frequency = (uint16_t)Frequency;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
|
||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||
// g_eeprom.fm_frequency_playing = g_eeprom.config.setting.fm_radio.selected_frequency;
|
||||
BK1080_SetFrequency(g_eeprom.config.setting.fm_radio.selected_frequency);
|
||||
|
||||
g_request_save_fm = true;
|
||||
return;
|
||||
@ -409,17 +405,17 @@ static void FM_Key_DIGITS(const key_code_t Key, const bool key_pressed, const bo
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
g_eeprom.fm_selected_channel = Channel;
|
||||
g_eeprom.fm_frequency_playing = g_fm_channels[Channel];
|
||||
g_eeprom.config.setting.fm_radio.selected_channel = Channel;
|
||||
g_eeprom.config.setting.fm_radio.selected_frequency = g_eeprom.config.setting.fm_channel[Channel];
|
||||
|
||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||
BK1080_SetFrequency(g_eeprom.config.setting.fm_radio.selected_frequency);
|
||||
|
||||
g_request_save_fm = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (Channel < ARRAY_SIZE(g_fm_channels))
|
||||
if (Channel < ARRAY_SIZE(g_eeprom.config.setting.fm_channel))
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
@ -555,8 +551,8 @@ static void FM_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
return; // key still pressed
|
||||
|
||||
// see if the frequency is already stored in a channel
|
||||
for (i = 0; i < ARRAY_SIZE(g_fm_channels) && channel < 0; i++)
|
||||
if (g_fm_channels[i] == g_eeprom.fm_frequency_playing)
|
||||
for (i = 0; i < ARRAY_SIZE(g_eeprom.config.setting.fm_channel) && channel < 0; i++)
|
||||
if (g_eeprom.config.setting.fm_channel[i] == g_eeprom.config.setting.fm_radio.selected_frequency)
|
||||
channel = i; // found it in the channel list
|
||||
|
||||
g_request_display_screen = DISPLAY_FM;
|
||||
@ -568,16 +564,16 @@ static void FM_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
if (g_fm_scan_state_dir == FM_SCAN_STATE_DIR_OFF)
|
||||
{ // not scanning
|
||||
|
||||
if (!g_eeprom.fm_channel_mode)
|
||||
if (g_eeprom.config.setting.fm_radio.channel_mode == 0)
|
||||
{ // frequency mode
|
||||
|
||||
if (g_ask_to_save)
|
||||
{
|
||||
if (channel < 0)
|
||||
{
|
||||
g_fm_channels[g_fm_channel_position] = g_eeprom.fm_frequency_playing;
|
||||
g_ask_to_save = false;
|
||||
g_request_save_fm = true;
|
||||
g_eeprom.config.setting.fm_channel[g_fm_channel_position] = g_eeprom.config.setting.fm_radio.selected_frequency;
|
||||
g_ask_to_save = false;
|
||||
g_request_save_fm = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -588,10 +584,10 @@ static void FM_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
{ // channel mode
|
||||
if (g_ask_to_delete)
|
||||
{
|
||||
g_fm_channels[g_eeprom.fm_selected_channel] = 0xFFFF;
|
||||
g_eeprom.config.setting.fm_channel[g_eeprom.config.setting.fm_radio.selected_channel] = 0xFFFF;
|
||||
|
||||
FM_configure_channel_state();
|
||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||
BK1080_SetFrequency(g_eeprom.config.setting.fm_radio.selected_frequency);
|
||||
|
||||
g_request_save_fm = true;
|
||||
g_ask_to_delete = false;
|
||||
@ -621,7 +617,7 @@ static void FM_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
|
||||
if (g_ask_to_save)
|
||||
{
|
||||
g_fm_channels[g_fm_channel_position] = g_eeprom.fm_frequency_playing;
|
||||
g_eeprom.config.setting.fm_channel[g_fm_channel_position] = g_eeprom.config.setting.fm_radio.selected_frequency;
|
||||
g_ask_to_save = false;
|
||||
g_request_save_fm = true;
|
||||
return;
|
||||
@ -664,32 +660,32 @@ static void FM_Key_UP_DOWN(const bool key_pressed, const bool key_held, const fm
|
||||
if (g_fm_auto_scan)
|
||||
return;
|
||||
|
||||
FM_tune(g_eeprom.fm_frequency_playing, scan_state_dir, false);
|
||||
FM_tune(g_eeprom.config.setting.fm_radio.selected_frequency, scan_state_dir, false);
|
||||
|
||||
g_request_display_screen = DISPLAY_FM;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_eeprom.fm_channel_mode)
|
||||
if (g_eeprom.config.setting.fm_radio.channel_mode != 0)
|
||||
{ // we're in channel mode
|
||||
const uint8_t Channel = FM_find_next_channel(g_eeprom.fm_selected_channel + scan_state_dir, scan_state_dir);
|
||||
if (Channel == 0xFF || g_eeprom.fm_selected_channel == Channel)
|
||||
const uint8_t Channel = FM_find_next_channel(g_eeprom.config.setting.fm_radio.selected_channel + scan_state_dir, scan_state_dir);
|
||||
if (Channel == 0xFF || g_eeprom.config.setting.fm_radio.selected_channel == Channel)
|
||||
goto Bail;
|
||||
|
||||
g_eeprom.fm_selected_channel = Channel;
|
||||
g_eeprom.fm_frequency_playing = g_fm_channels[Channel];
|
||||
g_eeprom.config.setting.fm_radio.selected_channel = Channel;
|
||||
g_eeprom.config.setting.fm_radio.selected_frequency = g_eeprom.config.setting.fm_channel[Channel];
|
||||
}
|
||||
else
|
||||
{ // no, frequency mode
|
||||
uint16_t Frequency = g_eeprom.fm_selected_frequency + scan_state_dir;
|
||||
uint16_t Frequency = g_eeprom.config.setting.fm_radio.selected_frequency + scan_state_dir;
|
||||
if (Frequency < BK1080_freq_lower)
|
||||
Frequency = BK1080_freq_upper - 1u;
|
||||
else
|
||||
if (Frequency >= BK1080_freq_upper)
|
||||
Frequency = BK1080_freq_lower;
|
||||
|
||||
g_eeprom.fm_frequency_playing = Frequency;
|
||||
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
|
||||
g_eeprom.config.setting.fm_radio.selected_frequency = Frequency;
|
||||
// g_eeprom.config.setting.fm_radio.selected_frequency = g_eeprom.fm_frequency_playing;
|
||||
}
|
||||
|
||||
if (g_current_display_screen == DISPLAY_FM && g_fm_scan_state_dir == FM_SCAN_STATE_DIR_OFF)
|
||||
@ -704,7 +700,7 @@ static void FM_Key_UP_DOWN(const bool key_pressed, const bool key_held, const fm
|
||||
g_request_save_fm = true;
|
||||
|
||||
Bail:
|
||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||
BK1080_SetFrequency(g_eeprom.config.setting.fm_radio.selected_frequency);
|
||||
|
||||
g_request_display_screen = DISPLAY_FM;
|
||||
}
|
||||
|
1
app/fm.h
1
app/fm.h
@ -29,7 +29,6 @@ enum fm_scan_state_dir_e {
|
||||
};
|
||||
typedef enum fm_scan_state_dir_e fm_scan_state_dir_t;
|
||||
|
||||
extern uint16_t g_fm_channels[20];
|
||||
extern bool g_fm_radio_mode;
|
||||
extern fm_scan_state_dir_t g_fm_scan_state_dir;
|
||||
extern bool g_fm_auto_scan;
|
||||
|
@ -56,10 +56,10 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
|
||||
{ // toggle the keyboad lock
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = g_eeprom.key_lock ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
||||
g_another_voice_id = g_eeprom.config.setting.key_lock ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
||||
#endif
|
||||
|
||||
g_eeprom.key_lock = !g_eeprom.key_lock;
|
||||
g_eeprom.config.setting.key_lock = (g_eeprom.key_lock + 1) & 1u;
|
||||
g_request_save_settings = true;
|
||||
g_update_status = true;
|
||||
|
||||
@ -113,10 +113,10 @@ void GENERIC_Key_PTT(bool key_pressed)
|
||||
{
|
||||
APP_end_tx();
|
||||
|
||||
if (g_eeprom.repeater_tail_tone_elimination == 0)
|
||||
if (g_eeprom.config.setting.repeater_tail_tone_elimination == 0)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
else
|
||||
g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10;
|
||||
g_rtte_count_down = g_eeprom.config.setting.repeater_tail_tone_elimination * 10;
|
||||
}
|
||||
|
||||
g_flag_end_tx = false;
|
||||
@ -147,7 +147,7 @@ void GENERIC_Key_PTT(bool key_pressed)
|
||||
|
||||
if (g_current_display_screen == DISPLAY_SEARCH)
|
||||
{ // CTCSS/CDCSS scanning .. stop
|
||||
g_eeprom.cross_vfo_rx_tx = g_backup_cross_vfo_rx_tx;
|
||||
g_eeprom.config.setting.cross_vfo = g_backup_cross_vfo;
|
||||
g_search_flag_stop_scan = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_flag_reset_vfos = true;
|
||||
|
134
app/main.c
134
app/main.c
@ -47,7 +47,7 @@ bool g_manual_scanning;
|
||||
|
||||
bool scanning_paused(void)
|
||||
{
|
||||
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) &&
|
||||
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF) &&
|
||||
g_scan_pause_tick_10ms > 0 && g_scan_pause_tick_10ms <= (200 / 10))
|
||||
{ // scanning isn't paused
|
||||
return false;
|
||||
@ -105,9 +105,9 @@ void toggle_chan_scanlist(void)
|
||||
void MAIN_copy_mem_vfo_mem(void)
|
||||
{
|
||||
//const unsigned int vfo = get_RX_VFO();
|
||||
const unsigned int vfo = g_eeprom.tx_vfo;
|
||||
const unsigned int vfo = g_eeprom.config.setting.tx_vfo_num;
|
||||
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF || !g_eeprom.vfo_open)
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF || g_eeprom.config.setting.vfo_open == 0)
|
||||
{ // scanning or VFO disabled
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
@ -119,14 +119,14 @@ void toggle_chan_scanlist(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (IS_USER_CHANNEL(g_eeprom.screen_channel[vfo]))
|
||||
if (IS_USER_CHANNEL(g_eeprom.config.setting.indices.vfo[vfo].screen))
|
||||
{ // copy channel to VFO, then swap to the VFO
|
||||
|
||||
const unsigned int channel = FREQ_CHANNEL_FIRST + g_eeprom.vfo_info[vfo].band;
|
||||
const unsigned int channel = FREQ_CHANNEL_FIRST + g_vfo_info[vfo].band;
|
||||
|
||||
g_eeprom.screen_channel[vfo] = channel;
|
||||
g_eeprom.vfo_info[vfo].channel_save = channel;
|
||||
g_eeprom.tx_vfo = vfo;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = channel;
|
||||
g_vfo_info[vfo].channel_save = channel;
|
||||
g_eeprom.config.setting.tx_vfo_num = vfo;
|
||||
|
||||
RADIO_select_vfos();
|
||||
RADIO_ApplyOffset(g_tx_vfo, false);
|
||||
@ -135,9 +135,9 @@ void toggle_chan_scanlist(void)
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
// find the first channel that contains this frequency
|
||||
g_tx_vfo->freq_in_channel = BOARD_find_channel(g_tx_vfo->freq_config_tx.frequency);
|
||||
g_tx_vfo->freq_in_channel = SETTINGS_find_channel(g_tx_vfo->freq_config_tx.frequency);
|
||||
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, 1);
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.config.setting.tx_vfo_num, g_tx_vfo, 1);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("chan-vfo %u\r\n", g_tx_vfo->channel_save);
|
||||
@ -150,14 +150,14 @@ void toggle_chan_scanlist(void)
|
||||
g_update_display = true;
|
||||
}
|
||||
else
|
||||
if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[vfo]))
|
||||
if (IS_NOT_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[vfo].screen))
|
||||
{ // copy VFO to a channel
|
||||
|
||||
// search the channels to see if the frequency is already present
|
||||
unsigned int chan = BOARD_find_channel(g_eeprom.vfo_info[vfo].p_tx->frequency);
|
||||
unsigned int chan = SETTINGS_find_channel(g_vfo_info[vfo].p_tx->frequency);
|
||||
if (chan > USER_CHANNEL_LAST)
|
||||
{ // not found - find next free channel to save too
|
||||
//for (chan = g_eeprom.screen_channel[vfo]; chan <= USER_CHANNEL_LAST; chan++)
|
||||
//for (chan = g_eeprom.config.setting.indices.vfo[vfo].screen; chan <= USER_CHANNEL_LAST; chan++)
|
||||
for (chan = 0; chan <= USER_CHANNEL_LAST; chan++)
|
||||
if (!RADIO_CheckValidChannel(chan, false, vfo))
|
||||
break;
|
||||
@ -192,7 +192,7 @@ void toggle_chan_scanlist(void)
|
||||
void processFKeyFunction(const key_code_t Key)
|
||||
{
|
||||
uint8_t Band;
|
||||
uint8_t Vfo = g_eeprom.tx_vfo;
|
||||
uint8_t vfo = g_eeprom.config.setting.tx_vfo_num;
|
||||
|
||||
if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen == DISPLAY_MENU)
|
||||
{
|
||||
@ -243,7 +243,7 @@ void processFKeyFunction(const key_code_t Key)
|
||||
APP_stop_scan();
|
||||
|
||||
Band = g_tx_vfo->band + 1;
|
||||
if (g_setting_350_enable || Band != BAND5_350MHz)
|
||||
if (g_eeprom.config.setting.enable_350 || Band != BAND5_350MHz)
|
||||
{
|
||||
if (Band > BAND7_470MHz)
|
||||
Band = BAND1_50MHz; // wrap-a-round
|
||||
@ -252,8 +252,8 @@ void processFKeyFunction(const key_code_t Key)
|
||||
Band = BAND6_400MHz; // jump to next band
|
||||
g_tx_vfo->band = Band;
|
||||
|
||||
g_eeprom.screen_channel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
||||
g_eeprom.freq_channel[Vfo] = FREQ_CHANNEL_FIRST + Band;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = FREQ_CHANNEL_FIRST + Band;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].frequency = FREQ_CHANNEL_FIRST + Band;
|
||||
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
@ -265,19 +265,19 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
APP_stop_scan();
|
||||
|
||||
if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_A)
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_CHAN_B;
|
||||
if (g_eeprom.config.setting.cross_vfo == CROSS_BAND_CHAN_A)
|
||||
g_eeprom.config.setting.cross_vfo = CROSS_BAND_CHAN_B;
|
||||
else
|
||||
if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B)
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_CHAN_A;
|
||||
if (g_eeprom.config.setting.cross_vfo == CROSS_BAND_CHAN_B)
|
||||
g_eeprom.config.setting.cross_vfo = CROSS_BAND_CHAN_A;
|
||||
else
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_A)
|
||||
g_eeprom.dual_watch = DUAL_WATCH_CHAN_B;
|
||||
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_CHAN_A)
|
||||
g_eeprom.config.setting.dual_watch = DUAL_WATCH_CHAN_B;
|
||||
else
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_B)
|
||||
g_eeprom.dual_watch = DUAL_WATCH_CHAN_A;
|
||||
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_CHAN_B)
|
||||
g_eeprom.config.setting.dual_watch = DUAL_WATCH_CHAN_A;
|
||||
else
|
||||
g_eeprom.tx_vfo = (Vfo + 1) & 1u;
|
||||
g_eeprom.config.setting.tx_vfo_num = (vfo + 1) & 1u;
|
||||
|
||||
g_request_save_settings = 1;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
@ -289,13 +289,13 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
APP_stop_scan();
|
||||
|
||||
if (g_eeprom.vfo_open && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
if (g_eeprom.config.setting.vfo_open > 0 && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
{
|
||||
uint8_t Channel;
|
||||
|
||||
if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // swap to frequency mode
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo];
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].frequency;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_FREQUENCY_MODE;
|
||||
@ -306,10 +306,10 @@ void processFKeyFunction(const key_code_t Key)
|
||||
break;
|
||||
}
|
||||
|
||||
Channel = RADIO_FindNextChannel(g_eeprom.user_channel[g_eeprom.tx_vfo], 1, false, 0);
|
||||
Channel = RADIO_FindNextChannel(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user, 1, false, 0);
|
||||
if (Channel != 0xFF)
|
||||
{ // swap to channel mode
|
||||
g_eeprom.screen_channel[Vfo] = Channel;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen= Channel;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
|
||||
@ -333,8 +333,8 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
g_search_flag_start_scan = true;
|
||||
g_search_single_frequency = false;
|
||||
g_backup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx;
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
|
||||
g_backup_cross_vfo = g_eeprom.config.setting.cross_vfo;
|
||||
g_eeprom.config.setting.cross_vfo = CROSS_BAND_OFF;
|
||||
break;
|
||||
|
||||
case KEY_5: // NOAA
|
||||
@ -345,11 +345,11 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
if (IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
{
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom.noaa_channel[g_eeprom.tx_vfo];
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = g_eeprom.config.setting.indices.noaa_channel[g_eeprom.config.setting.tx_vfo_num];
|
||||
}
|
||||
else
|
||||
{
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo];
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].frequency;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_FREQUENCY_MODE;
|
||||
@ -404,7 +404,7 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
case KEY_9: // CALL
|
||||
|
||||
if (!RADIO_CheckValidChannel(g_eeprom2.config.call1, false, 0))
|
||||
if (!RADIO_CheckValidChannel(g_eeprom.config.setting.call1, false, 0))
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
@ -414,13 +414,13 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
APP_stop_scan();
|
||||
|
||||
g_eeprom.user_channel[Vfo] = g_eeprom2.config.call1;
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom2.config.call1;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].user = g_eeprom.config.setting.call1;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = g_eeprom.config.setting.call1;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
|
||||
AUDIO_SetDigitVoice(1, 1 + g_eeprom2.config.call1);
|
||||
g_another_voice_id = (voice_id_t)0xFE;
|
||||
AUDIO_SetDigitVoice(1, 1 + g_eeprom.config.setting.call1);
|
||||
g_another_voice_id = (voice_id_t)0xFE;
|
||||
#endif
|
||||
|
||||
g_request_save_vfo = true;
|
||||
@ -436,6 +436,8 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
{
|
||||
const uint8_t vfo = g_eeprom.config.setting.tx_vfo_num;
|
||||
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
if (key_held)
|
||||
@ -477,8 +479,6 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t Vfo = g_eeprom.tx_vfo;
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_current_function == FUNCTION_TRANSMIT)
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
@ -520,8 +520,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[Vfo] = (uint8_t)Channel;
|
||||
g_eeprom.screen_channel[Vfo] = (uint8_t)Channel;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].user = (uint8_t)Channel;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = (uint8_t)Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
@ -568,13 +568,13 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
|
||||
if (g_tx_vfo->band != band)
|
||||
{
|
||||
g_tx_vfo->band = band;
|
||||
g_eeprom.screen_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||
g_eeprom.freq_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||
g_tx_vfo->band = band;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = band + FREQ_CHANNEL_FIRST;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].frequency = band + FREQ_CHANNEL_FIRST;
|
||||
|
||||
SETTINGS_save_vfo_indices();
|
||||
|
||||
RADIO_configure_channel(Vfo, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(vfo, VFO_CONFIGURE_RELOAD);
|
||||
}
|
||||
|
||||
Frequency += g_tx_vfo->step_freq / 2; // for rounding to nearest step size
|
||||
@ -590,7 +590,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_tx_vfo->freq_config_tx.frequency = Frequency;
|
||||
|
||||
// find the first channel that contains this frequency
|
||||
g_tx_vfo->freq_in_channel = BOARD_find_channel(Frequency);
|
||||
g_tx_vfo->freq_in_channel = SETTINGS_find_channel(Frequency);
|
||||
|
||||
g_request_save_channel = 1;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE;
|
||||
@ -610,7 +610,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
if (g_input_box_index != 2)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
// g_request_display_screen = DISPLAY_MAIN;
|
||||
return;
|
||||
@ -621,15 +621,15 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
Channel = (g_input_box[0] * 10) + g_input_box[1];
|
||||
if (Channel >= 1 && Channel <= ARRAY_SIZE(NOAA_FREQUENCY_TABLE))
|
||||
{
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
g_eeprom.noaa_channel[Vfo] = Channel;
|
||||
g_eeprom.screen_channel[Vfo] = Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_update_display = true;
|
||||
g_eeprom.config.setting.indices.noaa_channel[vfo] = Channel;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_update_display = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -845,8 +845,8 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
||||
// scan the CTCSS/DCS code
|
||||
g_search_flag_start_scan = true;
|
||||
g_search_single_frequency = true;
|
||||
g_backup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx;
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
|
||||
g_backup_cross_vfo = g_eeprom.config.setting.cross_vfo;
|
||||
g_eeprom.config.setting.cross_vfo = CROSS_BAND_OFF;
|
||||
}
|
||||
|
||||
g_ptt_was_released = true;
|
||||
@ -860,7 +860,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
static bool monitor_was_enabled = false;
|
||||
#endif
|
||||
|
||||
uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo];
|
||||
uint8_t Channel = g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen;
|
||||
|
||||
if (key_pressed && !key_held)
|
||||
{ // key just pressed
|
||||
@ -886,9 +886,9 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
g_tx_vfo->freq_config_tx.frequency = g_tx_vfo->freq_config_rx.frequency;
|
||||
|
||||
// find the first channel that contains this frequency
|
||||
g_tx_vfo->freq_in_channel = BOARD_find_channel(g_tx_vfo->freq_config_rx.frequency);
|
||||
g_tx_vfo->freq_in_channel = SETTINGS_find_channel(g_tx_vfo->freq_config_rx.frequency);
|
||||
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, 1);
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.config.setting.tx_vfo_num, g_tx_vfo, 1);
|
||||
|
||||
RADIO_ApplyOffset(g_tx_vfo, true);
|
||||
|
||||
@ -969,7 +969,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
// TODO: include this once we have the entire eeprom loaded
|
||||
//
|
||||
//if (!key_held && key_pressed)
|
||||
// g_tx_vfo->freq_in_channel = BOARD_find_channel(frequency);
|
||||
// g_tx_vfo->freq_in_channel = SETTINGS_find_channel(frequency);
|
||||
//else
|
||||
//if (key_held && key_pressed)
|
||||
g_tx_vfo->freq_in_channel = 0xff;
|
||||
@ -1027,8 +1027,8 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
}
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[g_eeprom.tx_vfo] = Next;
|
||||
g_eeprom.screen_channel[g_eeprom.tx_vfo] = Next;
|
||||
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user = Next;
|
||||
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen = Next;
|
||||
|
||||
if (!key_held)
|
||||
{
|
||||
@ -1041,9 +1041,9 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
{
|
||||
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(g_eeprom.screen_channel[g_eeprom.tx_vfo] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
|
||||
g_eeprom.noaa_channel[g_eeprom.tx_vfo] = Channel;
|
||||
g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel;
|
||||
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen - NOAA_CHANNEL_FIRST, Direction, 0, 9);
|
||||
g_eeprom.config.setting.indices.noaa_channel[g_eeprom.config.setting.tx_vfo_num] = Channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen = Channel;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
265
app/menu.c
265
app/menu.c
@ -61,7 +61,7 @@
|
||||
uint8_t dac_gain;
|
||||
} __attribute__((packed)) misc;
|
||||
|
||||
g_eeprom.BK4819_xtal_freq_low = value;
|
||||
g_eeprom.config.setting.BK4819_xtal_freq_low = value;
|
||||
|
||||
// radio 1 .. 04 00 46 00 50 00 2C 0E
|
||||
// radio 2 .. 05 00 46 00 50 00 2C 0E
|
||||
@ -406,7 +406,7 @@ void MENU_AcceptSetting(void)
|
||||
return;
|
||||
|
||||
case MENU_SQL:
|
||||
g_eeprom.squelch_level = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.squelch_level = g_sub_menu_selection;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE;
|
||||
break;
|
||||
|
||||
@ -509,7 +509,7 @@ void MENU_AcceptSetting(void)
|
||||
case MENU_SCRAMBLER:
|
||||
g_tx_vfo->scrambling_type = g_sub_menu_selection;
|
||||
#if 0
|
||||
if (g_sub_menu_selection > 0 && g_setting_scramble_enable)
|
||||
if (g_sub_menu_selection > 0 && g_eeprom.config.setting.enable_scrambler)
|
||||
BK4819_EnableScramble(g_sub_menu_selection - 1);
|
||||
else
|
||||
BK4819_DisableScramble();
|
||||
@ -525,13 +525,13 @@ void MENU_AcceptSetting(void)
|
||||
case MENU_MEM_SAVE:
|
||||
g_tx_vfo->channel_save = g_sub_menu_selection;
|
||||
#if 0
|
||||
g_eeprom.user_channel[0] = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.indices.vfo[0].user = g_sub_menu_selection;
|
||||
#else
|
||||
g_eeprom.user_channel[g_eeprom.tx_vfo] = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user = g_sub_menu_selection;
|
||||
#endif
|
||||
g_request_save_channel = 2;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_flag_reset_vfos = true;
|
||||
g_flag_reset_vfos = true;
|
||||
return;
|
||||
|
||||
case MENU_MEM_NAME:
|
||||
@ -547,30 +547,30 @@ void MENU_AcceptSetting(void)
|
||||
// save the channel name
|
||||
memset(g_tx_vfo->name, 0, sizeof(g_tx_vfo->name));
|
||||
memcpy(g_tx_vfo->name, g_edit, 10);
|
||||
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3);
|
||||
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.config.setting.tx_vfo_num, g_tx_vfo, 3);
|
||||
g_flag_reconfigure_vfos = true;
|
||||
return;
|
||||
|
||||
case MENU_BAT_SAVE:
|
||||
g_eeprom.battery_save = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.battery_save_ratio = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
case MENU_VOX:
|
||||
g_eeprom.vox_switch = g_sub_menu_selection != 0;
|
||||
if (g_eeprom.vox_switch)
|
||||
g_eeprom.vox_level = g_sub_menu_selection - 1;
|
||||
g_eeprom.config.setting.vox_switch = g_sub_menu_selection != 0;
|
||||
if (g_eeprom.config.setting.vox_switch)
|
||||
g_eeprom.config.setting.vox_level = g_sub_menu_selection - 1;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
g_update_status = true;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_AUTO_BACKLITE:
|
||||
g_eeprom.backlight = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.backlight_time = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_AUTO_BACKLITE_ON_TX_RX:
|
||||
g_setting_backlight_on_tx_rx = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.backlight_on_tx_rx = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_CONTRAST
|
||||
@ -581,54 +581,54 @@ void MENU_AcceptSetting(void)
|
||||
#endif
|
||||
|
||||
case MENU_DUAL_WATCH:
|
||||
// g_eeprom.dual_watch = g_sub_menu_selection;
|
||||
g_eeprom.dual_watch = (g_sub_menu_selection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF;
|
||||
// g_eeprom.config.setting.dual_watch = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.dual_watch = (g_sub_menu_selection > 0) ? 1 + g_eeprom.config.setting.tx_vfo_num : DUAL_WATCH_OFF;
|
||||
|
||||
g_flag_reconfigure_vfos = true;
|
||||
g_update_status = true;
|
||||
break;
|
||||
|
||||
case MENU_SCAN_HOLD:
|
||||
g_eeprom.scan_hold_time_500ms = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.scan_hold_time = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_CROSS_VFO:
|
||||
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[0]))
|
||||
if (IS_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[0].screen))
|
||||
return;
|
||||
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[1]))
|
||||
if (IS_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[1].screen))
|
||||
return;
|
||||
|
||||
g_eeprom.cross_vfo_rx_tx = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.cross_vfo = g_sub_menu_selection;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
g_update_status = true;
|
||||
break;
|
||||
|
||||
case MENU_BEEP:
|
||||
g_eeprom.beep_control = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.beep_control = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_TX_TO:
|
||||
g_eeprom.tx_timeout_timer = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.tx_timeout = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
case MENU_VOICE:
|
||||
g_eeprom.voice_prompt = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.voice_prompt = g_sub_menu_selection;
|
||||
g_update_status = true;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_SCAN_CAR_RESUME:
|
||||
g_eeprom.scan_resume_mode = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.carrier_search_mode = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_MEM_DISP:
|
||||
g_eeprom.channel_display_mode = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.channel_display_mode = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
case MENU_AUTO_KEY_LOCK:
|
||||
g_eeprom.auto_keypad_lock = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.auto_key_lock = g_sub_menu_selection;
|
||||
g_key_lock_tick_500ms = key_lock_timeout_500ms;
|
||||
break;
|
||||
#endif
|
||||
@ -648,29 +648,29 @@ void MENU_AcceptSetting(void)
|
||||
return;
|
||||
|
||||
case MENU_STE:
|
||||
g_eeprom.tail_note_elimination = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.tail_tone_elimination = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_RP_STE:
|
||||
g_eeprom.repeater_tail_tone_elimination = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.repeater_tail_tone_elimination = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_MIC_GAIN:
|
||||
g_eeprom.mic_sensitivity = g_sub_menu_selection;
|
||||
g_eeprom.mic_sensitivity_tuning = g_mic_gain_dB_2[g_eeprom.mic_sensitivity];
|
||||
BK4819_set_mic_gain(g_eeprom.mic_sensitivity_tuning);
|
||||
g_eeprom.config.setting.mic_sensitivity = g_sub_menu_selection;
|
||||
g_mic_sensitivity_tuning = g_mic_gain_dB_2[g_eeprom.config.setting.mic_sensitivity];
|
||||
BK4819_set_mic_gain(g_mic_sensitivity_tuning);
|
||||
g_flag_reconfigure_vfos = true;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_TX_AUDIO_BAR
|
||||
case MENU_TX_BAR:
|
||||
g_setting_mic_bar = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.mic_bar = g_sub_menu_selection;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_RX_SIGNAL_BAR
|
||||
case MENU_RX_BAR:
|
||||
g_setting_rssi_bar = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.enable_rssi_bar = g_sub_menu_selection;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -679,39 +679,39 @@ void MENU_AcceptSetting(void)
|
||||
#if 1
|
||||
g_request_save_channel = 1;
|
||||
#else
|
||||
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3);
|
||||
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.config.setting.tx_vfo_num, g_tx_vfo, 3);
|
||||
g_flag_reconfigure_vfos = true;
|
||||
#endif
|
||||
return;
|
||||
|
||||
case MENU_1_CALL:
|
||||
g_eeprom2.config.call1 = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.call1 = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_S_LIST:
|
||||
g_eeprom.scan_list_default = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.scan_list_default = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
case MENU_ALARM_MODE:
|
||||
g_eeprom.alarm_mode = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.alarm_mode = g_sub_menu_selection;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_DTMF_ST:
|
||||
g_eeprom.dtmf_side_tone = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.dtmf.side_tone = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_DTMF_RSP:
|
||||
g_eeprom.dtmf_decode_response = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.dtmf.decode_response = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_DTMF_HOLD:
|
||||
g_eeprom.dtmf_auto_reset_time = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.dtmf.auto_reset_time = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_DTMF_PRE:
|
||||
g_eeprom.dtmf_preload_time = g_sub_menu_selection * 10;
|
||||
g_eeprom.config.setting.dtmf.preload_time = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
@ -721,7 +721,7 @@ void MENU_AcceptSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_MDC1200_ID:
|
||||
g_eeprom.mdc1200_id = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.mdc1200_id = g_sub_menu_selection;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -731,14 +731,14 @@ void MENU_AcceptSetting(void)
|
||||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH ||
|
||||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
|
||||
{
|
||||
g_eeprom.roger_mode = ROGER_MODE_OFF;
|
||||
g_eeprom.config.setting.roger_mode = ROGER_MODE_OFF;
|
||||
break;
|
||||
}
|
||||
g_request_save_channel = 1;
|
||||
return;
|
||||
|
||||
case MENU_BAT_TXT:
|
||||
g_setting_battery_text = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.battery_text = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_DTMF_DCD:
|
||||
@ -748,10 +748,10 @@ void MENU_AcceptSetting(void)
|
||||
return;
|
||||
|
||||
case MENU_DTMF_LIVE_DEC:
|
||||
g_setting_live_dtmf_decoder = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.dtmf_live_decoder = g_sub_menu_selection;
|
||||
g_dtmf_rx_live_timeout = 0;
|
||||
memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live));
|
||||
if (!g_setting_live_dtmf_decoder)
|
||||
if (!g_eeprom.config.setting.dtmf_live_decoder)
|
||||
BK4819_DisableDTMF();
|
||||
g_flag_reconfigure_vfos = true;
|
||||
g_update_status = true;
|
||||
@ -770,12 +770,12 @@ void MENU_AcceptSetting(void)
|
||||
return;
|
||||
|
||||
case MENU_PON_MSG:
|
||||
g_eeprom.pwr_on_display_mode = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.power_on_display_mode = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_ROGER_MODE:
|
||||
g_eeprom.roger_mode = g_sub_menu_selection;
|
||||
if (g_eeprom.roger_mode != ROGER_MODE_OFF)
|
||||
g_eeprom.config.setting.roger_mode = g_sub_menu_selection;
|
||||
if (g_eeprom.config.setting.roger_mode != ROGER_MODE_OFF)
|
||||
{
|
||||
if (g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN ||
|
||||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH ||
|
||||
@ -794,7 +794,7 @@ void MENU_AcceptSetting(void)
|
||||
/*
|
||||
#ifdef ENABLE_AM_FIX
|
||||
case MENU_AM_FIX:
|
||||
g_setting_am_fix = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.am_fix = g_sub_menu_selection;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_flag_reset_vfos = true;
|
||||
break;
|
||||
@ -802,7 +802,7 @@ void MENU_AcceptSetting(void)
|
||||
*/
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
case MENU_AM_FIX_TEST1:
|
||||
g_setting_am_fix_test1 = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.am_fix_test1 = g_sub_menu_selection;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_flag_reset_vfos = true;
|
||||
break;
|
||||
@ -810,7 +810,7 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
case MENU_NOAA_SCAN:
|
||||
g_eeprom.noaa_auto_scan = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.noaa_auto_scan = g_sub_menu_selection;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
break;
|
||||
#endif
|
||||
@ -823,55 +823,55 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
#ifdef ENABLE_SIDE_BUTT_MENU
|
||||
case MENU_SIDE1_SHORT:
|
||||
g_eeprom.key1_short_press_action = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.key1_short = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_SIDE1_LONG:
|
||||
g_eeprom.key1_long_press_action = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.key1_long = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_SHORT:
|
||||
g_eeprom.key2_short_press_action = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.key2_short = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_LONG:
|
||||
g_eeprom.key2_long_press_action = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.key2_long = g_sub_menu_selection;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_RESET:
|
||||
BOARD_FactoryReset(g_sub_menu_selection);
|
||||
SETTINGS_factory_reset(g_sub_menu_selection);
|
||||
return;
|
||||
|
||||
case MENU_350_TX:
|
||||
g_setting_350_tx_enable = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.enable_tx_350 = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_FREQ_LOCK:
|
||||
g_setting_freq_lock = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.freq_lock = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_174_TX:
|
||||
g_setting_174_tx_enable = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.enable_tx_200 = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_470_TX:
|
||||
g_setting_470_tx_enable = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.enable_tx_470 = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_350_EN:
|
||||
g_setting_350_enable = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.enable_350 = g_sub_menu_selection;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_flag_reset_vfos = true;
|
||||
break;
|
||||
|
||||
case MENU_SCRAMBLER_EN:
|
||||
g_setting_scramble_enable = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.enable_scrambler = g_sub_menu_selection;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
break;
|
||||
|
||||
case MENU_TX_EN:
|
||||
g_setting_tx_enable = g_sub_menu_selection;
|
||||
g_eeprom.config.setting.tx_enable = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_F_CAL_MENU
|
||||
@ -882,20 +882,15 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
case MENU_BAT_CAL:
|
||||
{
|
||||
uint16_t buf[4];
|
||||
g_eeprom.calib.battery[0] = (520ul * g_sub_menu_selection) / 760; // 5.20V empty, blinking above this value, reduced functionality below
|
||||
g_eeprom.calib.battery[1] = (700ul * g_sub_menu_selection) / 760; // 7.00V, ~5%, 1 bars above this value
|
||||
g_eeprom.calib.battery[2] = (745ul * g_sub_menu_selection) / 760; // 7.45V, ~17%, 2 bars above this value
|
||||
g_eeprom.calib.battery[3] = g_sub_menu_selection; // 7.6V, ~29%, 3 bars above this value
|
||||
g_eeprom.calib.battery[4] = (788ul * g_sub_menu_selection) / 760; // 7.88V, ~65%, 4 bars above this value
|
||||
g_eeprom.calib.battery[5] = 2300;
|
||||
|
||||
g_battery_calibration[0] = (520ul * g_sub_menu_selection) / 760; // 5.20V empty, blinking above this value, reduced functionality below
|
||||
g_battery_calibration[1] = (700ul * g_sub_menu_selection) / 760; // 7.00V, ~5%, 1 bars above this value
|
||||
g_battery_calibration[2] = (745ul * g_sub_menu_selection) / 760; // 7.45V, ~17%, 2 bars above this value
|
||||
g_battery_calibration[3] = g_sub_menu_selection; // 7.6V, ~29%, 3 bars above this value
|
||||
g_battery_calibration[4] = (788ul * g_sub_menu_selection) / 760; // 7.88V, ~65%, 4 bars above this value
|
||||
g_battery_calibration[5] = 2300;
|
||||
EEPROM_WriteBuffer8(0x1F40, g_battery_calibration);
|
||||
|
||||
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
|
||||
buf[0] = g_battery_calibration[4];
|
||||
buf[1] = g_battery_calibration[5];
|
||||
EEPROM_WriteBuffer8(0x1F48, buf);
|
||||
EEPROM_WriteBuffer8(0x1F40, &g_eeprom.calib.battery[0]);
|
||||
EEPROM_WriteBuffer8(0x1F48, &g_eeprom.calib.battery[4]);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -966,7 +961,7 @@ void MENU_ShowCurrentSetting(void)
|
||||
switch (g_menu_cursor)
|
||||
{
|
||||
case MENU_SQL:
|
||||
g_sub_menu_selection = g_eeprom.squelch_level;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.squelch_level;
|
||||
break;
|
||||
|
||||
case MENU_CHAN_SQL:
|
||||
@ -1045,35 +1040,35 @@ void MENU_ShowCurrentSetting(void)
|
||||
|
||||
case MENU_MEM_SAVE:
|
||||
#if 0
|
||||
g_sub_menu_selection = g_eeprom.user_channel[0];
|
||||
g_sub_menu_selection = g_eeprom.config.setting.indices.vfo[0].user;
|
||||
#else
|
||||
g_sub_menu_selection = g_eeprom.user_channel[g_eeprom.tx_vfo];
|
||||
g_sub_menu_selection = g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case MENU_MEM_NAME:
|
||||
g_sub_menu_selection = g_eeprom.user_channel[g_eeprom.tx_vfo];
|
||||
g_sub_menu_selection = g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user;
|
||||
break;
|
||||
|
||||
case MENU_BAT_SAVE:
|
||||
g_sub_menu_selection = g_eeprom.battery_save;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.battery_save_ratio;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
case MENU_VOX:
|
||||
g_sub_menu_selection = g_eeprom.vox_switch ? g_eeprom.vox_level + 1 : 0;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.vox_switch ? g_eeprom.config.setting.vox_level + 1 : 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_AUTO_BACKLITE:
|
||||
g_sub_menu_selection = g_eeprom.backlight;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.backlight_time;
|
||||
|
||||
g_backlight_count_down = 0;
|
||||
g_backlight_tick_500ms = 0;
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON while in backlight menu
|
||||
break;
|
||||
|
||||
case MENU_AUTO_BACKLITE_ON_TX_RX:
|
||||
g_sub_menu_selection = g_setting_backlight_on_tx_rx;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.backlight_on_tx_rx;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_CONTRAST
|
||||
@ -1083,43 +1078,43 @@ void MENU_ShowCurrentSetting(void)
|
||||
#endif
|
||||
|
||||
case MENU_DUAL_WATCH:
|
||||
// g_sub_menu_selection = g_eeprom.dual_watch;
|
||||
g_sub_menu_selection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1;
|
||||
// g_sub_menu_selection = g_eeprom.config.setting.dual_watch;
|
||||
g_sub_menu_selection = (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF) ? 0 : 1;
|
||||
break;
|
||||
|
||||
case MENU_SCAN_HOLD:
|
||||
g_sub_menu_selection = g_eeprom.scan_hold_time_500ms;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.scan_hold_time;
|
||||
break;
|
||||
|
||||
case MENU_CROSS_VFO:
|
||||
g_sub_menu_selection = g_eeprom.cross_vfo_rx_tx;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.cross_vfo;
|
||||
break;
|
||||
|
||||
case MENU_BEEP:
|
||||
g_sub_menu_selection = g_eeprom.beep_control;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.beep_control;
|
||||
break;
|
||||
|
||||
case MENU_TX_TO:
|
||||
g_sub_menu_selection = g_eeprom.tx_timeout_timer;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.tx_timeout;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
case MENU_VOICE:
|
||||
g_sub_menu_selection = g_eeprom.voice_prompt;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.voice_prompt;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_SCAN_CAR_RESUME:
|
||||
g_sub_menu_selection = g_eeprom.scan_resume_mode;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.carrier_search_mode;
|
||||
break;
|
||||
|
||||
case MENU_MEM_DISP:
|
||||
g_sub_menu_selection = g_eeprom.channel_display_mode;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.channel_display_mode;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
case MENU_AUTO_KEY_LOCK:
|
||||
g_sub_menu_selection = g_eeprom.auto_keypad_lock;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.auto_key_lock;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -1132,26 +1127,26 @@ void MENU_ShowCurrentSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_STE:
|
||||
g_sub_menu_selection = g_eeprom.tail_note_elimination;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.tail_tone_elimination;
|
||||
break;
|
||||
|
||||
case MENU_RP_STE:
|
||||
g_sub_menu_selection = g_eeprom.repeater_tail_tone_elimination;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.repeater_tail_tone_elimination;
|
||||
break;
|
||||
|
||||
case MENU_MIC_GAIN:
|
||||
g_sub_menu_selection = g_eeprom.mic_sensitivity;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.mic_sensitivity;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_TX_AUDIO_BAR
|
||||
case MENU_TX_BAR:
|
||||
g_sub_menu_selection = g_setting_mic_bar;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.mic_bar;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_RX_SIGNAL_BAR
|
||||
case MENU_RX_BAR:
|
||||
g_sub_menu_selection = g_setting_rssi_bar;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.enable_rssi_bar;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -1160,11 +1155,11 @@ void MENU_ShowCurrentSetting(void)
|
||||
return;
|
||||
|
||||
case MENU_1_CALL:
|
||||
g_sub_menu_selection = g_eeprom2.config.call1;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.call1;
|
||||
break;
|
||||
|
||||
case MENU_S_LIST:
|
||||
g_sub_menu_selection = g_eeprom.scan_list_default;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.scan_list_default;
|
||||
break;
|
||||
|
||||
case MENU_SLIST1:
|
||||
@ -1177,20 +1172,20 @@ void MENU_ShowCurrentSetting(void)
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
case MENU_ALARM_MODE:
|
||||
g_sub_menu_selection = g_eeprom.alarm_mode;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.alarm_mode;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_DTMF_ST:
|
||||
g_sub_menu_selection = g_eeprom.dtmf_side_tone;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.dtmf.side_tone;
|
||||
break;
|
||||
|
||||
case MENU_DTMF_RSP:
|
||||
g_sub_menu_selection = g_eeprom.dtmf_decode_response;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.dtmf.decode_response;
|
||||
break;
|
||||
|
||||
case MENU_DTMF_HOLD:
|
||||
g_sub_menu_selection = g_eeprom.dtmf_auto_reset_time;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.dtmf.auto_reset_time;
|
||||
|
||||
if (g_sub_menu_selection <= DTMF_HOLD_MIN)
|
||||
g_sub_menu_selection = DTMF_HOLD_MIN;
|
||||
@ -1218,7 +1213,7 @@ void MENU_ShowCurrentSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_DTMF_PRE:
|
||||
g_sub_menu_selection = g_eeprom.dtmf_preload_time / 10;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.dtmf.preload_time;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
@ -1227,7 +1222,7 @@ void MENU_ShowCurrentSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_MDC1200_ID:
|
||||
g_sub_menu_selection = g_eeprom.mdc1200_id;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.mdc1200_id;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -1236,7 +1231,7 @@ void MENU_ShowCurrentSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_BAT_TXT:
|
||||
g_sub_menu_selection = g_setting_battery_text;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.battery_text;
|
||||
return;
|
||||
|
||||
case MENU_DTMF_DCD:
|
||||
@ -1248,15 +1243,15 @@ void MENU_ShowCurrentSetting(void)
|
||||
break;
|
||||
|
||||
case MENU_DTMF_LIVE_DEC:
|
||||
g_sub_menu_selection = g_setting_live_dtmf_decoder;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.dtmf_live_decoder;
|
||||
break;
|
||||
|
||||
case MENU_PON_MSG:
|
||||
g_sub_menu_selection = g_eeprom.pwr_on_display_mode;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.power_on_display_mode;
|
||||
break;
|
||||
|
||||
case MENU_ROGER_MODE:
|
||||
g_sub_menu_selection = g_eeprom.roger_mode;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.roger_mode;
|
||||
break;
|
||||
|
||||
case MENU_MOD_MODE:
|
||||
@ -1265,84 +1260,84 @@ void MENU_ShowCurrentSetting(void)
|
||||
/*
|
||||
#ifdef ENABLE_AM_FIX
|
||||
case MENU_AM_FIX:
|
||||
g_sub_menu_selection = g_setting_am_fix;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.am_fix;
|
||||
break;
|
||||
#endif
|
||||
*/
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
case MENU_AM_FIX_TEST1:
|
||||
g_sub_menu_selection = g_setting_am_fix_test1;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.am_fix_test1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
case MENU_NOAA_SCAN:
|
||||
g_sub_menu_selection = g_eeprom.noaa_auto_scan;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.noaa_auto_scan;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_MEM_DEL:
|
||||
#if 0
|
||||
g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.user_channel[0], 1, false, 1);
|
||||
g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.config.setting.indices.vfo[0].user, 1, false, 1);
|
||||
#else
|
||||
g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.user_channel[g_eeprom.tx_vfo], 1, false, 1);
|
||||
g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user, 1, false, 1);
|
||||
#endif
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_SIDE_BUTT_MENU
|
||||
case MENU_SIDE1_SHORT:
|
||||
g_sub_menu_selection = g_eeprom.key1_short_press_action;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.key1_short;
|
||||
break;
|
||||
|
||||
case MENU_SIDE1_LONG:
|
||||
g_sub_menu_selection = g_eeprom.key1_long_press_action;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.key1_long;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_SHORT:
|
||||
g_sub_menu_selection = g_eeprom.key2_short_press_action;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.key2_short;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_LONG:
|
||||
g_sub_menu_selection = g_eeprom.key2_long_press_action;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.key2_long;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_350_TX:
|
||||
g_sub_menu_selection = g_setting_350_tx_enable;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.enable_tx_350;
|
||||
break;
|
||||
|
||||
case MENU_FREQ_LOCK:
|
||||
g_sub_menu_selection = g_setting_freq_lock;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.freq_lock;
|
||||
break;
|
||||
|
||||
case MENU_174_TX:
|
||||
g_sub_menu_selection = g_setting_174_tx_enable;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.enable_tx_200;
|
||||
break;
|
||||
|
||||
case MENU_470_TX:
|
||||
g_sub_menu_selection = g_setting_470_tx_enable;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.enable_tx_470;
|
||||
break;
|
||||
|
||||
case MENU_350_EN:
|
||||
g_sub_menu_selection = g_setting_350_enable;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.enable_350;
|
||||
break;
|
||||
|
||||
case MENU_SCRAMBLER_EN:
|
||||
g_sub_menu_selection = g_setting_scramble_enable;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.enable_scrambler;
|
||||
break;
|
||||
|
||||
case MENU_TX_EN:
|
||||
g_sub_menu_selection = g_setting_tx_enable;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.tx_enable;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_F_CAL_MENU
|
||||
case MENU_F_CALI:
|
||||
g_sub_menu_selection = g_eeprom.BK4819_xtal_freq_low;
|
||||
g_sub_menu_selection = g_eeprom.config.setting.BK4819_xtal_freq_low;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_BAT_CAL:
|
||||
g_sub_menu_selection = g_battery_calibration[3];
|
||||
g_sub_menu_selection = g_eeprom.calib.battery[3];
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1599,9 +1594,9 @@ static void MENU_Key_EXIT(bool key_pressed, bool key_held)
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
|
||||
if (g_eeprom.backlight == 0)
|
||||
if (g_eeprom.config.setting.backlight_time == 0)
|
||||
{
|
||||
g_backlight_count_down = 0;
|
||||
g_backlight_tick_500ms = 0;
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||
}
|
||||
}
|
||||
@ -1659,7 +1654,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0))
|
||||
return;
|
||||
|
||||
BOARD_fetchChannelName(g_edit, g_sub_menu_selection);
|
||||
SETTINGS_fetch_channel_name(g_edit, g_sub_menu_selection);
|
||||
|
||||
// pad the channel name out with '_'
|
||||
g_edit_index = strlen(g_edit);
|
||||
@ -1877,9 +1872,9 @@ static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
|
||||
|
||||
g_request_display_screen = DISPLAY_MENU;
|
||||
|
||||
if (g_menu_cursor != MENU_AUTO_BACKLITE && g_eeprom.backlight == 0)
|
||||
if (g_menu_cursor != MENU_AUTO_BACKLITE && g_eeprom.config.setting.backlight_time == 0)
|
||||
{
|
||||
g_backlight_count_down = 0;
|
||||
g_backlight_tick_500ms = 0;
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||
}
|
||||
|
||||
|
12
app/search.c
12
app/search.c
@ -112,7 +112,7 @@ static void SEARCH_Key_EXIT(bool key_pressed, bool key_held)
|
||||
switch (g_search_edit_state)
|
||||
{
|
||||
case SEARCH_EDIT_STATE_NONE:
|
||||
g_eeprom.cross_vfo_rx_tx = g_backup_cross_vfo_rx_tx;
|
||||
g_eeprom.config.setting.cross_vfo = g_backup_cross_vfo;
|
||||
g_update_status = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_flag_reset_vfos = true;
|
||||
@ -184,7 +184,7 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
|
||||
// determine what the current step size is for the detected frequency
|
||||
// use the 7 VFO channels/bands to determine it
|
||||
const unsigned int band = (unsigned int)FREQUENCY_GetBand(g_search_frequency);
|
||||
g_search_step_setting = BOARD_fetchFrequencyStepSetting(band, g_eeprom.tx_vfo);
|
||||
g_search_step_setting = SETTINGS_fetch_frequency_step_setting(band, g_eeprom.config.setting.tx_vfo_num);
|
||||
{ // round to nearest step size
|
||||
const uint16_t step_size = STEP_FREQ_TABLE[g_search_step_setting];
|
||||
g_search_frequency = ((g_search_frequency + (step_size / 2)) / step_size) * step_size;
|
||||
@ -268,16 +268,16 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
|
||||
if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST)
|
||||
{
|
||||
Channel = g_search_channel;
|
||||
g_eeprom.user_channel[g_eeprom.tx_vfo] = Channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user = Channel;
|
||||
}
|
||||
else
|
||||
{
|
||||
Channel = FREQ_CHANNEL_FIRST + g_tx_vfo->band;
|
||||
g_eeprom.freq_channel[g_eeprom.tx_vfo] = Channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].frequency = Channel;
|
||||
}
|
||||
|
||||
g_tx_vfo->channel_save = Channel;
|
||||
g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel;
|
||||
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen = Channel;
|
||||
g_request_save_channel = 2;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
@ -619,7 +619,7 @@ void SEARCH_Start(void)
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
g_is_noaa_mode = false;
|
||||
g_noaa_mode = false;
|
||||
#endif
|
||||
|
||||
if (g_search_single_frequency)
|
||||
|
39
app/uart.c
39
app/uart.c
@ -210,7 +210,7 @@ static void SendVersion(void)
|
||||
reply.Header.ID = 0x0515;
|
||||
reply.Header.Size = sizeof(reply.Data);
|
||||
memcpy(reply.Data.Version, Version_str, slen);
|
||||
reply.Data.has_custom_aes_key = g_has_custom_aes_key;
|
||||
reply.Data.has_custom_aes_key = g_has_aes_key;
|
||||
reply.Data.password_locked = g_password_locked;
|
||||
reply.Data.Challenge[0] = g_challenge[0];
|
||||
reply.Data.Challenge[1] = g_challenge[1];
|
||||
@ -285,11 +285,12 @@ static void cmd_051B(const uint8_t *pBuffer)
|
||||
reply.Data.Offset = addr;
|
||||
reply.Data.Size = size;
|
||||
|
||||
// if (g_has_custom_aes_key)
|
||||
// if (g_has_aes_key)
|
||||
// locked = is_locked;
|
||||
|
||||
// if (!locked)
|
||||
EEPROM_ReadBuffer(addr, reply.Data.Data, size);
|
||||
// EEPROM_ReadBuffer(addr, reply.Data.Data, size);
|
||||
memcpy(reply.Data.Data, ((uint8_t *)&g_eeprom) + addr, size);
|
||||
|
||||
SendReply(&reply, size + 8);
|
||||
}
|
||||
@ -303,7 +304,7 @@ static void cmd_051D(const uint8_t *pBuffer)
|
||||
unsigned int size = pCmd->Size;
|
||||
#ifdef INCLUDE_AES
|
||||
bool reload_eeprom = false;
|
||||
bool locked = g_has_custom_aes_key ? is_locked : g_has_custom_aes_key;
|
||||
bool locked = g_has_aes_key ? is_locked : g_has_aes_key;
|
||||
#endif
|
||||
reply_051D_t reply;
|
||||
|
||||
@ -369,7 +370,7 @@ static void cmd_051D(const uint8_t *pBuffer)
|
||||
|
||||
#ifdef INCLUDE_AES
|
||||
if (reload_eeprom)
|
||||
BOARD_eeprom_load();
|
||||
SETTINGS_read_eeprom();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -412,7 +413,7 @@ static void cmd_0529(void)
|
||||
static void cmd_052D(const uint8_t *pBuffer)
|
||||
{
|
||||
cmd_052D_t *pCmd = (cmd_052D_t *)pBuffer;
|
||||
bool locked = g_has_custom_aes_key;
|
||||
bool locked = g_has_aes_key;
|
||||
uint32_t response[4];
|
||||
reply_052D_t reply;
|
||||
|
||||
@ -420,8 +421,10 @@ static void cmd_052D(const uint8_t *pBuffer)
|
||||
|
||||
if (!locked)
|
||||
{
|
||||
uint32_t aes_key[4];
|
||||
memcpy((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings
|
||||
locked = IsBadChallenge(g_custom_aes_key, g_challenge, response);
|
||||
memcpy(aes_key, g_eeprom.config.setting.aes_key, sizeof(aes_key));
|
||||
locked = IsBadChallenge(aes_key, g_challenge, response);
|
||||
}
|
||||
|
||||
if (!locked)
|
||||
@ -459,21 +462,21 @@ static void cmd_052F(const uint8_t *pBuffer)
|
||||
{
|
||||
const cmd_052F_t *pCmd = (const cmd_052F_t *)pBuffer;
|
||||
|
||||
g_eeprom.dual_watch = DUAL_WATCH_OFF;
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
|
||||
g_eeprom.rx_vfo = 0;
|
||||
g_eeprom.dtmf_side_tone = false;
|
||||
g_eeprom.vfo_info[0].frequency_reverse = false;
|
||||
g_eeprom.vfo_info[0].p_rx = &g_eeprom.vfo_info[0].freq_config_rx;
|
||||
g_eeprom.vfo_info[0].p_tx = &g_eeprom.vfo_info[0].freq_config_tx;
|
||||
g_eeprom.vfo_info[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF;
|
||||
g_eeprom.vfo_info[0].dtmf_ptt_id_tx_mode = PTT_ID_OFF;
|
||||
g_eeprom.vfo_info[0].dtmf_decoding_enable = false;
|
||||
g_rx_vfo = 0;
|
||||
g_eeprom.config.setting.dual_watch = DUAL_WATCH_OFF;
|
||||
g_eeprom.config.setting.cross_vfo = CROSS_BAND_OFF;
|
||||
g_eeprom.config.setting.dtmf.side_tone = false;
|
||||
g_vfo_info[0].frequency_reverse = false;
|
||||
g_vfo_info[0].p_rx = &g_vfo_info[0].freq_config_rx;
|
||||
g_vfo_info[0].p_tx = &g_vfo_info[0].freq_config_tx;
|
||||
g_vfo_info[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF;
|
||||
g_vfo_info[0].dtmf_ptt_id_tx_mode = PTT_ID_OFF;
|
||||
g_vfo_info[0].dtmf_decoding_enable = false;
|
||||
|
||||
g_serial_config_tick_500ms = serial_config_tick_500ms;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
g_is_noaa_mode = false;
|
||||
g_noaa_mode = false;
|
||||
#endif
|
||||
|
||||
if (g_current_function == FUNCTION_POWER_SAVE)
|
||||
|
Reference in New Issue
Block a user