diff --git a/app/app.c b/app/app.c index bc4ca37..6b23d57 100644 --- a/app/app.c +++ b/app/app.c @@ -88,7 +88,7 @@ static void APP_update_rssi(const int vfo) #ifdef ENABLE_AM_FIX // add RF gain adjust compensation - if (g_current_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix) + if (g_current_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix) rssi -= rssi_gain_diff[vfo]; #endif @@ -527,7 +527,7 @@ bool APP_start_listening(void) } // AF gain - original QS values -// if (g_rx_vfo->channel.am_mode > 0) +// if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM) // { // BK4819_write_reg(0x48, 0xB3A8); // 1011 0011 1010 1000 // } @@ -550,12 +550,12 @@ bool APP_start_listening(void) #ifdef ENABLE_VOICE #ifdef MUTE_AUDIO_FOR_VOICE if (g_voice_write_index == 0) - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #else - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #endif #else - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #endif GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); @@ -2385,7 +2385,7 @@ void APP_time_slice_10ms(void) #endif #ifdef ENABLE_AM_FIX - if (g_rx_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix) + if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix) AM_fix_10ms(g_rx_vfo_num); #endif diff --git a/app/main.c b/app/main.c index e220c7e..ebf55c1 100644 --- a/app/main.c +++ b/app/main.c @@ -213,12 +213,8 @@ void processFKeyFunction(const key_code_t Key) if (g_fkey_pressed) { - #if 0 - g_tx_vfo->channel.am_mode = (g_tx_vfo->am_mode + 1) & 1u; - #else - if (++g_tx_vfo->channel.am_mode >= 3) - g_tx_vfo->channel.am_mode = 0; - #endif + if (++g_tx_vfo->channel.mod_mode >= MOD_MODE_LEN) + g_tx_vfo->channel.mod_mode = 0; g_request_save_channel = 1; } else diff --git a/app/menu.c b/app/menu.c index d798ad7..749d675 100644 --- a/app/menu.c +++ b/app/menu.c @@ -767,7 +767,7 @@ void MENU_AcceptSetting(void) break; case MENU_MOD_MODE: - g_tx_vfo->channel.am_mode = g_sub_menu_selection; + g_tx_vfo->channel.mod_mode = g_sub_menu_selection; g_request_save_channel = 1; return; /* @@ -1234,7 +1234,7 @@ void MENU_ShowCurrentSetting(void) break; case MENU_MOD_MODE: - g_sub_menu_selection = g_tx_vfo->channel.am_mode; + g_sub_menu_selection = g_tx_vfo->channel.mod_mode; break; /* #ifdef ENABLE_AM_FIX @@ -1765,7 +1765,7 @@ static void MENU_Key_STAR(const bool key_pressed, const bool key_held) RADIO_select_vfos(); - if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_rx_vfo->channel.am_mode == 0) + if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_rx_vfo->channel.mod_mode == MOD_MODE_FM) { 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 diff --git a/audio.c b/audio.c index f104d50..7e68b40 100644 --- a/audio.c +++ b/audio.c @@ -77,16 +77,15 @@ beep_type_t g_beep_to_play = BEEP_NONE; -void AUDIO_set_mod_mode(const unsigned int mode) +void AUDIO_set_mod_mode(const mod_mode_t mode) { BK4819_af_type_t af_mode; switch (mode) { default: - case 0: af_mode = BK4819_AF_FM; break; - case 1: af_mode = BK4819_AF_AM; break; - case 2: af_mode = BK4819_AF_BASEBAND1; break; - case 3: af_mode = BK4819_AF_BASEBAND2; break; + case MOD_MODE_FM: af_mode = BK4819_AF_FM; break; + case MOD_MODE_AM: af_mode = BK4819_AF_AM; break; + case MOD_MODE_DSB: af_mode = BK4819_AF_BASEBAND1; break; } BK4819_SetAF(af_mode); } @@ -338,7 +337,7 @@ void AUDIO_PlayBeep(beep_type_t Beep) SYSTEM_DelayMs(Delay * 10); if (g_current_function == FUNCTION_RECEIVE) - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #ifdef ENABLE_FMRADIO if (g_fm_radio_mode) @@ -486,7 +485,7 @@ void AUDIO_PlayBeep(beep_type_t Beep) // unmute the radios audio if (g_current_function == FUNCTION_RECEIVE) - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #ifdef ENABLE_FMRADIO if (g_fm_radio_mode) diff --git a/audio.h b/audio.h index 8d04dd2..6181d93 100644 --- a/audio.h +++ b/audio.h @@ -20,6 +20,8 @@ #include #include +#include "settings.h" + enum beep_type_e { BEEP_NONE = 0, BEEP_1KHZ_60MS_OPTIONAL, @@ -36,7 +38,7 @@ typedef enum beep_type_e beep_type_t; extern beep_type_t g_beep_to_play; -void AUDIO_set_mod_mode(const unsigned int mode); +void AUDIO_set_mod_mode(const mod_mode_t mode); void AUDIO_PlayBeep(beep_type_t Beep); enum { diff --git a/firmware.bin b/firmware.bin index ad73f23..d753332 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 64b7cb5..9c23f7b 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 5b870d1..f08fb4f 100644 --- a/functions.c +++ b/functions.c @@ -51,7 +51,7 @@ void FUNCTION_Init(void) { g_current_code_type = g_selected_code_type; if (g_css_scan_mode == CSS_SCAN_MODE_OFF) - g_current_code_type = (g_rx_vfo->channel.am_mode > 0) ? CODE_TYPE_NONE : g_rx_vfo->p_rx->code_type; + g_current_code_type = (g_rx_vfo->channel.mod_mode > 0) ? CODE_TYPE_NONE : g_rx_vfo->p_rx->code_type; } else g_current_code_type = CODE_TYPE_CONTINUOUS_TONE; diff --git a/radio.c b/radio.c index b978bcf..2241b00 100644 --- a/radio.c +++ b/radio.c @@ -145,7 +145,7 @@ void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t p_vfo->freq_in_channel = 0xff; if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) - p_vfo->channel.am_mode = 1; // AM + p_vfo->channel.mod_mode = MOD_MODE_AM; RADIO_ConfigureSquelchAndOutputPower(p_vfo); } @@ -338,7 +338,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur // EEPROM_ReadBuffer(0x0F50 + (channel * 16), p_vfo->channel_name, 10); // only 10 bytes used memcpy(p_vfo->channel_name.name, &g_eeprom.config.channel_name[channel].name, sizeof(p_vfo->channel_name.name)); - if (p_vfo->channel.am_mode > 0) + if (p_vfo->channel.mod_mode != MOD_MODE_FM) { // freq/chan is in AM mode // disable stuff, even though it can all still be used with AM ??? p_vfo->channel.scrambler = 0; @@ -351,7 +351,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur #ifdef ENABLE_AM_FIX AM_fix_reset(VFO); - if (p_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix) + if (p_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix) { AM_fix_10ms(VFO); } @@ -361,7 +361,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur BK4819_write_reg(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0)); } #else - if (p_vfo->am_mode > 0) + if (p_vfo->mod_mode != MOD_MODE_FM) { BK4819_EnableAGC(); } @@ -661,7 +661,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) BK4819_SetFilterBandwidth(Bandwidth); BK4819_EnableAFC(); #else - if (g_rx_vfo->channel.am_mode > 1) + if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM) { BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER); // sideband BK4819_DisableAFC(); @@ -726,7 +726,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true); // AF RX Gain and DAC -// if (g_rx_vfo->channel.am_mode > 0) +// if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM) // { // BK4819_write_reg(0x48, 0xB3A8); // 1011 0011 1010 1000 // } @@ -748,12 +748,12 @@ void RADIO_setup_registers(bool switch_to_function_foreground) #ifdef ENABLE_VOICE #ifdef MUTE_AUDIO_FOR_VOICE if (g_voice_write_index == 0) - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #else - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #endif #else - AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); + AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode); #endif } } @@ -762,7 +762,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) { - if (g_rx_vfo->channel.am_mode == 0) + if (g_rx_vfo->channel.mod_mode == MOD_MODE_FM) { // FM uint8_t code_type = g_selected_code_type; uint8_t code = g_selected_code; @@ -833,7 +833,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) #endif g_eeprom.config.setting.vox_enabled && IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) && - g_current_vfo->channel.am_mode == 0) + g_current_vfo->channel.mod_mode == MOD_MODE_FM) { RADIO_enable_vox(g_eeprom.config.setting.vox_level); interrupt_mask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST; @@ -843,7 +843,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) BK4819_DisableVox(); // RX expander - BK4819_SetCompander((g_rx_vfo->channel.am_mode == 0 && g_rx_vfo->channel.compand >= 2) ? g_rx_vfo->channel.compand : 0); + BK4819_SetCompander((g_rx_vfo->channel.mod_mode == MOD_MODE_FM && g_rx_vfo->channel.compand >= 2) ? g_rx_vfo->channel.compand : 0); BK4819_EnableDTMF(); interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND; @@ -932,7 +932,7 @@ void RADIO_enableTX(const bool fsk_tx) BK4819_SetFilterBandwidth(Bandwidth); BK4819_EnableAFC(); #else - if (g_current_vfo->channel.am_mode > 1) + if (g_current_vfo->channel.mod_mode == MOD_MODE_DSB) { BK4819_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER); // sideband BK4819_DisableAFC(); @@ -954,7 +954,7 @@ void RADIO_enableTX(const bool fsk_tx) // so MAKE SURE that DTMF is disabled - until needed BK4819_DisableDTMF(); - 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_SetCompander((!fsk_tx && g_rx_vfo->channel.mod_mode == MOD_MODE_FM && (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_filter_path(g_current_vfo->p_tx->frequency); @@ -1066,7 +1066,7 @@ void RADIO_PrepareTX(void) g_current_vfo = (g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) ? g_rx_vfo : &g_vfo_info[g_eeprom.config.setting.tx_vfo_num]; #ifndef ENABLE_TX_WHEN_AM - if (g_current_vfo->channel.am_mode > 0) + if (g_current_vfo->channel.mod_mode != MOD_MODE_FM) { // not allowed to TX if not in FM mode State = VFO_STATE_TX_DISABLE; } diff --git a/settings.h b/settings.h index a6a6709..19ec3a6 100644 --- a/settings.h +++ b/settings.h @@ -24,6 +24,14 @@ #include "dcs.h" #include "frequencies.h" +enum mod_mode_e { + MOD_MODE_FM = 0, + MOD_MODE_AM, + MOD_MODE_DSB, + MOD_MODE_LEN +}; +typedef enum mod_mode_e mod_mode_t; + enum pwr_on_display_mode_e { PWR_ON_DISPLAY_MODE_FULL_SCREEN = 0, PWR_ON_DISPLAY_MODE_MESSAGE, @@ -191,10 +199,10 @@ typedef struct { uint8_t unused3:2; // #endif #if 0 - uint8_t am_mode:1; // FM/AM + uint8_t mod_mode:1; // FM/AM uint8_t unused4:3; // #else - uint8_t am_mode:2; // FM/AM/DSB + uint8_t mod_mode:2; // FM/AM/DSB uint8_t unused4:2; // #endif // [12] diff --git a/ui/aircopy.c b/ui/aircopy.c index 3efdd8e..3dd0ef5 100644 --- a/ui/aircopy.c +++ b/ui/aircopy.c @@ -19,6 +19,7 @@ #include "external/printf/printf.h" #include "misc.h" #include "radio.h" +#include "settings.h" #include "ui/aircopy.h" #include "ui/helper.h" #include "ui/inputbox.h" diff --git a/ui/main.c b/ui/main.c index 40b00eb..628534b 100644 --- a/ui/main.c +++ b/ui/main.c @@ -820,15 +820,15 @@ void UI_DisplayMain(void) // ************ str[0] = '\0'; - if (g_vfo_info[vfo_num].channel.am_mode > 0) + if (g_vfo_info[vfo_num].channel.mod_mode != MOD_MODE_FM) { - //strcpy(str, g_sub_menu_mod_mode[g_vfo_info[vfo_num].channel.am_mode]); - switch (g_vfo_info[vfo_num].channel.am_mode) + //strcpy(str, g_sub_menu_mod_mode[g_vfo_info[vfo_num].channel.mod_mode]); + switch (g_vfo_info[vfo_num].channel.mod_mode) { default: - case 0: strcpy(str, "FM"); break; - case 1: strcpy(str, "AM"); break; - case 2: strcpy(str, "DS"); break; + case MOD_MODE_FM: strcpy(str, "FM"); break; + case MOD_MODE_AM: strcpy(str, "AM"); break; + case MOD_MODE_DSB: strcpy(str, "DS"); break; } } else @@ -844,7 +844,7 @@ void UI_DisplayMain(void) #ifdef ENABLE_TX_WHEN_AM if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) #else - if ((state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) && g_vfo_info[vfo_num].channel.am_mode == 0) // TX allowed only when FM + if ((state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) && g_vfo_info[vfo_num].channel.mod_mode == MOD_MODE_FM) // TX allowed only when FM #endif { if (FREQUENCY_tx_freq_check(g_vfo_info[vfo_num].p_tx->frequency) == 0) @@ -934,7 +934,7 @@ void UI_DisplayMain(void) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) // show the AM-FIX debug data - if (rx && g_vfo_info[g_rx_vfo_num].am_mode > 0 && g_eeprom.config.setting.am_fix) + if (rx && g_vfo_info[g_rx_vfo_num].mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix) { g_center_line = CENTER_LINE_AM_FIX_DATA; AM_fix_print_data(g_rx_vfo_num, str);