0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

Removed duplicate AM flag (IsAM)

This commit is contained in:
OneOfEleven 2023-09-28 23:32:08 +01:00
parent d2729c2007
commit 8ce02a37a9
10 changed files with 51 additions and 56 deletions

View File

@ -71,7 +71,7 @@ static void updateRSSI(const int vfo)
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// add RF gain adjust compensation // add RF gain adjust compensation
if (gEeprom.VfoInfo[vfo].IsAM && gSetting_AM_fix) if (gEeprom.VfoInfo[vfo].AM_mode && gSetting_AM_fix)
rssi -= rssi_gain_diff[vfo]; rssi -= rssi_gain_diff[vfo];
#endif #endif
@ -433,7 +433,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
#endif #endif
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].IsAM && reset_am_fix) if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && reset_am_fix)
AM_fix_reset(gEeprom.RX_CHANNEL); // TODO: only reset it when moving channel/frequency AM_fix_reset(gEeprom.RX_CHANNEL); // TODO: only reset it when moving channel/frequency
#endif #endif
@ -505,7 +505,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
uint8_t mixer = orig_mixer; uint8_t mixer = orig_mixer;
uint8_t pga = orig_pga; uint8_t pga = orig_pga;
if (gRxVfo->IsAM) if (gRxVfo->AM_mode)
{ // AM { // AM
/* /*
#ifndef ENABLE_AM_FIX #ifndef ENABLE_AM_FIX
@ -553,7 +553,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gVoiceWriteIndex == 0) if (gVoiceWriteIndex == 0)
#endif #endif
BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN); BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN);
FUNCTION_Select(Function); FUNCTION_Select(Function);
@ -1351,7 +1351,7 @@ void APP_TimeSlice10ms(void)
#endif #endif
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].IsAM && gSetting_AM_fix) if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix)
AM_fix_10ms(gEeprom.RX_CHANNEL); AM_fix_10ms(gEeprom.RX_CHANNEL);
#endif #endif

View File

@ -625,8 +625,8 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_AM: case MENU_AM:
gTxVfo->AM_CHANNEL_MODE = gSubMenuSelection; gTxVfo->AM_mode = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
@ -1013,7 +1013,7 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_AM: case MENU_AM:
gSubMenuSelection = gTxVfo->AM_CHANNEL_MODE; gSubMenuSelection = gTxVfo->AM_mode;
break; break;
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
@ -1459,9 +1459,9 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && !gRxVfo->IsAM) if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->AM_mode == 0)
#else #else
if (!gRxVfo->IsAM) if (gRxVfo->AM_mode == 0)
#endif #endif
{ {
if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS)

View File

@ -267,7 +267,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
{ {
if (gRxVfo->IsAM) if (gRxVfo->AM_mode)
BK4819_SetAF(BK4819_AF_AM); BK4819_SetAF(BK4819_AF_AM);
else else
BK4819_SetAF(BK4819_AF_OPEN); BK4819_SetAF(BK4819_AF_OPEN);
@ -403,12 +403,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
} }
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
{ BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN);
if (gRxVfo->IsAM)
BK4819_SetAF(BK4819_AF_AM);
else
BK4819_SetAF(BK4819_AF_OPEN);
}
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode) if (gFmRadioMode)

Binary file not shown.

Binary file not shown.

View File

@ -46,7 +46,7 @@ void FUNCTION_Init(void)
{ {
gCurrentCodeType = gSelectedCodeType; gCurrentCodeType = gSelectedCodeType;
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (gCssScanMode == CSS_SCAN_MODE_OFF)
gCurrentCodeType = gRxVfo->IsAM ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType; gCurrentCodeType = gRxVfo->AM_mode ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType;
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else

67
radio.c
View File

@ -33,6 +33,7 @@
#include "misc.h" #include "misc.h"
#include "radio.h" #include "radio.h"
#include "settings.h" #include "settings.h"
#include "ui/menu.h"
VFO_Info_t *gTxVfo; VFO_Info_t *gTxVfo;
VFO_Info_t *gRxVfo; VFO_Info_t *gRxVfo;
@ -135,10 +136,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t Band, uint32
#endif #endif
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz))
{ pInfo->AM_mode = 1;
pInfo->AM_CHANNEL_MODE = true;
pInfo->IsAM = true;
}
RADIO_ConfigureSquelchAndOutputPower(pInfo); RADIO_ConfigureSquelchAndOutputPower(pInfo);
} }
@ -220,8 +218,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
Band = Attributes & MR_CH_BAND_MASK; Band = Attributes & MR_CH_BAND_MASK;
if (Band > BAND7_470MHz) if (Band > BAND7_470MHz)
{ {
// Band = BAND6_400MHz; Band = BAND6_400MHz;
Band = FREQUENCY_GetBand(gEeprom.ScreenChannel[VFO]); // 111 bug fix, or have I broke it ? // Band = FREQUENCY_GetBand(gEeprom.ScreenChannel[VFO]); // 1of11 bug fix, or have I broke it ?
} }
if (IS_MR_CHANNEL(Channel)) if (IS_MR_CHANNEL(Channel))
@ -251,13 +249,15 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
uint8_t Tmp; uint8_t Tmp;
uint8_t Data[8]; uint8_t Data[8];
// ***************
EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data)); EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data));
Tmp = Data[3] & 0x0F; Tmp = Data[3] & 0x0F;
if (Tmp > 2) if (Tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB)
Tmp = 0; Tmp = 0;
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = Tmp; gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = Tmp;
gEeprom.VfoInfo[VFO].AM_CHANNEL_MODE = !!(Data[3] & 0x10); gEeprom.VfoInfo[VFO].AM_mode = (Data[3] >> 4) & 1u;
Tmp = Data[6]; Tmp = Data[6];
if (Tmp >= ARRAY_SIZE(StepFrequencyTable)) if (Tmp >= ARRAY_SIZE(StepFrequencyTable))
@ -266,7 +266,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
gEeprom.VfoInfo[VFO].StepFrequency = StepFrequencyTable[Tmp]; gEeprom.VfoInfo[VFO].StepFrequency = StepFrequencyTable[Tmp];
Tmp = Data[7]; Tmp = Data[7];
if (Tmp > 10) if (Tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1))
Tmp = 0; Tmp = 0;
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = Tmp; gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = Tmp;
@ -283,13 +283,13 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
break; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
if (Tmp >= 50) if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
Tmp = 0; Tmp = 0;
break; break;
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
if (Tmp >= 104) if (Tmp > (ARRAY_SIZE(DCS_Options) - 1))
Tmp = 0; Tmp = 0;
break; break;
} }
@ -305,13 +305,13 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
break; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
if (Tmp >= 50) if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1))
Tmp = 0; Tmp = 0;
break; break;
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
if (Tmp >= 104) if (Tmp > (ARRAY_SIZE(DCS_Options) - 1))
Tmp = 0; Tmp = 0;
break; break;
} }
@ -344,6 +344,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = ((Data[5] >> 1) & 3u); gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = ((Data[5] >> 1) & 3u);
} }
// ***************
struct struct
{ {
uint32_t Frequency; uint32_t Frequency;
@ -357,6 +359,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
if (Info.Offset >= 100000000) if (Info.Offset >= 100000000)
Info.Offset = 1000000; Info.Offset = 1000000;
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = Info.Offset; gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = Info.Offset;
// ***************
} }
Frequency = pRadio->freq_config_RX.Frequency; Frequency = pRadio->freq_config_RX.Frequency;
@ -410,16 +414,13 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
pConfig->Frequency = 43300000; pConfig->Frequency = 43300000;
} }
if (gEeprom.VfoInfo[VFO].AM_CHANNEL_MODE) if (gEeprom.VfoInfo[VFO].AM_mode)
{ { // freq/chan is in AM mode
gEeprom.VfoInfo[VFO].IsAM = true; gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = 0;
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = 0; gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use DTMF on SSB
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF;
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF; gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF;
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF;
} }
else
gEeprom.VfoInfo[VFO].IsAM = false;
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4; gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4;
@ -591,7 +592,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->IsAM && gSetting_AM_fix); // BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->AM_mode && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
#else #else
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
@ -647,7 +648,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif #endif
{ {
if (!gRxVfo->IsAM) if (gRxVfo->AM_mode == 0)
{ {
uint8_t CodeType = gSelectedCodeType; uint8_t CodeType = gSelectedCodeType;
uint8_t Code = gSelectedCode; uint8_t Code = gSelectedCode;
@ -722,15 +723,15 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && !gCurrentVfo->IsAM) if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0)
#else #else
if (gEeprom.VOX_SWITCH && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && !gCurrentVfo->IsAM) if (gEeprom.VOX_SWITCH && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0)
#endif #endif
#else #else
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gEeprom.VOX_SWITCH && !gFmRadioMode && !gCurrentVfo->IsAM) if (gEeprom.VOX_SWITCH && !gFmRadioMode && gCurrentVfo->AM_mode == 0)
#else #else
if (gEeprom.VOX_SWITCH && !gCurrentVfo->IsAM) if (gEeprom.VOX_SWITCH && gCurrentVfo->AM_mode == 0)
#endif #endif
#endif #endif
{ {
@ -742,13 +743,13 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
// RX expander // RX expander
BK4819_SetCompander((!gRxVfo->IsAM && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0); BK4819_SetCompander((gRxVfo->AM_mode == 0 && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0);
#endif #endif
#if 0 #if 0
// there's no reason the DTMF decoder can't be used in AM RX mode too // there's no reason the DTMF decoder can't be used in AM RX mode too
// aircraft comms use it on HF (AM and SSB) // aircraft comms use it on HF (AM and SSB)
if (gRxVfo->IsAM || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)) if (gRxVfo->AM_mode || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED))
{ {
BK4819_DisableDTMF(); BK4819_DisableDTMF();
} }
@ -841,7 +842,7 @@ void RADIO_SetTxParameters(void)
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->IsAM && gSetting_AM_fix); // BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->AM_mode && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
#else #else
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
@ -853,7 +854,7 @@ void RADIO_SetTxParameters(void)
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
// TX compressor // TX compressor
BK4819_SetCompander((!gRxVfo->IsAM && (gRxVfo->Compander == 1 || gRxVfo->Compander >= 3)) ? gRxVfo->Compander : 0); BK4819_SetCompander((gRxVfo->AM_mode == 0 && (gRxVfo->Compander == 1 || gRxVfo->Compander >= 3)) ? gRxVfo->Compander : 0);
#endif #endif
BK4819_PrepareTransmit(); BK4819_PrepareTransmit();
@ -953,7 +954,7 @@ void RADIO_PrepareTX(void)
#endif #endif
{ {
#ifndef ENABLE_TX_WHEN_AM #ifndef ENABLE_TX_WHEN_AM
if (gCurrentVfo->IsAM) if (gCurrentVfo->AM_mode)
{ // not allowed to TX if in AM mode { // not allowed to TX if in AM mode
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }

View File

@ -136,8 +136,7 @@ typedef struct VFO_Info_t
uint8_t BUSY_CHANNEL_LOCK; uint8_t BUSY_CHANNEL_LOCK;
uint8_t AM_CHANNEL_MODE; uint8_t AM_mode;
bool IsAM;
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
uint8_t Compander; uint8_t Compander;

View File

@ -208,7 +208,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
State[0] = pVFO->freq_config_RX.Code; State[0] = pVFO->freq_config_RX.Code;
State[1] = pVFO->freq_config_TX.Code; State[1] = pVFO->freq_config_TX.Code;
State[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType; State[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
State[3] = (pVFO->AM_CHANNEL_MODE << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION; State[3] = ((pVFO->AM_mode & 1u) << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
State[4] = 0 State[4] = 0
| (pVFO->BUSY_CHANNEL_LOCK << 4) | (pVFO->BUSY_CHANNEL_LOCK << 4)
| (pVFO->OUTPUT_POWER << 2) | (pVFO->OUTPUT_POWER << 2)

View File

@ -467,7 +467,7 @@ void UI_DisplayMain(void)
// ************ // ************
String[0] = '\0'; String[0] = '\0';
if (gEeprom.VfoInfo[vfo_num].IsAM) if (gEeprom.VfoInfo[vfo_num].AM_mode)
{ // show the AM symbol { // show the AM symbol
strcpy(String, "AM"); strcpy(String, "AM");
} }
@ -526,7 +526,7 @@ void UI_DisplayMain(void)
{ // we're free to use the middle empty line for something { // we're free to use the middle empty line for something
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
if (gSetting_AM_fix && gEeprom.VfoInfo[gEeprom.RX_CHANNEL].IsAM) if (gSetting_AM_fix && gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode)
{ {
switch (gCurrentFunction) switch (gCurrentFunction)
{ {