0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 06:11:24 +03:00

modulation mode constants

This commit is contained in:
OneOfEleven 2023-11-06 14:46:39 +00:00
parent 1ee2662f78
commit be787babf2
12 changed files with 55 additions and 49 deletions

View File

@ -88,7 +88,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->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]; rssi -= rssi_gain_diff[vfo];
#endif #endif
@ -527,7 +527,7 @@ bool APP_start_listening(void)
} }
// AF gain - original QS values // 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 // BK4819_write_reg(0x48, 0xB3A8); // 1011 0011 1010 1000
// } // }
@ -550,12 +550,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->channel.am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
#else #else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
#endif #endif
#else #else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
#endif #endif
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
@ -2385,7 +2385,7 @@ void APP_time_slice_10ms(void)
#endif #endif
#ifdef ENABLE_AM_FIX #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); AM_fix_10ms(g_rx_vfo_num);
#endif #endif

View File

@ -213,12 +213,8 @@ void processFKeyFunction(const key_code_t Key)
if (g_fkey_pressed) if (g_fkey_pressed)
{ {
#if 0 if (++g_tx_vfo->channel.mod_mode >= MOD_MODE_LEN)
g_tx_vfo->channel.am_mode = (g_tx_vfo->am_mode + 1) & 1u; g_tx_vfo->channel.mod_mode = 0;
#else
if (++g_tx_vfo->channel.am_mode >= 3)
g_tx_vfo->channel.am_mode = 0;
#endif
g_request_save_channel = 1; g_request_save_channel = 1;
} }
else else

View File

@ -767,7 +767,7 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_MOD_MODE: 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; g_request_save_channel = 1;
return; return;
/* /*
@ -1234,7 +1234,7 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_MOD_MODE: 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; break;
/* /*
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
@ -1765,7 +1765,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->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) 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

13
audio.c
View File

@ -77,16 +77,15 @@
beep_type_t g_beep_to_play = BEEP_NONE; 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; BK4819_af_type_t af_mode;
switch (mode) switch (mode)
{ {
default: default:
case 0: af_mode = BK4819_AF_FM; break; case MOD_MODE_FM: af_mode = BK4819_AF_FM; break;
case 1: af_mode = BK4819_AF_AM; break; case MOD_MODE_AM: af_mode = BK4819_AF_AM; break;
case 2: af_mode = BK4819_AF_BASEBAND1; break; case MOD_MODE_DSB: af_mode = BK4819_AF_BASEBAND1; break;
case 3: af_mode = BK4819_AF_BASEBAND2; break;
} }
BK4819_SetAF(af_mode); BK4819_SetAF(af_mode);
} }
@ -338,7 +337,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
SYSTEM_DelayMs(Delay * 10); SYSTEM_DelayMs(Delay * 10);
if (g_current_function == FUNCTION_RECEIVE) 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 #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
@ -486,7 +485,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
// unmute the radios audio // unmute the radios audio
if (g_current_function == FUNCTION_RECEIVE) 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 #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)

View File

@ -20,6 +20,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "settings.h"
enum beep_type_e { enum beep_type_e {
BEEP_NONE = 0, BEEP_NONE = 0,
BEEP_1KHZ_60MS_OPTIONAL, BEEP_1KHZ_60MS_OPTIONAL,
@ -36,7 +38,7 @@ typedef enum beep_type_e beep_type_t;
extern beep_type_t g_beep_to_play; 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); void AUDIO_PlayBeep(beep_type_t Beep);
enum { enum {

Binary file not shown.

Binary file not shown.

View File

@ -51,7 +51,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->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 else
g_current_code_type = CODE_TYPE_CONTINUOUS_TONE; g_current_code_type = CODE_TYPE_CONTINUOUS_TONE;

30
radio.c
View File

@ -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; p_vfo->freq_in_channel = 0xff;
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) 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); 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 // 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)); 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 { // 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->channel.scrambler = 0; 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 #ifdef ENABLE_AM_FIX
AM_fix_reset(VFO); 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); 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)); BK4819_write_reg(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
} }
#else #else
if (p_vfo->am_mode > 0) if (p_vfo->mod_mode != MOD_MODE_FM)
{ {
BK4819_EnableAGC(); BK4819_EnableAGC();
} }
@ -661,7 +661,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
BK4819_SetFilterBandwidth(Bandwidth); BK4819_SetFilterBandwidth(Bandwidth);
BK4819_EnableAFC(); BK4819_EnableAFC();
#else #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_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER); // sideband
BK4819_DisableAFC(); 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); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true);
// AF RX Gain and DAC // 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 // 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 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->channel.am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
#else #else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
#endif #endif
#else #else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode); AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
#endif #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 (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 { // 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;
@ -833,7 +833,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->channel.am_mode == 0) g_current_vfo->channel.mod_mode == MOD_MODE_FM)
{ {
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;
@ -843,7 +843,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
BK4819_DisableVox(); BK4819_DisableVox();
// RX expander // 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(); BK4819_EnableDTMF();
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND; interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
@ -932,7 +932,7 @@ void RADIO_enableTX(const bool fsk_tx)
BK4819_SetFilterBandwidth(Bandwidth); BK4819_SetFilterBandwidth(Bandwidth);
BK4819_EnableAFC(); BK4819_EnableAFC();
#else #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_SetFilterBandwidth(BK4819_FILTER_BW_NARROWER); // sideband
BK4819_DisableAFC(); BK4819_DisableAFC();
@ -954,7 +954,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->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_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);
@ -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]; 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 #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 { // not allowed to TX if not in FM mode
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }

View File

@ -24,6 +24,14 @@
#include "dcs.h" #include "dcs.h"
#include "frequencies.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 { enum pwr_on_display_mode_e {
PWR_ON_DISPLAY_MODE_FULL_SCREEN = 0, PWR_ON_DISPLAY_MODE_FULL_SCREEN = 0,
PWR_ON_DISPLAY_MODE_MESSAGE, PWR_ON_DISPLAY_MODE_MESSAGE,
@ -191,10 +199,10 @@ typedef struct {
uint8_t unused3:2; // uint8_t unused3:2; //
#endif #endif
#if 0 #if 0
uint8_t am_mode:1; // FM/AM uint8_t mod_mode:1; // FM/AM
uint8_t unused4:3; // uint8_t unused4:3; //
#else #else
uint8_t am_mode:2; // FM/AM/DSB uint8_t mod_mode:2; // FM/AM/DSB
uint8_t unused4:2; // uint8_t unused4:2; //
#endif #endif
// [12] // [12]

View File

@ -19,6 +19,7 @@
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "misc.h" #include "misc.h"
#include "radio.h" #include "radio.h"
#include "settings.h"
#include "ui/aircopy.h" #include "ui/aircopy.h"
#include "ui/helper.h" #include "ui/helper.h"
#include "ui/inputbox.h" #include "ui/inputbox.h"

View File

@ -820,15 +820,15 @@ void UI_DisplayMain(void)
// ************ // ************
str[0] = '\0'; 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]); //strcpy(str, g_sub_menu_mod_mode[g_vfo_info[vfo_num].channel.mod_mode]);
switch (g_vfo_info[vfo_num].channel.am_mode) switch (g_vfo_info[vfo_num].channel.mod_mode)
{ {
default: default:
case 0: strcpy(str, "FM"); break; case MOD_MODE_FM: strcpy(str, "FM"); break;
case 1: strcpy(str, "AM"); break; case MOD_MODE_AM: strcpy(str, "AM"); break;
case 2: strcpy(str, "DS"); break; case MOD_MODE_DSB: strcpy(str, "DS"); break;
} }
} }
else else
@ -844,7 +844,7 @@ void UI_DisplayMain(void)
#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].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 #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)
@ -934,7 +934,7 @@ void UI_DisplayMain(void)
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
// show the AM-FIX debug 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; g_center_line = CENTER_LINE_AM_FIX_DATA;
AM_fix_print_data(g_rx_vfo_num, str); AM_fix_print_data(g_rx_vfo_num, str);