0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-19 00:11:18 +03:00

fix missing display details

This commit is contained in:
OneOfEleven 2023-11-02 21:44:53 +00:00
parent 3681674b09
commit 98a4cd9483
20 changed files with 401 additions and 444 deletions

View File

@ -76,11 +76,11 @@ static void ACTION_FlashLight(void)
void ACTION_Power(void) void ACTION_Power(void)
{ {
if (++g_tx_vfo->output_power > OUTPUT_POWER_HIGH) if (++g_tx_vfo->channel.tx_power > OUTPUT_POWER_HIGH)
g_tx_vfo->output_power = OUTPUT_POWER_LOW; g_tx_vfo->channel.tx_power = OUTPUT_POWER_LOW;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("act_pwr %u\r\n", g_tx_vfo->output_power); // UART_printf("act_pwr %u\r\n", g_tx_vfo->channel.tx_power);
#endif #endif
g_request_save_channel = 1; g_request_save_channel = 1;

View File

@ -83,7 +83,7 @@ static void APP_update_rssi(const int vfo)
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// add RF gain adjust compensation // add RF gain adjust compensation
if (g_current_vfo->am_mode > 0 && g_eeprom.config.setting.am_fix) if (g_current_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix)
rssi -= rssi_gain_diff[vfo]; rssi -= rssi_gain_diff[vfo];
#endif #endif
@ -214,9 +214,9 @@ static void APP_process_new_receive(void)
{ // not code scanning { // not code scanning
#ifdef ENABLE_KILL_REVIVE #ifdef ENABLE_KILL_REVIVE
if (g_rx_vfo->dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled) if (g_rx_vfo->channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
#else #else
if (g_rx_vfo->dtmf_decoding_enable) if (g_rx_vfo->channel.dtmf_decoding_enable)
#endif #endif
{ // DTMF DCD is enabled { // DTMF DCD is enabled
@ -520,7 +520,7 @@ bool APP_start_listening(void)
} }
// AF gain - original QS values // AF gain - original QS values
// if (g_rx_vfo->am_mode > 0) // if (g_rx_vfo->channel.am_mode > 0)
// { // {
// BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000 // BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000
// } // }
@ -540,12 +540,12 @@ bool APP_start_listening(void)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
#ifdef MUTE_AUDIO_FOR_VOICE #ifdef MUTE_AUDIO_FOR_VOICE
if (g_voice_write_index == 0) if (g_voice_write_index == 0)
AUDIO_set_mod_mode(g_rx_vfo->am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#else #else
AUDIO_set_mod_mode(g_rx_vfo->am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif #endif
#else #else
AUDIO_set_mod_mode(g_rx_vfo->am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif #endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -568,7 +568,7 @@ uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step)
if (pInfo->step_freq == 833) if (pInfo->step_freq == 833)
{ {
const uint32_t Lower = FREQ_BAND_TABLE[pInfo->band].lower; const uint32_t Lower = FREQ_BAND_TABLE[pInfo->channel_attributes.band].lower;
const uint32_t Delta = Frequency - Lower; const uint32_t Delta = Frequency - Lower;
uint32_t Base = (Delta / 2500) * 2500; uint32_t Base = (Delta / 2500) * 2500;
const uint32_t Index = ((Delta - Base) % 2500) / 833; const uint32_t Index = ((Delta - Base) % 2500) / 833;
@ -579,12 +579,12 @@ uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step)
Frequency = Lower + Base + (Index * 833); Frequency = Lower + Base + (Index * 833);
} }
// if (Frequency >= FREQ_BAND_TABLE[pInfo->band].upper) // if (Frequency >= FREQ_BAND_TABLE[pInfo->channel_attributes.band].upper)
// Frequency = FREQ_BAND_TABLE[pInfo->band].lower; // Frequency = FREQ_BAND_TABLE[pInfo->channel_attributes.band].lower;
// else // else
// if (Frequency < FREQ_BAND_TABLE[pInfo->band].lower) // if (Frequency < FREQ_BAND_TABLE[pInfo->channel_attributes.band].lower)
// Frequency = FREQUENCY_floor_to_step(FREQ_BAND_TABLE[pInfo->band].upper, pInfo->step_freq, FREQ_BAND_TABLE[pInfo->band].lower); // Frequency = FREQUENCY_floor_to_step(FREQ_BAND_TABLE[pInfo->channel_attributes.band].upper, pInfo->step_freq, FREQ_BAND_TABLE[pInfo->channel_attributes.band].lower);
Frequency = FREQUENCY_wrap_to_step_band(Frequency, pInfo->step_freq, pInfo->band); Frequency = FREQUENCY_wrap_to_step_band(Frequency, pInfo->step_freq, pInfo->channel_attributes.band);
return Frequency; return Frequency;
} }
@ -940,9 +940,9 @@ void APP_process_radio_interrupts(void)
} }
#ifdef ENABLE_KILL_REVIVE #ifdef ENABLE_KILL_REVIVE
if (g_rx_vfo->dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled) if (g_rx_vfo->channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
#else #else
if (g_rx_vfo->dtmf_decoding_enable) if (g_rx_vfo->channel.dtmf_decoding_enable)
#endif #endif
{ {
if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1)) if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1))
@ -2321,7 +2321,7 @@ void APP_time_slice_10ms(void)
#endif #endif
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (g_rx_vfo->am_mode > 0 && g_eeprom.config.setting.am_fix) if (g_rx_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix)
AM_fix_10ms(g_rx_vfo_num); AM_fix_10ms(g_rx_vfo_num);
#endif #endif
@ -2686,10 +2686,10 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
BK4819_ExitDTMF_TX(false); BK4819_ExitDTMF_TX(false);
if (g_current_vfo->scrambling_type == 0 || !g_eeprom.config.setting.enable_scrambler) if (g_current_vfo->channel.scrambler == 0 || !g_eeprom.config.setting.enable_scrambler)
BK4819_DisableScramble(); BK4819_DisableScramble();
else else
BK4819_EnableScramble(g_current_vfo->scrambling_type - 1); BK4819_EnableScramble(g_current_vfo->channel.scrambler - 1);
} }
} }
else else

View File

@ -27,6 +27,7 @@
#include "dtmf.h" #include "dtmf.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "misc.h" #include "misc.h"
#include "radio.h"
#include "settings.h" #include "settings.h"
#include "ui/ui.h" #include "ui/ui.h"
@ -214,9 +215,9 @@ void DTMF_HandleRequest(void)
} }
#ifdef ENABLE_KILL_REVIVE #ifdef ENABLE_KILL_REVIVE
if (!g_rx_vfo->dtmf_decoding_enable && !g_eeprom.config.setting.radio_disabled) if (!g_rx_vfo->channel.dtmf_decoding_enable && !g_eeprom.config.setting.radio_disabled)
#else #else
if (!g_rx_vfo->dtmf_decoding_enable) if (!g_rx_vfo->channel.dtmf_decoding_enable)
#endif #endif
{ // D-DCD is disabled or we're enabled { // D-DCD is disabled or we're enabled
DTMF_clear_RX(); DTMF_clear_RX();
@ -417,9 +418,9 @@ bool DTMF_Reply(void)
default: default:
case DTMF_REPLY_NONE: case DTMF_REPLY_NONE:
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE || if (g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO || g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO ||
g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_OFF || g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_OFF ||
g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN) g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN)
{ {
g_dtmf_reply_state = DTMF_REPLY_NONE; g_dtmf_reply_state = DTMF_REPLY_NONE;
return false; return false;

View File

@ -219,7 +219,7 @@ void GENERIC_Key_PTT(bool key_pressed)
#else #else
// append our DTMF ID to the inputted DTMF code - // append our DTMF ID to the inputted DTMF code -
// IF the user inputted code is exactly 3 digits long and D-DCD is enabled // IF the user inputted code is exactly 3 digits long and D-DCD is enabled
if (g_dtmf_input_box_index == 3 && g_tx_vfo->dtmf_decoding_enable > 0) if (g_dtmf_input_box_index == 3 && g_tx_vfo->channel.dtmf_decoding_enable > 0)
g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3); g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3);
else else
g_dtmf_call_mode = DTMF_CALL_MODE_DTMF; g_dtmf_call_mode = DTMF_CALL_MODE_DTMF;

View File

@ -80,19 +80,19 @@ void toggle_chan_scanlist(void)
return; return;
} }
if (g_tx_vfo->scanlist_1_participation) if (g_tx_vfo->channel_attributes.scanlist1)
{ {
if (g_tx_vfo->scanlist_2_participation) if (g_tx_vfo->channel_attributes.scanlist2)
g_tx_vfo->scanlist_1_participation = 0; g_tx_vfo->channel_attributes.scanlist1 = 0;
else else
g_tx_vfo->scanlist_2_participation = 1; g_tx_vfo->channel_attributes.scanlist2 = 1;
} }
else else
{ {
if (g_tx_vfo->scanlist_2_participation) if (g_tx_vfo->channel_attributes.scanlist2)
g_tx_vfo->scanlist_2_participation = 0; g_tx_vfo->channel_attributes.scanlist2 = 0;
else else
g_tx_vfo->scanlist_1_participation = 1; g_tx_vfo->channel_attributes.scanlist1 = 1;
} }
SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo); SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo);
@ -122,7 +122,7 @@ void toggle_chan_scanlist(void)
if (IS_USER_CHANNEL(g_eeprom.config.setting.indices.vfo[vfo].screen)) if (IS_USER_CHANNEL(g_eeprom.config.setting.indices.vfo[vfo].screen))
{ // copy channel to VFO, then swap to the VFO { // copy channel to VFO, then swap to the VFO
const unsigned int channel = FREQ_CHANNEL_FIRST + g_vfo_info[vfo].band; const unsigned int channel = FREQ_CHANNEL_FIRST + g_vfo_info[vfo].channel_attributes.band;
g_eeprom.config.setting.indices.vfo[vfo].screen = channel; g_eeprom.config.setting.indices.vfo[vfo].screen = channel;
g_vfo_info[vfo].channel_save = channel; g_vfo_info[vfo].channel_save = channel;
@ -210,10 +210,10 @@ void processFKeyFunction(const key_code_t Key)
if (g_fkey_pressed) if (g_fkey_pressed)
{ {
#if 0 #if 0
g_tx_vfo->am_mode = (g_tx_vfo->am_mode + 1) & 1u; g_tx_vfo->channel.am_mode = (g_tx_vfo->am_mode + 1) & 1u;
#else #else
if (++g_tx_vfo->am_mode >= 3) if (++g_tx_vfo->channel.am_mode >= 3)
g_tx_vfo->am_mode = 0; g_tx_vfo->channel.am_mode = 0;
#endif #endif
g_request_save_channel = 1; g_request_save_channel = 1;
} }
@ -242,7 +242,7 @@ void processFKeyFunction(const key_code_t Key)
APP_stop_scan(); APP_stop_scan();
Band = g_tx_vfo->band + 1; Band = g_tx_vfo->channel_attributes.band + 1;
if (g_eeprom.config.setting.enable_350 || Band != BAND5_350MHz) if (g_eeprom.config.setting.enable_350 || Band != BAND5_350MHz)
{ {
if (Band > BAND7_470MHz) if (Band > BAND7_470MHz)
@ -250,7 +250,7 @@ void processFKeyFunction(const key_code_t Key)
} }
else else
Band = BAND6_400MHz; // jump to next band Band = BAND6_400MHz; // jump to next band
g_tx_vfo->band = Band; g_tx_vfo->channel_attributes.band = Band;
g_eeprom.config.setting.indices.vfo[vfo].screen = 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_eeprom.config.setting.indices.vfo[vfo].frequency = FREQ_CHANNEL_FIRST + Band;
@ -397,7 +397,7 @@ void processFKeyFunction(const key_code_t Key)
return; return;
} }
g_tx_vfo->frequency_reverse = g_tx_vfo->frequency_reverse == false; g_tx_vfo->channel.frequency_reverse = g_tx_vfo->channel.frequency_reverse == false;
g_request_save_channel = 1; g_request_save_channel = 1;
break; break;
@ -566,9 +566,9 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
if (g_tx_vfo->band != band) if (g_tx_vfo->channel_attributes.band != band)
{ {
g_tx_vfo->band = band; g_tx_vfo->channel_attributes.band = band;
g_eeprom.config.setting.indices.vfo[vfo].screen = band + FREQ_CHANNEL_FIRST; g_eeprom.config.setting.indices.vfo[vfo].screen = band + FREQ_CHANNEL_FIRST;
g_eeprom.config.setting.indices.vfo[vfo].frequency = band + FREQ_CHANNEL_FIRST; g_eeprom.config.setting.indices.vfo[vfo].frequency = band + FREQ_CHANNEL_FIRST;
@ -578,7 +578,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
} }
Frequency += g_tx_vfo->step_freq / 2; // for rounding to nearest step size Frequency += g_tx_vfo->step_freq / 2; // for rounding to nearest step size
Frequency = FREQUENCY_floor_to_step(Frequency, g_tx_vfo->step_freq, FREQ_BAND_TABLE[g_tx_vfo->band].lower, FREQ_BAND_TABLE[g_tx_vfo->band].upper); Frequency = FREQUENCY_floor_to_step(Frequency, g_tx_vfo->step_freq, FREQ_BAND_TABLE[g_tx_vfo->channel_attributes.band].lower, FREQ_BAND_TABLE[g_tx_vfo->channel_attributes.band].upper);
if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower) if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower)
{ // clamp the frequency to the limit { // clamp the frequency to the limit

View File

@ -43,6 +43,8 @@
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/menu.h" #include "ui/menu.h"
#include "ui/menu.h" #include "ui/menu.h"
#include "radio.h"
#include "settings.h"
#include "ui/ui.h" #include "ui/ui.h"
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
@ -411,19 +413,19 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_CHAN_SQL: case MENU_CHAN_SQL:
g_tx_vfo->squelch_level = g_sub_menu_selection; g_tx_vfo->channel.squelch_level = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
g_vfo_configure_mode = VFO_CONFIGURE; g_vfo_configure_mode = VFO_CONFIGURE;
return; return;
case MENU_STEP: case MENU_STEP:
g_tx_vfo->step_setting = step_freq_table_sorted[g_sub_menu_selection]; g_tx_vfo->channel.step_setting = step_freq_table_sorted[g_sub_menu_selection];
g_request_save_channel = 1; g_request_save_channel = 1;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
return; return;
case MENU_TX_POWER: case MENU_TX_POWER:
g_tx_vfo->output_power = g_sub_menu_selection; g_tx_vfo->channel.tx_power = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
return; return;
@ -492,22 +494,22 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_SHIFT_DIR: case MENU_SHIFT_DIR:
g_tx_vfo->tx_offset_freq_dir = g_sub_menu_selection; g_tx_vfo->channel.tx_offset_dir = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
return; return;
case MENU_OFFSET: case MENU_OFFSET:
g_tx_vfo->tx_offset_freq = g_sub_menu_selection; g_tx_vfo->channel.tx_offset = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
return; return;
case MENU_BANDWIDTH: case MENU_BANDWIDTH:
g_tx_vfo->channel_bandwidth = g_sub_menu_selection; g_tx_vfo->channel.channel_bandwidth = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
return; return;
case MENU_SCRAMBLER: case MENU_SCRAMBLER:
g_tx_vfo->scrambling_type = g_sub_menu_selection; g_tx_vfo->channel.scrambler = g_sub_menu_selection;
#if 0 #if 0
if (g_sub_menu_selection > 0 && g_eeprom.config.setting.enable_scrambler) if (g_sub_menu_selection > 0 && g_eeprom.config.setting.enable_scrambler)
BK4819_EnableScramble(g_sub_menu_selection - 1); BK4819_EnableScramble(g_sub_menu_selection - 1);
@ -518,7 +520,7 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_BUSY_CHAN_LOCK: case MENU_BUSY_CHAN_LOCK:
g_tx_vfo->busy_channel_lock = g_sub_menu_selection; g_tx_vfo->channel.busy_channel_lock = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
return; return;
@ -545,8 +547,8 @@ void MENU_AcceptSetting(void)
} }
// save the channel name // save the channel name
memset(g_tx_vfo->name, 0, sizeof(g_tx_vfo->name)); memset(g_tx_vfo->channel_name, 0, sizeof(g_tx_vfo->channel_name));
memcpy(g_tx_vfo->name, g_edit, 10); memcpy(g_tx_vfo->channel_name, g_edit, 10);
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.config.setting.tx_vfo_num, 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; g_flag_reconfigure_vfos = true;
return; return;
@ -634,14 +636,14 @@ void MENU_AcceptSetting(void)
#endif #endif
case MENU_S_ADD1: case MENU_S_ADD1:
g_tx_vfo->scanlist_1_participation = g_sub_menu_selection; g_tx_vfo->channel_attributes.scanlist1 = g_sub_menu_selection;
SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo); SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo);
g_vfo_configure_mode = VFO_CONFIGURE; g_vfo_configure_mode = VFO_CONFIGURE;
g_flag_reset_vfos = true; g_flag_reset_vfos = true;
return; return;
case MENU_S_ADD2: case MENU_S_ADD2:
g_tx_vfo->scanlist_2_participation = g_sub_menu_selection; g_tx_vfo->channel_attributes.scanlist2 = g_sub_menu_selection;
SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo); SETTINGS_save_chan_attribs_name(g_tx_vfo->channel_save, g_tx_vfo);
g_vfo_configure_mode = VFO_CONFIGURE; g_vfo_configure_mode = VFO_CONFIGURE;
g_flag_reset_vfos = true; g_flag_reset_vfos = true;
@ -675,7 +677,7 @@ void MENU_AcceptSetting(void)
#endif #endif
case MENU_COMPAND: case MENU_COMPAND:
g_tx_vfo->compand = g_sub_menu_selection; g_tx_vfo->channel.compand = g_sub_menu_selection;
#if 1 #if 1
g_request_save_channel = 1; g_request_save_channel = 1;
#else #else
@ -716,7 +718,7 @@ void MENU_AcceptSetting(void)
#ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200
case MENU_MDC1200_MODE: case MENU_MDC1200_MODE:
g_tx_vfo->mdc1200_mode = g_sub_menu_selection; g_tx_vfo->channel.mdc1200_mode = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
break; break;
@ -726,10 +728,10 @@ void MENU_AcceptSetting(void)
#endif #endif
case MENU_PTT_ID: case MENU_PTT_ID:
g_tx_vfo->dtmf_ptt_id_tx_mode = g_sub_menu_selection; g_tx_vfo->channel.dtmf_ptt_id_tx_mode = g_sub_menu_selection;
if (g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN || if (g_tx_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH || g_tx_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_BOTH ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO) g_tx_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{ {
g_eeprom.config.setting.roger_mode = ROGER_MODE_OFF; g_eeprom.config.setting.roger_mode = ROGER_MODE_OFF;
break; break;
@ -742,7 +744,7 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_DTMF_DCD: case MENU_DTMF_DCD:
g_tx_vfo->dtmf_decoding_enable = g_sub_menu_selection; g_tx_vfo->channel.dtmf_decoding_enable = g_sub_menu_selection;
DTMF_clear_RX(); DTMF_clear_RX();
g_request_save_channel = 1; g_request_save_channel = 1;
return; return;
@ -777,18 +779,18 @@ void MENU_AcceptSetting(void)
g_eeprom.config.setting.roger_mode = g_sub_menu_selection; g_eeprom.config.setting.roger_mode = g_sub_menu_selection;
if (g_eeprom.config.setting.roger_mode != ROGER_MODE_OFF) if (g_eeprom.config.setting.roger_mode != ROGER_MODE_OFF)
{ {
if (g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN || if (g_tx_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH || g_tx_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_BOTH ||
g_tx_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO) g_tx_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{ {
g_tx_vfo->dtmf_ptt_id_tx_mode = PTT_ID_OFF; // // disable PTT ID tail g_tx_vfo->channel.dtmf_ptt_id_tx_mode = PTT_ID_OFF; // // disable PTT ID tail
g_request_save_channel = 1; g_request_save_channel = 1;
} }
} }
break; break;
case MENU_MOD_MODE: case MENU_MOD_MODE:
g_tx_vfo->am_mode = g_sub_menu_selection; g_tx_vfo->channel.am_mode = g_sub_menu_selection;
g_request_save_channel = 1; g_request_save_channel = 1;
return; return;
/* /*
@ -965,15 +967,15 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_CHAN_SQL: case MENU_CHAN_SQL:
g_sub_menu_selection = g_tx_vfo->squelch_level; g_sub_menu_selection = g_tx_vfo->channel.squelch_level;
break; break;
case MENU_STEP: case MENU_STEP:
g_sub_menu_selection = FREQUENCY_get_step_index(STEP_FREQ_TABLE[g_tx_vfo->step_setting]); g_sub_menu_selection = FREQUENCY_get_step_index(STEP_FREQ_TABLE[g_tx_vfo->channel.step_setting]);
break; break;
case MENU_TX_POWER: case MENU_TX_POWER:
g_sub_menu_selection = g_tx_vfo->output_power; g_sub_menu_selection = g_tx_vfo->channel.tx_power;
break; break;
case MENU_RX_CDCSS: case MENU_RX_CDCSS:
@ -1019,23 +1021,23 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_SHIFT_DIR: case MENU_SHIFT_DIR:
g_sub_menu_selection = g_tx_vfo->tx_offset_freq_dir; g_sub_menu_selection = g_tx_vfo->channel.tx_offset_dir;
break; break;
case MENU_OFFSET: case MENU_OFFSET:
g_sub_menu_selection = g_tx_vfo->tx_offset_freq; g_sub_menu_selection = g_tx_vfo->channel.tx_offset;
break; break;
case MENU_BANDWIDTH: case MENU_BANDWIDTH:
g_sub_menu_selection = g_tx_vfo->channel_bandwidth; g_sub_menu_selection = g_tx_vfo->channel.channel_bandwidth;
break; break;
case MENU_SCRAMBLER: case MENU_SCRAMBLER:
g_sub_menu_selection = g_tx_vfo->scrambling_type; g_sub_menu_selection = g_tx_vfo->channel.scrambler;
break; break;
case MENU_BUSY_CHAN_LOCK: case MENU_BUSY_CHAN_LOCK:
g_sub_menu_selection = g_tx_vfo->busy_channel_lock; g_sub_menu_selection = g_tx_vfo->channel.busy_channel_lock;
break; break;
case MENU_MEM_SAVE: case MENU_MEM_SAVE:
@ -1119,11 +1121,11 @@ void MENU_ShowCurrentSetting(void)
#endif #endif
case MENU_S_ADD1: case MENU_S_ADD1:
g_sub_menu_selection = g_tx_vfo->scanlist_1_participation; g_sub_menu_selection = g_tx_vfo->channel_attributes.scanlist1;
break; break;
case MENU_S_ADD2: case MENU_S_ADD2:
g_sub_menu_selection = g_tx_vfo->scanlist_2_participation; g_sub_menu_selection = g_tx_vfo->channel_attributes.scanlist2;
break; break;
case MENU_STE: case MENU_STE:
@ -1151,7 +1153,7 @@ void MENU_ShowCurrentSetting(void)
#endif #endif
case MENU_COMPAND: case MENU_COMPAND:
g_sub_menu_selection = g_tx_vfo->compand; g_sub_menu_selection = g_tx_vfo->channel.compand;
return; return;
case MENU_1_CALL: case MENU_1_CALL:
@ -1218,7 +1220,7 @@ void MENU_ShowCurrentSetting(void)
#ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200
case MENU_MDC1200_MODE: case MENU_MDC1200_MODE:
g_sub_menu_selection = g_tx_vfo->mdc1200_mode; g_sub_menu_selection = g_tx_vfo->channel.mdc1200_mode;
break; break;
case MENU_MDC1200_ID: case MENU_MDC1200_ID:
@ -1227,7 +1229,7 @@ void MENU_ShowCurrentSetting(void)
#endif #endif
case MENU_PTT_ID: case MENU_PTT_ID:
g_sub_menu_selection = g_tx_vfo->dtmf_ptt_id_tx_mode; g_sub_menu_selection = g_tx_vfo->channel.dtmf_ptt_id_tx_mode;
break; break;
case MENU_BAT_TXT: case MENU_BAT_TXT:
@ -1235,7 +1237,7 @@ void MENU_ShowCurrentSetting(void)
return; return;
case MENU_DTMF_DCD: case MENU_DTMF_DCD:
g_sub_menu_selection = g_tx_vfo->dtmf_decoding_enable; g_sub_menu_selection = g_tx_vfo->channel.dtmf_decoding_enable;
break; break;
case MENU_DTMF_LIST: case MENU_DTMF_LIST:
@ -1255,7 +1257,7 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_MOD_MODE: case MENU_MOD_MODE:
g_sub_menu_selection = g_tx_vfo->am_mode; g_sub_menu_selection = g_tx_vfo->channel.am_mode;
break; break;
/* /*
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
@ -1782,7 +1784,7 @@ static void MENU_Key_STAR(const bool key_pressed, const bool key_held)
RADIO_select_vfos(); RADIO_select_vfos();
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_rx_vfo->am_mode == 0) if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_rx_vfo->channel.am_mode == 0)
{ {
if (g_menu_cursor == MENU_RX_CTCSS || g_menu_cursor == MENU_RX_CDCSS) if (g_menu_cursor == MENU_RX_CTCSS || g_menu_cursor == MENU_RX_CDCSS)
{ // scan CTCSS or DCS to find the tone/code of the incoming signal { // scan CTCSS or DCS to find the tone/code of the incoming signal

View File

@ -251,7 +251,7 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
} }
g_tx_vfo->freq_config_tx = g_tx_vfo->freq_config_rx; g_tx_vfo->freq_config_tx = g_tx_vfo->freq_config_rx;
g_tx_vfo->step_setting = g_search_step_setting; g_tx_vfo->channel.step_setting = g_search_step_setting;
} }
else else
{ {
@ -272,7 +272,7 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
} }
else else
{ {
Channel = FREQ_CHANNEL_FIRST + g_tx_vfo->band; Channel = FREQ_CHANNEL_FIRST + g_tx_vfo->channel_attributes.band;
g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].frequency = Channel; g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].frequency = Channel;
} }
@ -605,12 +605,12 @@ void SEARCH_Start(void)
g_rx_vfo->channel_save = FREQ_CHANNEL_FIRST + BAND6_400MHz; g_rx_vfo->channel_save = FREQ_CHANNEL_FIRST + BAND6_400MHz;
#endif #endif
BackupStep = g_rx_vfo->step_setting; BackupStep = g_rx_vfo->channel.step_setting;
BackupStepFreq = g_rx_vfo->step_freq; BackupStepFreq = g_rx_vfo->step_freq;
RADIO_InitInfo(g_rx_vfo, g_rx_vfo->channel_save, g_rx_vfo->p_rx->frequency); RADIO_InitInfo(g_rx_vfo, g_rx_vfo->channel_save, g_rx_vfo->p_rx->frequency);
g_rx_vfo->step_setting = BackupStep; g_rx_vfo->channel.step_setting = BackupStep;
g_rx_vfo->step_freq = BackupStepFreq; g_rx_vfo->step_freq = BackupStepFreq;
g_monitor_enabled = false; g_monitor_enabled = false;
@ -626,7 +626,7 @@ void SEARCH_Start(void)
{ {
g_search_css_state = SEARCH_CSS_STATE_SCANNING; g_search_css_state = SEARCH_CSS_STATE_SCANNING;
g_search_frequency = g_rx_vfo->p_rx->frequency; g_search_frequency = g_rx_vfo->p_rx->frequency;
g_search_step_setting = g_rx_vfo->step_setting; g_search_step_setting = g_rx_vfo->channel.step_setting;
BK4819_set_rf_filter_path(g_search_frequency); BK4819_set_rf_filter_path(g_search_frequency);

View File

@ -36,6 +36,7 @@
#endif #endif
#include "functions.h" #include "functions.h"
#include "misc.h" #include "misc.h"
#include "radio.h"
#include "settings.h" #include "settings.h"
#if defined(ENABLE_OVERLAY) #if defined(ENABLE_OVERLAY)
#include "sram-overlay.h" #include "sram-overlay.h"
@ -462,16 +463,16 @@ static void cmd_052F(const uint8_t *pBuffer)
{ {
const cmd_052F_t *pCmd = (const cmd_052F_t *)pBuffer; const cmd_052F_t *pCmd = (const cmd_052F_t *)pBuffer;
g_rx_vfo = 0; g_rx_vfo_num = 0;
g_eeprom.config.setting.dual_watch = DUAL_WATCH_OFF; g_eeprom.config.setting.dual_watch = DUAL_WATCH_OFF;
g_eeprom.config.setting.cross_vfo = CROSS_BAND_OFF; g_eeprom.config.setting.cross_vfo = CROSS_BAND_OFF;
g_eeprom.config.setting.dtmf.side_tone = false; g_eeprom.config.setting.dtmf.side_tone = false;
g_vfo_info[0].frequency_reverse = false; g_vfo_info[0].channel.frequency_reverse = false;
g_vfo_info[0].p_rx = &g_vfo_info[0].freq_config_rx; 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].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].channel.tx_offset_dir = TX_OFFSET_FREQ_DIR_OFF;
g_vfo_info[0].dtmf_ptt_id_tx_mode = PTT_ID_OFF; g_vfo_info[0].channel.dtmf_ptt_id_tx_mode = PTT_ID_OFF;
g_vfo_info[0].dtmf_decoding_enable = false; g_vfo_info[0].channel.dtmf_decoding_enable = false;
g_serial_config_tick_500ms = serial_config_tick_500ms; g_serial_config_tick_500ms = serial_config_tick_500ms;

Binary file not shown.

Binary file not shown.

View File

@ -50,7 +50,7 @@ void FUNCTION_Init(void)
{ {
g_current_code_type = g_selected_code_type; g_current_code_type = g_selected_code_type;
if (g_css_scan_mode == CSS_SCAN_MODE_OFF) if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
g_current_code_type = (g_rx_vfo->am_mode > 0) ? CODE_TYPE_NONE : g_rx_vfo->p_rx->code_type; g_current_code_type = (g_rx_vfo->channel.am_mode > 0) ? CODE_TYPE_NONE : g_rx_vfo->p_rx->code_type;
} }
else else
g_current_code_type = CODE_TYPE_CONTINUOUS_TONE; g_current_code_type = CODE_TYPE_CONTINUOUS_TONE;
@ -233,7 +233,7 @@ void FUNCTION_Select(function_type_t Function)
} }
#endif #endif
if (g_current_vfo->scrambling_type == 0 || !g_eeprom.config.setting.enable_scrambler) if (g_current_vfo->channel.scrambler == 0 || !g_eeprom.config.setting.enable_scrambler)
BK4819_DisableScramble(); BK4819_DisableScramble();
RADIO_enableTX(false); RADIO_enableTX(false);
@ -283,7 +283,7 @@ void FUNCTION_Select(function_type_t Function)
} }
else else
#endif #endif
if (g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO) if (g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{ {
BK4819_PlayTone(APOLLO_TONE1_HZ, APOLLO_TONE_MS, 0); BK4819_PlayTone(APOLLO_TONE1_HZ, APOLLO_TONE_MS, 0);
} }
@ -301,9 +301,9 @@ void FUNCTION_Select(function_type_t Function)
(1u << 1) | // enable TX DSP (1u << 1) | // enable TX DSP
(0u << 0)); // disable RX DSP (0u << 0)); // disable RX DSP
*/ */
if (g_current_vfo->scrambling_type > 0 && g_eeprom.config.setting.enable_scrambler) if (g_current_vfo->channel.scrambler > 0 && g_eeprom.config.setting.enable_scrambler)
{ {
BK4819_EnableScramble(g_current_vfo->scrambling_type - 1); BK4819_EnableScramble(g_current_vfo->channel.scrambler - 1);
} }
break; break;

4
main.c
View File

@ -190,7 +190,7 @@ void Main(void)
g_unhide_hidden = (BootMode == BOOT_MODE_UNHIDE_HIDDEN); // flag to say include the hidden menu items g_unhide_hidden = (BootMode == BOOT_MODE_UNHIDE_HIDDEN); // flag to say include the hidden menu items
// load the entire EEPROM contents into memory // load the entire EEPROM contents into memory
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // backlight on // GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // backlight on
MAIN_DisplayReadingEEPROM(); MAIN_DisplayReadingEEPROM();
SETTINGS_read_eeprom(); SETTINGS_read_eeprom();
MAIN_DisplayClear(); MAIN_DisplayClear();
@ -227,9 +227,7 @@ void Main(void)
RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD); RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD);
RADIO_configure_channel(1, VFO_CONFIGURE_RELOAD); RADIO_configure_channel(1, VFO_CONFIGURE_RELOAD);
RADIO_select_vfos(); RADIO_select_vfos();
RADIO_setup_registers(true); RADIO_setup_registers(true);
for (i = 0; i < ARRAY_SIZE(g_battery_voltages); i++) for (i = 0; i < ARRAY_SIZE(g_battery_voltages); i++)

211
radio.c
View File

@ -30,6 +30,9 @@
#include "driver/eeprom.h" #include "driver/eeprom.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/system.h" #include "driver/system.h"
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h"
#endif
#include "frequencies.h" #include "frequencies.h"
#include "functions.h" #include "functions.h"
#include "helper/battery.h" #include "helper/battery.h"
@ -125,24 +128,24 @@ void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t
memset(p_vfo, 0, sizeof(*p_vfo)); memset(p_vfo, 0, sizeof(*p_vfo));
p_vfo->band = FREQUENCY_GetBand(Frequency); p_vfo->channel_attributes.band = FREQUENCY_GetBand(Frequency);
p_vfo->scanlist_1_participation = 1; p_vfo->channel_attributes.scanlist1 = 1;
p_vfo->scanlist_2_participation = 1; p_vfo->channel_attributes.scanlist2 = 1;
p_vfo->step_setting = STEP_12_5kHz; p_vfo->channel.step_setting = STEP_12_5kHz;
p_vfo->step_freq = STEP_FREQ_TABLE[p_vfo->step_setting]; p_vfo->step_freq = STEP_FREQ_TABLE[p_vfo->channel.step_setting];
p_vfo->channel_save = ChannelSave; p_vfo->channel_save = ChannelSave;
p_vfo->frequency_reverse = false; p_vfo->channel.frequency_reverse = false;
p_vfo->output_power = OUTPUT_POWER_LOW; p_vfo->channel.tx_power = OUTPUT_POWER_LOW;
p_vfo->freq_config_rx.frequency = Frequency; p_vfo->freq_config_rx.frequency = Frequency;
p_vfo->freq_config_tx.frequency = Frequency; p_vfo->freq_config_tx.frequency = Frequency;
p_vfo->p_rx = &p_vfo->freq_config_rx; p_vfo->p_rx = &p_vfo->freq_config_rx;
p_vfo->p_tx = &p_vfo->freq_config_tx; p_vfo->p_tx = &p_vfo->freq_config_tx;
p_vfo->compand = 0; // off p_vfo->channel.compand = 0; // off
p_vfo->squelch_level = 0; // use main squelch p_vfo->channel.squelch_level = 0; // use main squelch
p_vfo->freq_in_channel = 0xff; p_vfo->freq_in_channel = 0xff;
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz))
p_vfo->am_mode = 1; p_vfo->channel.am_mode = 1; // AM
RADIO_ConfigureSquelchAndOutputPower(p_vfo); RADIO_ConfigureSquelchAndOutputPower(p_vfo);
} }
@ -150,6 +153,7 @@ void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t
void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure) void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure)
{ {
unsigned int channel; unsigned int channel;
unsigned int chan;
t_channel_attrib attributes; t_channel_attrib attributes;
// uint16_t base; // uint16_t base;
uint32_t frequency; uint32_t frequency;
@ -185,7 +189,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
if (channel <= USER_CHANNEL_LAST) if (channel <= USER_CHANNEL_LAST)
{ {
channel = RADIO_FindNextChannel(channel, SCAN_STATE_DIR_FORWARD, false, VFO); channel = RADIO_FindNextChannel(channel, SCAN_STATE_DIR_FORWARD, false, VFO);
if (channel == 0xFF) if (!IS_VALID_CHANNEL(channel))
{ {
channel = g_eeprom.config.setting.indices.vfo[VFO].frequency; channel = g_eeprom.config.setting.indices.vfo[VFO].frequency;
g_eeprom.config.setting.indices.vfo[VFO].screen = channel; g_eeprom.config.setting.indices.vfo[VFO].screen = channel;
@ -202,9 +206,15 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
channel = FREQ_CHANNEL_LAST - 1; channel = FREQ_CHANNEL_LAST - 1;
} }
chan = CHANNEL_NUM(channel, VFO);
attributes = g_user_channel_attributes[channel]; attributes = g_user_channel_attributes[channel];
if (attributes.band > BAND7_470MHz) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("config chan 1 %u %u %u %u %u\r\n", channel, chan, attributes.band, attributes.scanlist1, attributes.scanlist2);
#endif
if (attributes.attributes == 0xff)
{ // invalid/unused channel { // invalid/unused channel
unsigned int index; unsigned int index;
@ -226,22 +236,17 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
if (channel <= USER_CHANNEL_LAST) if (channel <= USER_CHANNEL_LAST)
{ // USER channel { // USER channel
p_vfo->band = attributes.band; p_vfo->channel_attributes = attributes;
p_vfo->scanlist_2_participation = attributes.scanlist2;
p_vfo->scanlist_1_participation = attributes.scanlist1;
} }
else else
if (IS_FREQ_CHANNEL(channel)) if (IS_FREQ_CHANNEL(channel))
{ // VFO channel { // VFO channel
attributes.band = channel - FREQ_CHANNEL_FIRST; // shouldn't this be "Band / 2" ? .. two VFO's per band TODO: attributes.band = channel - FREQ_CHANNEL_FIRST;
g_vfo_info[VFO].band = attributes.band; p_vfo->channel_attributes = attributes;
#if 0 #if 0
p_vfo->scanlist_2_participation = 1; // don't allow the VFO's to change their scanlist bits
p_vfo->scanlist_1_participation = 1; p_vfo->channel_attributes.scanlist2 = 1;
#else p_vfo->channel_attributes.scanlist1 = 1;
// allowing the vfo's to be included in the scanning
p_vfo->scanlist_2_participation = attributes.scanlist2;
p_vfo->scanlist_1_participation = attributes.scanlist1;
#endif #endif
} }
@ -254,72 +259,32 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(channel)) if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(channel))
{ {
const unsigned int chan = CHANNEL_NUM(channel, VFO);
t_channel m_channel;
// EEPROM_ReadBuffer(Base, &m_channel, sizeof(t_channel)); // EEPROM_ReadBuffer(Base, &m_channel, sizeof(t_channel));
memcpy(&m_channel, &g_eeprom.config.channel[chan], sizeof(t_channel));
p_vfo->freq_config_rx.frequency = m_channel.frequency; // EEPROM_ReadBuffer(Base, p_vfo->channel, sizeof(t_channel));
memcpy(&p_vfo->channel, &g_eeprom.config.channel[chan], sizeof(t_channel));
p_vfo->tx_offset_freq = (m_channel.tx_offset < MAX_TX_OFFSET) ? m_channel.tx_offset : 0; p_vfo->step_freq = STEP_FREQ_TABLE[p_vfo->channel.step_setting];
p_vfo->tx_offset_freq_dir = (m_channel.tx_offset_dir < TX_OFFSET_FREQ_DIR_LAST) ? m_channel.tx_offset_dir : TX_OFFSET_FREQ_DIR_OFF;
p_vfo->am_mode = m_channel.am_mode; p_vfo->channel_attributes = g_eeprom.config.channel_attributes[channel];
p_vfo->step_setting = (m_channel.step_setting < ARRAY_SIZE(STEP_FREQ_TABLE)) ? m_channel.step_setting : STEP_12_5kHz; p_vfo->freq_config_rx.frequency = p_vfo->channel.frequency;
p_vfo->step_freq = STEP_FREQ_TABLE[p_vfo->step_setting];
p_vfo->scrambling_type = (m_channel.scrambler < ARRAY_SIZE(g_sub_menu_scrambler)) ? m_channel.scrambler : 0; p_vfo->freq_config_rx.code_type = p_vfo->channel.rx_ctcss_cdcss_type;
p_vfo->freq_config_rx.code = p_vfo->channel.rx_ctcss_cdcss_code;
p_vfo->freq_config_rx.code_type = m_channel.rx_ctcss_cdcss_type; p_vfo->freq_config_tx.code_type = p_vfo->channel.tx_ctcss_cdcss_type;
switch (m_channel.rx_ctcss_cdcss_type) p_vfo->freq_config_tx.code = p_vfo->channel.tx_ctcss_cdcss_code;
{
default:
case CODE_TYPE_NONE:
p_vfo->freq_config_rx.code_type = CODE_TYPE_NONE;
p_vfo->freq_config_rx.code = 0;
break;
case CODE_TYPE_CONTINUOUS_TONE:
p_vfo->freq_config_rx.code = (m_channel.rx_ctcss_cdcss_code < ARRAY_SIZE(CTCSS_TONE_LIST)) ? m_channel.rx_ctcss_cdcss_code : 0;
break;
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
p_vfo->freq_config_rx.code = (m_channel.rx_ctcss_cdcss_code < ARRAY_SIZE(DCS_CODE_LIST)) ? m_channel.rx_ctcss_cdcss_code : 0;
break;
}
p_vfo->freq_config_tx.code_type = m_channel.tx_ctcss_cdcss_type; #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
switch (m_channel.tx_ctcss_cdcss_type) UART_printf("config chan 2 %u %u %u %u %u %uHz\r\n", channel, chan, p_vfo->channel_attributes.band, p_vfo->channel_attributes.scanlist1, p_vfo->channel_attributes.scanlist2, p_vfo->channel.frequency * 10);
{ #endif
default: }
case CODE_TYPE_NONE: else
p_vfo->freq_config_tx.code_type = CODE_TYPE_NONE; {
p_vfo->freq_config_tx.code = 0; #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
break; UART_printf("config chan 3 %u %u %u %u %uHz\r\n", channel, p_vfo->channel_attributes.band, p_vfo->channel_attributes.scanlist1, p_vfo->channel_attributes.scanlist2, p_vfo->channel.frequency * 10);
case CODE_TYPE_CONTINUOUS_TONE:
p_vfo->freq_config_tx.code = (m_channel.tx_ctcss_cdcss_code < ARRAY_SIZE(CTCSS_TONE_LIST)) ? m_channel.tx_ctcss_cdcss_code : 0;
break;
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
p_vfo->freq_config_tx.code = (m_channel.tx_ctcss_cdcss_code < ARRAY_SIZE(DCS_CODE_LIST)) ? m_channel.tx_ctcss_cdcss_code : 0;
break;
}
#ifdef ENABLE_MDC1200
p_vfo->mdc1200_mode = m_channel.mdc1200_mode;
#endif #endif
p_vfo->frequency_reverse = m_channel.frequency_reverse ? true : false;
p_vfo->channel_bandwidth = m_channel.channel_bandwidth ? true : false;
p_vfo->output_power = m_channel.tx_power;
p_vfo->busy_channel_lock = m_channel.busy_channel_lock ? true : false;
p_vfo->compand = m_channel.compand;
p_vfo->dtmf_decoding_enable = m_channel.dtmf_decoding_enable ? true : false;
p_vfo->dtmf_ptt_id_tx_mode = m_channel.dtmf_ptt_id_tx_mode;
p_vfo->squelch_level = (m_channel.squelch_level < 10) ? m_channel.squelch_level : 0;
} }
frequency = p_vfo->freq_config_rx.frequency; frequency = p_vfo->freq_config_rx.frequency;
@ -341,10 +306,10 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
p_vfo->freq_config_rx.frequency = frequency; p_vfo->freq_config_rx.frequency = frequency;
p_vfo->freq_config_tx.frequency = frequency; p_vfo->freq_config_tx.frequency = frequency;
attributes.band = FREQUENCY_GetBand(frequency); attributes.band = FREQUENCY_GetBand(frequency);
p_vfo->band = attributes.band; p_vfo->channel_attributes.band = attributes.band;
p_vfo->frequency_reverse = 0; p_vfo->channel.frequency_reverse = 0;
p_vfo->tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; p_vfo->channel.tx_offset_dir = TX_OFFSET_FREQ_DIR_OFF;
p_vfo->tx_offset_freq = 0; p_vfo->channel.tx_offset = 0;
// TODO: also update other settings such as step size // TODO: also update other settings such as step size
@ -356,28 +321,28 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
if (frequency >= AIR_BAND.lower && frequency < AIR_BAND.upper) if (frequency >= AIR_BAND.lower && frequency < AIR_BAND.upper)
{ // air band { // air band
p_vfo->tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; p_vfo->channel.tx_offset_dir = TX_OFFSET_FREQ_DIR_OFF;
p_vfo->tx_offset_freq = 0; p_vfo->channel.tx_offset = 0;
} }
else else
if (channel > USER_CHANNEL_LAST) if (channel > USER_CHANNEL_LAST)
{ {
p_vfo->tx_offset_freq = FREQUENCY_floor_to_step(p_vfo->tx_offset_freq + (p_vfo->step_freq / 2), p_vfo->step_freq, 0, p_vfo->tx_offset_freq + p_vfo->step_freq); p_vfo->channel.tx_offset = FREQUENCY_floor_to_step(p_vfo->channel.tx_offset + (p_vfo->step_freq / 2), p_vfo->step_freq, 0, p_vfo->channel.tx_offset + p_vfo->step_freq);
} }
RADIO_ApplyOffset(p_vfo, true); RADIO_ApplyOffset(p_vfo, true);
// channel name // channel name
memset(p_vfo->name, 0, sizeof(p_vfo->name)); memset(p_vfo->channel_name, 0, sizeof(p_vfo->channel_name));
if (channel <= USER_CHANNEL_LAST) if (channel <= USER_CHANNEL_LAST)
// EEPROM_ReadBuffer(0x0F50 + (Channel * 16), p_vfo->name, 10); // only 10 bytes used // EEPROM_ReadBuffer(0x0F50 + (channel * 16), p_vfo->channel_name, 10); // only 10 bytes used
memcpy(p_vfo->name, &g_eeprom.config.channel_name[channel].name, sizeof(g_eeprom.config.channel_name[channel].name)); memcpy(p_vfo->channel_name, &g_eeprom.config.channel_name[channel].name, sizeof(g_eeprom.config.channel_name[channel].name));
if (p_vfo->am_mode > 0) if (p_vfo->channel.am_mode > 0)
{ // freq/chan is in AM mode { // freq/chan is in AM mode
// disable stuff, even though it can all still be used with AM ??? // disable stuff, even though it can all still be used with AM ???
p_vfo->scrambling_type = 0; p_vfo->channel.scrambler = 0;
// p_vfo->dtmf_decoding_enable = false; // p_vfo->channel.dtmf_decoding_enable = 0;
p_vfo->freq_config_rx.code_type = CODE_TYPE_NONE; p_vfo->freq_config_rx.code_type = CODE_TYPE_NONE;
p_vfo->freq_config_tx.code_type = CODE_TYPE_NONE; p_vfo->freq_config_tx.code_type = CODE_TYPE_NONE;
} }
@ -385,7 +350,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
RADIO_ConfigureSquelchAndOutputPower(p_vfo); RADIO_ConfigureSquelchAndOutputPower(p_vfo);
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (p_vfo->am_mode > 0 && g_eeprom.config.setting.am_fix) if (p_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix)
{ {
AM_fix_reset(VFO); AM_fix_reset(VFO);
AM_fix_10ms(VFO); AM_fix_10ms(VFO);
@ -454,7 +419,7 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
// band = FREQUENCY_GetBand(p_vfo->p_rx->frequency); // band = FREQUENCY_GetBand(p_vfo->p_rx->frequency);
// base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00; // base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00;
squelch_level = (p_vfo->squelch_level > 0) ? p_vfo->squelch_level : g_eeprom.config.setting.squelch_level; squelch_level = (p_vfo->channel.squelch_level > 0) ? p_vfo->channel.squelch_level : g_eeprom.config.setting.squelch_level;
// note that 'noise' and 'glitch' values are inverted compared to 'rssi' values // note that 'noise' and 'glitch' values are inverted compared to 'rssi' values
@ -587,18 +552,18 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
const unsigned int band = (unsigned int)FREQUENCY_GetBand(p_vfo->p_tx->frequency); const unsigned int band = (unsigned int)FREQUENCY_GetBand(p_vfo->p_tx->frequency);
// EEPROM_ReadBuffer(0x1ED0 + (band * 16) + (p_vfo->output_power * 3), tx_power, 3); // EEPROM_ReadBuffer(0x1ED0 + (band * 16) + (p_vfo->output_power * 3), tx_power, 3);
memcpy(&tx_power, &g_eeprom.calib.tx_band_power[band].level[p_vfo->output_power], 3); memcpy(&tx_power, &g_eeprom.calib.tx_band_power[band].level[p_vfo->channel.tx_power], 3);
#ifdef ENABLE_REDUCE_LOW_MID_TX_POWER #ifdef ENABLE_REDUCE_LOW_MID_TX_POWER
// make low and mid even lower // make low and mid even lower
if (p_vfo->output_power == OUTPUT_POWER_LOW) if (p_vfo->channel.tx_power == OUTPUT_POWER_LOW)
{ {
tx_power[0] /= 5; //tx_power[0] /= 8; tx_power[0] /= 5; //tx_power[0] /= 8;
tx_power[1] /= 5; //tx_power[1] /= 8; tx_power[1] /= 5; //tx_power[1] /= 8;
tx_power[2] /= 5; //tx_power[2] /= 8; get more low power tx_power[2] /= 5; //tx_power[2] /= 8; get more low power
} }
else else
if (p_vfo->output_power == OUTPUT_POWER_MID) if (p_vfo->channel.tx_power == OUTPUT_POWER_MID)
{ {
tx_power[0] /= 3; //tx_power[0] /= 5; tx_power[0] /= 3; //tx_power[0] /= 5;
tx_power[1] /= 3; //tx_power[1] /= 5; tx_power[1] /= 3; //tx_power[1] /= 5;
@ -623,15 +588,15 @@ void RADIO_ApplyOffset(vfo_info_t *p_vfo, const bool set_pees)
{ {
uint32_t Frequency = p_vfo->freq_config_rx.frequency; uint32_t Frequency = p_vfo->freq_config_rx.frequency;
switch (p_vfo->tx_offset_freq_dir) switch (p_vfo->channel.tx_offset_dir)
{ {
case TX_OFFSET_FREQ_DIR_OFF: case TX_OFFSET_FREQ_DIR_OFF:
break; break;
case TX_OFFSET_FREQ_DIR_ADD: case TX_OFFSET_FREQ_DIR_ADD:
Frequency += p_vfo->tx_offset_freq; Frequency += p_vfo->channel.tx_offset;
break; break;
case TX_OFFSET_FREQ_DIR_SUB: case TX_OFFSET_FREQ_DIR_SUB:
Frequency -= p_vfo->tx_offset_freq; Frequency -= p_vfo->channel.tx_offset;
break; break;
} }
@ -645,7 +610,7 @@ void RADIO_ApplyOffset(vfo_info_t *p_vfo, const bool set_pees)
if (set_pees) if (set_pees)
{ {
if (!p_vfo->frequency_reverse) if (!p_vfo->channel.frequency_reverse)
{ {
p_vfo->p_rx = &p_vfo->freq_config_rx; p_vfo->p_rx = &p_vfo->freq_config_rx;
p_vfo->p_tx = &p_vfo->freq_config_tx; p_vfo->p_tx = &p_vfo->freq_config_tx;
@ -676,7 +641,7 @@ void RADIO_select_vfos(void)
void RADIO_setup_registers(bool switch_to_function_foreground) void RADIO_setup_registers(bool switch_to_function_foreground)
{ {
BK4819_filter_bandwidth_t Bandwidth = g_rx_vfo->channel_bandwidth; BK4819_filter_bandwidth_t Bandwidth = g_rx_vfo->channel.channel_bandwidth;
uint16_t interrupt_mask; uint16_t interrupt_mask;
uint32_t Frequency; uint32_t Frequency;
@ -697,10 +662,10 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
#if 0 #if 0
// BK4819_SetFilterBandwidth(Bandwidth, g_rx_vfo->am_mode > 0 && g_eeprom.config.setting.am_fix); // BK4819_SetFilterBandwidth(Bandwidth, g_rx_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
#else #else
if (g_rx_vfo->am_mode > 1) if (g_rx_vfo->channel.am_mode > 1)
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER, false); BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER, false);
else else
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
@ -758,7 +723,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true);
// AF RX Gain and DAC // AF RX Gain and DAC
// if (g_rx_vfo->am_mode > 0) // if (g_rx_vfo->channel.am_mode > 0)
// { // {
// BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000 // BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000
// } // }
@ -774,19 +739,19 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
#ifdef MUTE_AUDIO_FOR_VOICE #ifdef MUTE_AUDIO_FOR_VOICE
if (g_voice_write_index == 0) if (g_voice_write_index == 0)
AUDIO_set_mod_mode(g_rx_vfo->am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#else #else
AUDIO_set_mod_mode(g_rx_vfo->am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif #endif
#else #else
AUDIO_set_mod_mode(g_rx_vfo->am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif #endif
interrupt_mask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST; interrupt_mask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
{ {
if (g_rx_vfo->am_mode == 0) if (g_rx_vfo->channel.am_mode == 0)
{ // FM { // FM
uint8_t code_type = g_selected_code_type; uint8_t code_type = g_selected_code_type;
uint8_t code = g_selected_code; uint8_t code = g_selected_code;
@ -835,8 +800,8 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
break; break;
} }
if (g_rx_vfo->scrambling_type > 0 && g_eeprom.config.setting.enable_scrambler) if (g_rx_vfo->channel.scrambler > 0 && g_eeprom.config.setting.enable_scrambler)
BK4819_EnableScramble(g_rx_vfo->scrambling_type - 1); BK4819_EnableScramble(g_rx_vfo->channel.scrambler - 1);
else else
BK4819_DisableScramble(); BK4819_DisableScramble();
} }
@ -857,7 +822,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
#endif #endif
g_eeprom.config.setting.vox_enabled && g_eeprom.config.setting.vox_enabled &&
IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) && IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) &&
g_current_vfo->am_mode == 0) g_current_vfo->channel.am_mode == 0)
{ {
RADIO_enable_vox(g_eeprom.config.setting.vox_level); RADIO_enable_vox(g_eeprom.config.setting.vox_level);
interrupt_mask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST; interrupt_mask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
@ -867,7 +832,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
BK4819_DisableVox(); BK4819_DisableVox();
// RX expander // RX expander
BK4819_SetCompander((g_rx_vfo->am_mode == 0 && g_rx_vfo->compand >= 2) ? g_rx_vfo->compand : 0); BK4819_SetCompander((g_rx_vfo->channel.am_mode == 0 && g_rx_vfo->channel.compand >= 2) ? g_rx_vfo->channel.compand : 0);
BK4819_EnableDTMF(); BK4819_EnableDTMF();
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND; interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
@ -936,7 +901,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
void RADIO_enableTX(const bool fsk_tx) void RADIO_enableTX(const bool fsk_tx)
{ {
BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel_bandwidth; BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel.channel_bandwidth;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
@ -953,10 +918,10 @@ void RADIO_enableTX(const bool fsk_tx)
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
#if 0 #if 0
// BK4819_SetFilterBandwidth(Bandwidth, g_current_vfo->am_mode > 0 && g_eeprom.config.setting.am_fix); // BK4819_SetFilterBandwidth(Bandwidth, g_current_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
#else #else
if (g_current_vfo->am_mode > 1) if (g_current_vfo->channel.am_mode > 1)
BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER, false); BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER, false);
else else
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
@ -971,7 +936,7 @@ void RADIO_enableTX(const bool fsk_tx)
// so MAKE SURE that DTMF is disabled - until needed // so MAKE SURE that DTMF is disabled - until needed
BK4819_DisableDTMF(); BK4819_DisableDTMF();
BK4819_SetCompander((!fsk_tx && g_rx_vfo->am_mode == 0 && (g_rx_vfo->compand == 1 || g_rx_vfo->compand >= 3)) ? g_rx_vfo->compand : 0); BK4819_SetCompander((!fsk_tx && g_rx_vfo->channel.am_mode == 0 && (g_rx_vfo->channel.compand == 1 || g_rx_vfo->channel.compand >= 3)) ? g_rx_vfo->channel.compand : 0);
BK4819_set_rf_frequency(g_current_vfo->p_tx->frequency, false); BK4819_set_rf_frequency(g_current_vfo->p_tx->frequency, false);
BK4819_set_rf_filter_path(g_current_vfo->p_tx->frequency); BK4819_set_rf_filter_path(g_current_vfo->p_tx->frequency);
@ -1069,7 +1034,7 @@ void RADIO_PrepareTX(void)
RADIO_SelectCurrentVfo(); RADIO_SelectCurrentVfo();
#ifndef ENABLE_TX_WHEN_AM #ifndef ENABLE_TX_WHEN_AM
if (g_current_vfo->am_mode > 0) if (g_current_vfo->channel.am_mode > 0)
{ // not allowed to TX if not in FM mode { // not allowed to TX if not in FM mode
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
@ -1082,7 +1047,7 @@ void RADIO_PrepareTX(void)
else else
if (FREQUENCY_tx_freq_check(g_current_vfo->p_tx->frequency) == 0) if (FREQUENCY_tx_freq_check(g_current_vfo->p_tx->frequency) == 0)
{ // TX frequency is allowed { // TX frequency is allowed
if (g_current_vfo->busy_channel_lock && g_current_function == FUNCTION_RECEIVE) if (g_current_vfo->channel.busy_channel_lock && g_current_function == FUNCTION_RECEIVE)
State = VFO_STATE_BUSY; // busy RX'ing a station State = VFO_STATE_BUSY; // busy RX'ing a station
else else
if (g_battery_display_level == 0) if (g_battery_display_level == 0)
@ -1194,7 +1159,7 @@ void RADIO_tx_eot(void)
#endif #endif
if (g_dtmf_call_state == DTMF_CALL_STATE_NONE && if (g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
(g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN || g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH)) (g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN || g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_BOTH))
{ // end-of-tx { // end-of-tx
if (g_eeprom.config.setting.dtmf.side_tone) if (g_eeprom.config.setting.dtmf.side_tone)
{ {
@ -1222,13 +1187,13 @@ void RADIO_tx_eot(void)
else else
#ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200
// if (g_eeprom.config.setting.roger_mode == ROGER_MODE_MDC) // if (g_eeprom.config.setting.roger_mode == ROGER_MODE_MDC)
if (g_current_vfo->mdc1200_mode == MDC1200_MODE_EOT || g_current_vfo->mdc1200_mode == MDC1200_MODE_BOTH) if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_EOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH)
{ {
BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.config.setting.mdc1200_id); BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.config.setting.mdc1200_id);
} }
else else
#endif #endif
if (g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO) if (g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{ {
BK4819_PlayTone(APOLLO_TONE2_HZ, APOLLO_TONE_MS, 28); BK4819_PlayTone(APOLLO_TONE2_HZ, APOLLO_TONE_MS, 28);
} }

105
radio.h
View File

@ -20,111 +20,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "misc.h"
#include "dcs.h"
#include "frequencies.h" #include "frequencies.h"
#include "settings.h"
/*
enum {
RADIO_CHANNEL_UP = 0x01u,
RADIO_CHANNEL_DOWN = 0xFFu,
};
*/
enum {
BANDWIDTH_WIDE = 0,
BANDWIDTH_NARROW
};
enum ptt_id_e {
PTT_ID_OFF = 0, // OFF
PTT_ID_TX_UP, // BEGIN OF TX
PTT_ID_TX_DOWN, // END OF TX
PTT_ID_BOTH, // BOTH
PTT_ID_APOLLO // Apolo quindar tones
};
typedef enum ptt_id_e ptt_id_t;
enum mdc1200_mode_e {
MDC1200_MODE_OFF = 0, // OFF
MDC1200_MODE_BOT, // BEGIN OF TX
MDC1200_MODE_EOT, // END OF TX
MDC1200_MODE_BOTH // BOTH
};
typedef enum mdc1200_mode_e mdc1200_mode_t;
enum vfo_state_e
{
VFO_STATE_NORMAL = 0,
VFO_STATE_BUSY,
VFO_STATE_BAT_LOW,
VFO_STATE_TX_DISABLE,
VFO_STATE_TIMEOUT,
VFO_STATE_ALARM,
VFO_STATE_VOLTAGE_HIGH
};
typedef enum vfo_state_e vfo_state_t;
typedef struct
{
uint32_t frequency;
dcs_code_type_t code_type;
uint8_t code;
uint8_t padding[2];
} freq_config_t;
typedef struct vfo_info_t
{
freq_config_t freq_config_rx;
freq_config_t freq_config_tx;
freq_config_t *p_rx;
freq_config_t *p_tx;
uint32_t tx_offset_freq;
uint16_t step_freq;
uint8_t channel_save;
uint8_t tx_offset_freq_dir;
uint8_t squelch_level; // per channel squelch level
uint8_t squelch_open_rssi_thresh;
uint8_t squelch_open_noise_thresh;
uint8_t squelch_close_glitch_thresh;
uint8_t squelch_close_rssi_thresh;
uint8_t squelch_close_noise_thresh;
uint8_t squelch_open_glitch_thresh;
step_setting_t step_setting;
uint8_t output_power;
uint8_t txp_calculated_setting;
bool frequency_reverse;
uint8_t scrambling_type;
uint8_t channel_bandwidth;
uint8_t scanlist_1_participation;
uint8_t scanlist_2_participation;
uint8_t band;
uint8_t dtmf_decoding_enable;
ptt_id_t dtmf_ptt_id_tx_mode;
#ifdef ENABLE_MDC1200
mdc1200_mode_t mdc1200_mode;
#endif
uint8_t busy_channel_lock;
uint8_t am_mode;
uint8_t compand;
uint8_t freq_in_channel; // channel number if the VFO's frequency is found stored in a channel
char name[16];
} vfo_info_t;
extern vfo_info_t g_vfo_info[2]; extern vfo_info_t g_vfo_info[2];

View File

@ -25,6 +25,7 @@
#include "driver/uart.h" #include "driver/uart.h"
#endif #endif
#include "misc.h" #include "misc.h"
#include "radio.h"
#include "settings.h" #include "settings.h"
#include "ui/menu.h" #include "ui/menu.h"
@ -41,8 +42,8 @@ static const uint32_t DEFAULT_FREQUENCY_TABLE[] =
}; };
t_eeprom g_eeprom; t_eeprom g_eeprom;
t_channel_attrib g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
t_channel_attrib g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
void SETTINGS_read_eeprom(void) void SETTINGS_read_eeprom(void)
{ {
@ -63,11 +64,9 @@ void SETTINGS_read_eeprom(void)
sizeof(g_eeprom), sizeof(g_eeprom)); sizeof(g_eeprom), sizeof(g_eeprom));
#endif #endif
#if 0
// sanity checks .. // sanity checks ..
// 0D60..0E27
memcpy(&g_user_channel_attributes, &g_eeprom.config.channel_attributes, sizeof(g_user_channel_attributes));
g_eeprom.config.setting.call1 = IS_USER_CHANNEL(g_eeprom.config.setting.call1) ? g_eeprom.config.setting.call1 : USER_CHANNEL_FIRST; g_eeprom.config.setting.call1 = IS_USER_CHANNEL(g_eeprom.config.setting.call1) ? g_eeprom.config.setting.call1 : USER_CHANNEL_FIRST;
g_eeprom.config.setting.squelch_level = (g_eeprom.config.setting.squelch_level < 10) ? g_eeprom.config.setting.squelch_level : 1; g_eeprom.config.setting.squelch_level = (g_eeprom.config.setting.squelch_level < 10) ? g_eeprom.config.setting.squelch_level : 1;
g_eeprom.config.setting.tx_timeout = (g_eeprom.config.setting.tx_timeout < 11) ? g_eeprom.config.setting.tx_timeout : 1; g_eeprom.config.setting.tx_timeout = (g_eeprom.config.setting.tx_timeout < 11) ? g_eeprom.config.setting.tx_timeout : 1;
@ -237,7 +236,7 @@ void SETTINGS_read_eeprom(void)
g_eeprom.config.setting.freq_lock = (g_eeprom.config.setting.freq_lock < FREQ_LOCK_LAST) ? g_eeprom.config.setting.freq_lock : FREQ_LOCK_NORMAL; g_eeprom.config.setting.freq_lock = (g_eeprom.config.setting.freq_lock < FREQ_LOCK_LAST) ? g_eeprom.config.setting.freq_lock : FREQ_LOCK_NORMAL;
// g_eeprom.config.setting.enable_tx_350 = (g_eeprom.config.setting.enable_tx_350 < 2) ? g_eeprom.config.setting.enable_tx_350 : false; // g_eeprom.config.setting.enable_tx_350 = (g_eeprom.config.setting.enable_tx_350 < 2) ? g_eeprom.config.setting.enable_tx_350 : false;
#ifdef ENABLE_KILL_REVIVE #ifdef ENABLE_KILL_REVIVE
// g_eeprom.config.setting.radio_disabled = (g_eeprom.config.setting.radio_disabled < 2) ? g_eeprom.config.setting.radio_disabled : 0; g_eeprom.config.setting.radio_disabled = (g_eeprom.config.setting.radio_disabled < 2) ? g_eeprom.config.setting.radio_disabled : 0;
#else #else
g_eeprom.config.setting.radio_disabled = 0; g_eeprom.config.setting.radio_disabled = 0;
#endif #endif
@ -261,6 +260,26 @@ void SETTINGS_read_eeprom(void)
#endif #endif
// g_eeprom.config.setting.backlight_on_tx_rx = (Data[7] >> 6) & 3u; // g_eeprom.config.setting.backlight_on_tx_rx = (Data[7] >> 6) & 3u;
#else
#ifndef ENABLE_KILL_REVIVE
memset(g_eeprom.config.setting.dtmf.kill_code, 0, sizeof(g_eeprom.config.setting.dtmf.kill_code));
memset(g_eeprom.config.setting.dtmf.revive_code, 0, sizeof(g_eeprom.config.setting.dtmf.revive_code));
g_eeprom.config.setting.dtmf.permit_remote_kill = 0;
#endif
#if ENABLE_RESET_AES_KEY
// wipe that darned AES key
memset(&g_eeprom.config.setting.aes_key, 0xff, sizeof(g_eeprom.config.setting.aes_key));
#endif
#ifndef ENABLE_KILL_REVIVE
g_eeprom.config.setting.radio_disabled = 0;
#endif
#endif
// 0F48..0F4F // 0F48..0F4F
g_eeprom.config.setting.scan_hold_time = (g_eeprom.config.setting.scan_hold_time > 40) ? 6 : (g_eeprom.config.setting.scan_hold_time < 2) ? 6 : g_eeprom.config.setting.scan_hold_time; g_eeprom.config.setting.scan_hold_time = (g_eeprom.config.setting.scan_hold_time > 40) ? 6 : (g_eeprom.config.setting.scan_hold_time < 2) ? 6 : g_eeprom.config.setting.scan_hold_time;
@ -268,6 +287,9 @@ void SETTINGS_read_eeprom(void)
memset(&g_eeprom.unused, 0xff, sizeof(g_eeprom.unused)); memset(&g_eeprom.unused, 0xff, sizeof(g_eeprom.unused));
// 0D60..0E27
memcpy(&g_user_channel_attributes, &g_eeprom.config.channel_attributes, sizeof(g_user_channel_attributes));
// **************************************** // ****************************************
memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3)); memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3));
@ -374,7 +396,7 @@ void SETTINGS_save(void)
} }
} }
void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, const vfo_info_t *p_vfo, const unsigned int mode) void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, vfo_info_t *p_vfo, const unsigned int mode)
{ {
const unsigned int chan = CHANNEL_NUM(channel, vfo); const unsigned int chan = CHANNEL_NUM(channel, vfo);
t_channel *p_channel = &g_eeprom.config.channel[chan]; t_channel *p_channel = &g_eeprom.config.channel[chan];
@ -386,41 +408,28 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c
if (mode < 2 && channel <= USER_CHANNEL_LAST) if (mode < 2 && channel <= USER_CHANNEL_LAST)
return; return;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("sav_chan %04X %3u %3u %u %u\r\n", eeprom_addr, chan, channel, vfo, mode);
#endif
// **************** // ****************
if (p_vfo != NULL) if (p_vfo != NULL)
{ {
memset(p_channel, 0, sizeof(t_channel)); memset(p_channel, 0, sizeof(t_channel));
p_channel->frequency = p_vfo->freq_config_rx.frequency;
p_channel->tx_offset = p_vfo->tx_offset_freq; p_vfo->channel.frequency = p_vfo->freq_config_rx.frequency;
p_channel->rx_ctcss_cdcss_code = p_vfo->freq_config_rx.code; p_vfo->channel.rx_ctcss_cdcss_code = p_vfo->freq_config_rx.code;
p_channel->tx_ctcss_cdcss_code = p_vfo->freq_config_tx.code; p_vfo->channel.tx_ctcss_cdcss_code = p_vfo->freq_config_tx.code;
p_channel->rx_ctcss_cdcss_type = p_vfo->freq_config_rx.code_type; p_vfo->channel.rx_ctcss_cdcss_type = p_vfo->freq_config_rx.code_type;
// p_channel->unused1:2 p_vfo->channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type;
p_channel->tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type;
#ifdef ENABLE_MDC1200 memcpy(p_channel, &p_vfo->channel, sizeof(t_channel));
p_channel->mdc1200_mode = p_vfo->mdc1200_mode;
if (IS_USER_CHANNEL(channel))
g_eeprom.config.channel_attributes[channel] = g_user_channel_attributes[channel];
// memcpy(g_eeprom.config.channel_name[channel], p_vfo->channel_name, 16);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("save chan %04X %3u %3u %u %u %uHz\r\n", eeprom_addr, chan, channel, vfo, mode, p_channel->frequency * 10);
#endif #endif
p_channel->tx_offset_dir = p_vfo->tx_offset_freq_dir;
// p_channel->unused3:2
p_channel->am_mode = p_vfo->am_mode;
// p_channel->unused4:3
p_channel->frequency_reverse = p_vfo->frequency_reverse;
p_channel->channel_bandwidth = p_vfo->channel_bandwidth;
p_channel->tx_power = p_vfo->output_power;
p_channel->busy_channel_lock = p_vfo->busy_channel_lock;
// p_channel->unused5:1
p_channel->compand = p_vfo->compand;
p_channel->dtmf_decoding_enable = p_vfo->dtmf_decoding_enable;
p_channel->dtmf_ptt_id_tx_mode = p_vfo->dtmf_ptt_id_tx_mode;
// p_channel->unused6:4
p_channel->step_setting = p_vfo->step_setting;
p_channel->scrambler = p_vfo->scrambling_type;
p_channel->squelch_level = p_vfo->squelch_level;
} }
else else
if (channel <= USER_CHANNEL_LAST) if (channel <= USER_CHANNEL_LAST)
@ -428,8 +437,8 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c
memset(p_channel, 0xff, sizeof(t_channel)); memset(p_channel, 0xff, sizeof(t_channel));
} }
EEPROM_WriteBuffer8(eeprom_addr + 0, (uint8_t *)(p_channel) + 0); EEPROM_WriteBuffer8(eeprom_addr + 0, ((uint8_t *)p_channel) + 0);
EEPROM_WriteBuffer8(eeprom_addr + 8, (uint8_t *)(p_channel) + 8); EEPROM_WriteBuffer8(eeprom_addr + 8, ((uint8_t *)p_channel) + 8);
// **************** // ****************
@ -450,7 +459,7 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c
#else #else
if (p_vfo != NULL) if (p_vfo != NULL)
memcpy(&g_eeprom.config.channel_name[channel], p_vfo->name, 10); memcpy(&g_eeprom.config.channel_name[channel], p_vfo->channel_name, 10);
if (mode >= 3 || p_vfo == NULL) if (mode >= 3 || p_vfo == NULL)
{ // save the channel name { // save the channel name
@ -476,13 +485,8 @@ void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_
if (p_vfo != NULL) if (p_vfo != NULL)
{ // channel attributes { // channel attributes
t_channel_attrib attribs; t_channel_attrib attribs = p_vfo->channel_attributes;
attribs.band = p_vfo->band & 7u;
attribs.unused = 3u; attribs.unused = 3u;
attribs.scanlist2 = p_vfo->scanlist_2_participation;
attribs.scanlist1 = p_vfo->scanlist_1_participation;
g_user_channel_attributes[channel] = attribs; // remember new attributes g_user_channel_attributes[channel] = attribs; // remember new attributes
g_eeprom.config.channel_attributes[channel] = attribs; g_eeprom.config.channel_attributes[channel] = attribs;
@ -504,7 +508,7 @@ void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_
if (p_vfo != NULL) if (p_vfo != NULL)
{ {
memset(&g_eeprom.config.channel_name[channel], 0, sizeof(g_eeprom.config.channel_name[channel])); memset(&g_eeprom.config.channel_name[channel], 0, sizeof(g_eeprom.config.channel_name[channel]));
memcpy(&g_eeprom.config.channel_name[channel], p_vfo->name, 10); memcpy(&g_eeprom.config.channel_name[channel], p_vfo->channel_name, 10);
} }
else else
{ {
@ -650,7 +654,7 @@ void SETTINGS_factory_reset(bool bIsAll)
const uint32_t Frequency = DEFAULT_FREQUENCY_TABLE[i]; const uint32_t Frequency = DEFAULT_FREQUENCY_TABLE[i];
g_rx_vfo->freq_config_rx.frequency = Frequency; g_rx_vfo->freq_config_rx.frequency = Frequency;
g_rx_vfo->freq_config_tx.frequency = Frequency; g_rx_vfo->freq_config_tx.frequency = Frequency;
g_rx_vfo->band = FREQUENCY_GetBand(Frequency); g_rx_vfo->channel_attributes.band = FREQUENCY_GetBand(Frequency);
SETTINGS_save_channel(USER_CHANNEL_FIRST + i, 0, g_rx_vfo, 2); SETTINGS_save_channel(USER_CHANNEL_FIRST + i, 0, g_rx_vfo, 2);
} }
} }

View File

@ -20,8 +20,9 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "misc.h"
#include "dcs.h"
#include "frequencies.h" #include "frequencies.h"
#include "radio.h"
enum pwr_on_display_mode_e { enum pwr_on_display_mode_e {
PWR_ON_DISPLAY_MODE_FULL_SCREEN = 0, PWR_ON_DISPLAY_MODE_FULL_SCREEN = 0,
@ -121,6 +122,46 @@ enum mdf_display_mode_e {
}; };
typedef enum mdf_display_mode_e mdf_display_mode_t; typedef enum mdf_display_mode_e mdf_display_mode_t;
/*
enum {
RADIO_CHANNEL_UP = 0x01u,
RADIO_CHANNEL_DOWN = 0xFFu,
};
*/
enum {
BANDWIDTH_WIDE = 0,
BANDWIDTH_NARROW
};
enum ptt_id_e {
PTT_ID_OFF = 0, // OFF
PTT_ID_TX_UP, // BEGIN OF TX
PTT_ID_TX_DOWN, // END OF TX
PTT_ID_BOTH, // BOTH
PTT_ID_APOLLO // Apolo quindar tones
};
typedef enum ptt_id_e ptt_id_t;
enum mdc1200_mode_e {
MDC1200_MODE_OFF = 0, // OFF
MDC1200_MODE_BOT, // BEGIN OF TX
MDC1200_MODE_EOT, // END OF TX
MDC1200_MODE_BOTH // BOTH
};
typedef enum mdc1200_mode_e mdc1200_mode_t;
enum vfo_state_e
{
VFO_STATE_NORMAL = 0,
VFO_STATE_BUSY,
VFO_STATE_BAT_LOW,
VFO_STATE_TX_DISABLE,
VFO_STATE_TIMEOUT,
VFO_STATE_ALARM,
VFO_STATE_VOLTAGE_HIGH
};
typedef enum vfo_state_e vfo_state_t;
// ************************************************ // ************************************************
// this is the full eeprom structure, both config and calibration areas // this is the full eeprom structure, both config and calibration areas
@ -150,10 +191,10 @@ typedef struct {
uint8_t unused3:2; // uint8_t unused3:2; //
#endif #endif
#if 0 #if 0
uint8_t am_mode:1; // uint8_t am_mode:1; // FM/AM
uint8_t unused4:3; // uint8_t unused4:3; //
#else #else
uint8_t am_mode:2; // uint8_t am_mode:2; // FM/AM/DSB
uint8_t unused4:2; // uint8_t unused4:2; //
#endif #endif
// [12] // [12]
@ -214,7 +255,7 @@ typedef struct {
} __attribute__((packed)); } __attribute__((packed));
// 0x0D60 // 0x0D60
t_channel_attrib channel_attributes[USER_CHANNEL_LAST - USER_CHANNEL_FIRST + 1]; t_channel_attrib channel_attributes[200];
struct { struct {
// 0x0E28 // 0x0E28
@ -469,6 +510,45 @@ typedef struct {
// ************************************************ // ************************************************
typedef struct
{
uint32_t frequency;
dcs_code_type_t code_type;
uint8_t code;
} freq_config_t;
typedef struct vfo_info_t
{
uint8_t channel_save;
freq_config_t freq_config_rx;
freq_config_t freq_config_tx;
freq_config_t *p_rx;
freq_config_t *p_tx;
t_channel channel;
t_channel_attrib channel_attributes;
char channel_name[16];
uint16_t step_freq;
uint8_t freq_in_channel; // channel number where we also found this VFO's frequency
uint8_t squelch_open_glitch_thresh;
uint8_t squelch_open_rssi_thresh;
uint8_t squelch_open_noise_thresh;
uint8_t squelch_close_glitch_thresh;
uint8_t squelch_close_rssi_thresh;
uint8_t squelch_close_noise_thresh;
uint8_t txp_calculated_setting;
} vfo_info_t;
// ************************************************
extern t_eeprom g_eeprom; extern t_eeprom g_eeprom;
extern t_channel_attrib g_user_channel_attributes[FREQ_CHANNEL_LAST + 1]; extern t_channel_attrib g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
@ -480,7 +560,7 @@ void SETTINGS_write_eeprom_config(void);
#endif #endif
void SETTINGS_save_vfo_indices(void); void SETTINGS_save_vfo_indices(void);
void SETTINGS_save(void); void SETTINGS_save(void);
void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, const vfo_info_t *p_vfo, const unsigned int mode); void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, vfo_info_t *p_vfo, const unsigned int mode);
void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_t *p_vfo); void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_t *p_vfo);
unsigned int SETTINGS_find_channel(const uint32_t frequency); unsigned int SETTINGS_find_channel(const uint32_t frequency);

View File

@ -84,7 +84,8 @@ void UI_PrintString(const char *str, unsigned int x, const unsigned int end, con
x += ofs; x += ofs;
} }
for (i = 0; i < length && (x + width) <= LCD_WIDTH; i++, x += width) // for (i = 0; i < length && (x + width) <= LCD_WIDTH; i++, x += width)
for (i = 0; i < length; i++, x += width)
{ {
const int c = (int)str[i] - ' '; const int c = (int)str[i] - ' ';
if (c >= 0 && c < (int)font_size) if (c >= 0 && c < (int)font_size)
@ -117,6 +118,7 @@ static void UI_print_string(
} }
for (i = 0; i < length && (x + char_width) <= LCD_WIDTH; i++, x += char_pitch) for (i = 0; i < length && (x + char_width) <= LCD_WIDTH; i++, x += char_pitch)
// for (i = 0; i < length; i++, x += char_pitch)
{ {
const int c = (int)str[i] - ' '; const int c = (int)str[i] - ' ';
if (c >= 0 && c < (int)font_size) if (c >= 0 && c < (int)font_size)

View File

@ -262,7 +262,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
// TODO: sort out all 8 values from the eeprom // TODO: sort out all 8 values from the eeprom
#if 1 #if 1
const unsigned int band = g_rx_vfo->band; const unsigned int band = g_rx_vfo->channel_attributes.band;
const int16_t level0 = g_eeprom_rssi_calib[band][0]; const int16_t level0 = g_eeprom_rssi_calib[band][0];
const int16_t level1 = g_eeprom_rssi_calib[band][1]; const int16_t level1 = g_eeprom_rssi_calib[band][1];
const int16_t level2 = g_eeprom_rssi_calib[band][2]; const int16_t level2 = g_eeprom_rssi_calib[band][2];
@ -730,7 +730,7 @@ void UI_DisplayMain(void)
} }
x += smallest_char_spacing * 4; x += smallest_char_spacing * 4;
if (g_vfo_info[vfo_num].compand) if (g_vfo_info[vfo_num].channel.compand)
UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true); UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true);
//x += smallest_char_spacing * 1; //x += smallest_char_spacing * 1;
} }
@ -740,14 +740,14 @@ void UI_DisplayMain(void)
const uint8_t freq_in_channel = g_vfo_info[vfo_num].freq_in_channel; const uint8_t freq_in_channel = g_vfo_info[vfo_num].freq_in_channel;
// const uint8_t freq_in_channel = SETTINGS_find_channel(frequency); // currently way to slow // const uint8_t freq_in_channel = SETTINGS_find_channel(frequency); // currently way to slow
if (g_vfo_info[vfo_num].compand) if (g_vfo_info[vfo_num].channel.compand)
{ {
strcpy(str, " "); strcpy(str, " ");
if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST) if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
str[0] = 'F'; // channel number that contains this VFO frequency str[0] = 'F'; // channel number that contains this VFO frequency
if (g_vfo_info[vfo_num].compand) if (g_vfo_info[vfo_num].channel.compand)
str[1] = 'C'; // compander is enabled str[1] = 'C'; // compander is enabled
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 2), 0, line + 1); UI_PrintStringSmall(str, LCD_WIDTH - (7 * 2), 0, line + 1);
@ -771,7 +771,7 @@ void UI_DisplayMain(void)
if (mode == 1) if (mode == 1)
{ // TX power level { // TX power level
switch (g_rx_vfo->output_power) switch (g_rx_vfo->channel.tx_power)
{ {
case OUTPUT_POWER_LOW: Level = 2; break; case OUTPUT_POWER_LOW: Level = 2; break;
case OUTPUT_POWER_MID: Level = 4; break; case OUTPUT_POWER_MID: Level = 4; break;
@ -791,10 +791,10 @@ void UI_DisplayMain(void)
// ************ // ************
str[0] = '\0'; str[0] = '\0';
if (g_vfo_info[vfo_num].am_mode > 0) if (g_vfo_info[vfo_num].channel.am_mode > 0)
{ {
//strcpy(str, g_sub_menu_mod_mode[g_vfo_info[vfo_num].am_mode]); //strcpy(str, g_sub_menu_mod_mode[g_vfo_info[vfo_num].channel.am_mode]);
switch (g_vfo_info[vfo_num].am_mode) switch (g_vfo_info[vfo_num].channel.am_mode)
{ {
default: default:
case 0: strcpy(str, "FM"); break; case 0: strcpy(str, "FM"); break;
@ -810,62 +810,62 @@ void UI_DisplayMain(void)
if (code_type < ARRAY_SIZE(code_list)) if (code_type < ARRAY_SIZE(code_list))
strcpy(str, code_list[code_type]); strcpy(str, code_list[code_type]);
} }
UI_PrintStringSmall(str, LCD_WIDTH + 24, 0, line + 1); UI_PrintStringSmall(str, 24, 0, line + 2);
#ifdef ENABLE_TX_WHEN_AM #ifdef ENABLE_TX_WHEN_AM
if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM)
#else #else
if ((state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) && g_vfo_info[vfo_num].am_mode == 0) // not allowed to TX if not in FM mode if ((state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) && g_vfo_info[vfo_num].channel.am_mode == 0) // TX allowed only when FM
#endif #endif
{ {
if (FREQUENCY_tx_freq_check(g_vfo_info[vfo_num].p_tx->frequency) == 0) if (FREQUENCY_tx_freq_check(g_vfo_info[vfo_num].p_tx->frequency) == 0)
{ {
// show the TX power // show the TX power
const char pwr_list[] = "LMH"; const char pwr_list[] = "LMH";
const unsigned int i = g_vfo_info[vfo_num].output_power; const unsigned int i = g_vfo_info[vfo_num].channel.tx_power;
str[0] = (i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0'; str[0] = (i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0';
str[1] = '\0'; str[1] = '\0';
UI_PrintStringSmall(str, LCD_WIDTH + 46, 0, line + 1); UI_PrintStringSmall(str, 46, 0, line + 2);
if (g_vfo_info[vfo_num].freq_config_rx.frequency != g_vfo_info[vfo_num].freq_config_tx.frequency) if (g_vfo_info[vfo_num].freq_config_rx.frequency != g_vfo_info[vfo_num].freq_config_tx.frequency)
{ // show the TX offset symbol { // show the TX offset symbol
const char dir_list[] = "\0+-"; const char dir_list[] = "\0+-";
const unsigned int i = g_vfo_info[vfo_num].tx_offset_freq_dir; const unsigned int i = g_vfo_info[vfo_num].channel.tx_offset_dir;
str[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?'; str[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?';
str[1] = '\0'; str[1] = '\0';
UI_PrintStringSmall(str, LCD_WIDTH + 54, 0, line + 1); UI_PrintStringSmall(str, 54, 0, line + 2);
} }
} }
} }
// show the TX/RX reverse symbol // show the TX/RX reverse symbol
if (g_vfo_info[vfo_num].frequency_reverse) if (g_vfo_info[vfo_num].channel.frequency_reverse)
UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1); UI_PrintStringSmall("R", 62, 0, line + 2);
{ // show the narrow band symbol { // show the narrow band symbol
str[0] = '\0'; str[0] = '\0';
if (g_vfo_info[vfo_num].channel_bandwidth == BANDWIDTH_NARROW) if (g_vfo_info[vfo_num].channel.channel_bandwidth == BANDWIDTH_NARROW)
{ {
str[0] = 'N'; str[0] = 'N';
str[1] = '\0'; str[1] = '\0';
} }
UI_PrintStringSmall(str, LCD_WIDTH + 70, 0, line + 1); UI_PrintStringSmall(str, 70, 0, line + 2);
} }
// show the DTMF decoding symbol // show the DTMF decoding symbol
#ifdef ENABLE_KILL_REVIVE #ifdef ENABLE_KILL_REVIVE
if (g_vfo_info[vfo_num].dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled) if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); UI_PrintStringSmall("DTMF", 78, 0, line + 2);
#else #else
if (g_vfo_info[vfo_num].dtmf_decoding_enable) if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable)
UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); UI_PrintStringSmall("DTMF", 78, 0, line + 2);
//UI_PrintStringSmall4x5("DTMF", LCD_WIDTH + 78, 0, line + 1); // font table is currently wrong //UI_PrintStringSmall4x5("DTMF", 78, 0, line + 2); // font table is currently wrong
//UI_PrintStringSmallest("DTMF", LCD_WIDTH + 78, (line + 1) * 8, false, true); //UI_PrintStringSmallest("DTMF", 78, (line + 2) * 8, false, true);
#endif #endif
// show the audio scramble symbol // show the audio scramble symbol
if (g_vfo_info[vfo_num].scrambling_type > 0 && g_eeprom.config.setting.enable_scrambler) if (g_vfo_info[vfo_num].channel.scrambler > 0 && g_eeprom.config.setting.enable_scrambler)
UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1); UI_PrintStringSmall("SCR", 106, 0, line + 2);
} }
if (g_center_line == CENTER_LINE_NONE && if (g_center_line == CENTER_LINE_NONE &&

View File

@ -30,6 +30,7 @@
#include "frequencies.h" #include "frequencies.h"
#include "helper/battery.h" #include "helper/battery.h"
#include "misc.h" #include "misc.h"
#include "radio.h"
#include "settings.h" #include "settings.h"
#include "ui/helper.h" #include "ui/helper.h"
#include "ui/inputbox.h" #include "ui/inputbox.h"
@ -470,7 +471,7 @@ void UI_SortMenu(const bool hide_hidden)
void UI_DisplayMenu(void) void UI_DisplayMenu(void)
{ {
const unsigned int menu_list_width = 6; // max no. of characters on the menu list (left side) const unsigned int menu_list_width = 6; // max no. of characters on the menu list (left side)
const unsigned int sub_menu_x1 = (8 * menu_list_width) + 0; // start x corrd const unsigned int sub_menu_x1 = 8 * menu_list_width; // start x corrd
const unsigned int sub_menu_x2 = LCD_WIDTH - 1; // end x coord const unsigned int sub_menu_x2 = LCD_WIDTH - 1; // end x coord
bool channel_setting = false; // set if the setting is a channel setting bool channel_setting = false; // set if the setting is a channel setting
unsigned int i; unsigned int i;
@ -736,7 +737,6 @@ void UI_DisplayMenu(void)
break; break;
case MENU_MOD_MODE: case MENU_MOD_MODE:
// strcpy(str, (g_sub_menu_selection == 0) ? "FM" : "AM");
strcpy(str, g_sub_menu_mod_mode[g_sub_menu_selection]); strcpy(str, g_sub_menu_mod_mode[g_sub_menu_selection]);
channel_setting = true; channel_setting = true;
break; break;
@ -793,6 +793,10 @@ void UI_DisplayMenu(void)
break; break;
case MENU_DTMF_DCD: case MENU_DTMF_DCD:
channel_setting = true;
// Fallthrough
case MENU_DTMF_LIVE_DEC: case MENU_DTMF_LIVE_DEC:
strcpy(str, "DTMF\nDECODE\n"); strcpy(str, "DTMF\nDECODE\n");
strcat(str, g_sub_menu_off_on[g_sub_menu_selection]); strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
@ -989,16 +993,19 @@ void UI_DisplayMenu(void)
case MENU_UP_CODE: case MENU_UP_CODE:
strcpy(str, "DTMF BOT\n"); strcpy(str, "DTMF BOT\n");
strcat(str, g_eeprom.config.setting.dtmf.key_up_code); strcat(str, g_eeprom.config.setting.dtmf.key_up_code);
channel_setting = true;
break; break;
case MENU_DN_CODE: case MENU_DN_CODE:
strcpy(str, "DTMF EOT\n"); strcpy(str, "DTMF EOT\n");
strcat(str, g_eeprom.config.setting.dtmf.key_down_code); strcat(str, g_eeprom.config.setting.dtmf.key_down_code);
channel_setting = true;
break; break;
case MENU_DTMF_RSP: case MENU_DTMF_RSP:
strcpy(str, "DTMF\nRESPONSE\n"); strcpy(str, "DTMF\nRESPONSE\n");
strcat(str, g_sub_menu_dtmf_rsp[g_sub_menu_selection]); strcat(str, g_sub_menu_dtmf_rsp[g_sub_menu_selection]);
channel_setting = true;
break; break;
case MENU_DTMF_HOLD: case MENU_DTMF_HOLD: