Skip to content

Commit

Permalink
Rename RX_CHANNEL and TX_CHANNEL to RX_VFO and TX_VFO to be much less…
Browse files Browse the repository at this point in the history
… confusing
  • Loading branch information
OneOfEleven committed Oct 5, 2023
1 parent d632698 commit e042b21
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 98 deletions.
2 changes: 1 addition & 1 deletion app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void ACTION_Scan(bool bRestart)
#endif

// clear the other vfo's rssi level (to hide the antenna symbol)
gVFO_RSSI_bar_level[(gEeprom.RX_CHANNEL + 1) & 1u] = 0;
gVFO_RSSI_bar_level[(gEeprom.RX_VFO + 1) & 1u] = 0;

// let the user see DW is not active
gDualWatchActive = false;
Expand Down
44 changes: 22 additions & 22 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true;

updateRSSI(gEeprom.RX_CHANNEL);
updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true;
}

Expand All @@ -138,7 +138,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true;

updateRSSI(gEeprom.RX_CHANNEL);
updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true;
}
return;
Expand All @@ -160,7 +160,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true;

updateRSSI(gEeprom.RX_CHANNEL);
updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true;
}

Expand All @@ -178,7 +178,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING);
//gUpdateDisplay = true;

updateRSSI(gEeprom.RX_CHANNEL);
updateRSSI(gEeprom.RX_VFO);
gUpdateRSSI = true;
}
}
Expand Down Expand Up @@ -468,7 +468,7 @@ static void APP_HandleFunction(void)

void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
{
const unsigned int chan = gEeprom.RX_CHANNEL;
const unsigned int chan = gEeprom.RX_VFO;
// const unsigned int chan = gRxVfo->CHANNEL_SAVE;

if (gSetting_KILLED)
Expand Down Expand Up @@ -679,7 +679,7 @@ static void MR_NextChannel(void)
// dual watch is enabled - include the other VFO in the scan
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
chan = (gEeprom.RX_CHANNEL + 1) & 1u;
chan = (gEeprom.RX_VFO + 1) & 1u;
chan = gEeprom.ScreenChannel[chan];
if (IS_MR_CHANNEL(chan))
{
Expand Down Expand Up @@ -713,10 +713,10 @@ static void MR_NextChannel(void)

if (gNextMrChannel != prev_chan)
{
gEeprom.MrChannel[ gEeprom.RX_CHANNEL] = gNextMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gNextMrChannel;
gEeprom.MrChannel[ gEeprom.RX_VFO] = gNextMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = gNextMrChannel;

RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, VFO_CONFIGURE_RELOAD);
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
RADIO_SetupRegisters(true);

gUpdateDisplay = true;
Expand Down Expand Up @@ -749,20 +749,20 @@ static void DUALWATCH_Alternate(void)
if (gIsNoaaMode)
{
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
gEeprom.RX_CHANNEL = (gEeprom.RX_CHANNEL + 1) & 1;
gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1;
else
gEeprom.RX_CHANNEL = 0;
gEeprom.RX_VFO = 0;

gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL];
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO];

if (gEeprom.VfoInfo[0].CHANNEL_SAVE >= NOAA_CHANNEL_FIRST)
NOAA_IncreaseChannel();
}
else
#endif
{ // toggle between VFO's
gEeprom.RX_CHANNEL = (gEeprom.RX_CHANNEL + 1) & 1;
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL];
gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1;
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO];

if (!gDualWatchActive)
{ // let the user see DW is active
Expand Down Expand Up @@ -1250,7 +1250,7 @@ void APP_Update(void)
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI)
{ // dual watch mode, go back to sleep

updateRSSI(gEeprom.RX_CHANNEL);
updateRSSI(gEeprom.RX_VFO);

// go back to sleep

Expand Down Expand Up @@ -1410,9 +1410,9 @@ void APP_TimeSlice10ms(void)
#endif

#ifdef ENABLE_AM_FIX
// if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix)
// if (gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix)
if (gRxVfo->AM_mode && gSetting_AM_fix)
AM_fix_10ms(gEeprom.RX_CHANNEL);
AM_fix_10ms(gEeprom.RX_VFO);
#endif

if (UART_IsCommandAvailable())
Expand Down Expand Up @@ -1800,7 +1800,7 @@ void APP_TimeSlice500ms(void)
if (gCurrentFunction != FUNCTION_TRANSMIT)
{
if (gCurrentFunction != FUNCTION_POWER_SAVE)
updateRSSI(gEeprom.RX_CHANNEL);
updateRSSI(gEeprom.RX_VFO);

#ifdef ENABLE_FMRADIO
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF)
Expand Down Expand Up @@ -2110,10 +2110,10 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)

if (gFlagSaveChannel)
{
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL, gTxVfo, gFlagSaveChannel);
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gFlagSaveChannel);
gFlagSaveChannel = false;

RADIO_ConfigureChannel(gEeprom.TX_CHANNEL, VFO_CONFIGURE);
RADIO_ConfigureChannel(gEeprom.TX_VFO, VFO_CONFIGURE);
RADIO_SetupRegisters(true);

GUI_SelectNextDisplay(DISPLAY_MAIN);
Expand Down Expand Up @@ -2435,7 +2435,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld)
{
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL, gTxVfo, gRequestSaveChannel);
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel);

if (gScreenToDisplay != DISPLAY_SCANNER)
if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere
Expand All @@ -2460,7 +2460,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
RADIO_ConfigureChannel(1, gVfoConfigureMode);
}
else
RADIO_ConfigureChannel(gEeprom.TX_CHANNEL, gVfoConfigureMode);
RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode);

if (gRequestDisplayScreen == DISPLAY_INVALID)
gRequestDisplayScreen = DISPLAY_MAIN;
Expand Down
75 changes: 44 additions & 31 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
{
uint8_t Band;
uint8_t Vfo = gEeprom.TX_CHANNEL;
uint8_t Vfo = gEeprom.TX_VFO;

switch (Key)
{
Expand Down Expand Up @@ -99,7 +99,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A;
else
gEeprom.TX_CHANNEL = (Vfo + 1) & 1u;
gEeprom.TX_VFO = (Vfo + 1) & 1u;

gRequestSaveSettings = 1;
gFlagReconfigureVfos = true;
Expand All @@ -122,7 +122,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)

if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // swap to frequency mode
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL];
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif
Expand All @@ -131,7 +131,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break;
}

Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_CHANNEL], 1, false, 0);
Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 0);
if (Channel != 0xFF)
{ // swap to channel mode
gEeprom.ScreenChannel[Vfo] = Channel;
Expand Down Expand Up @@ -166,24 +166,24 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)

case KEY_5:
#ifdef ENABLE_NOAA

if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_CHANNEL];
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO];
}
else
{
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_CHANNEL];
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif
}
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;

#else
// toggle the selected channels scanlist setting

if (gScreenToDisplay != DISPLAY_SCANNER)
{
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
Expand All @@ -207,9 +207,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gFlagResetVfos = true;
}
}

#endif

break;

case KEY_6:
Expand All @@ -220,7 +220,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#ifdef ENABLE_VOX
ACTION_Vox();
#else


// TODO: make use of this function key

Expand Down Expand Up @@ -305,7 +305,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (!gWasFKeyPressed)
{ // F-key wasn't pressed

const uint8_t Vfo = gEeprom.TX_CHANNEL;
const uint8_t Vfo = gEeprom.TX_VFO;

gKeyInputCountdown = key_input_timeout_500ms;

Expand Down Expand Up @@ -554,31 +554,44 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gUpdateStatus = true;

#ifdef ENABLE_COPY_CHAN_TO_VFO

if (gEeprom.VFO_OPEN &&
gScanState == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF)
{ // copy channel to VFO

const unsigned int vfo = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL;

//const unsigned int vfo = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
unsigned int vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
vfo = 1;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
vfo = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
vfo = 0;
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
vfo = (vfo + 1) & 1u;

if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
{
{ // swap to the VFO

const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;

gEeprom.ScreenChannel[vfo] = channel;
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel;

// swap to the VFO
gEeprom.TX_CHANNEL = vfo;
gEeprom.RX_CHANNEL = vfo;
gEeprom.TX_VFO = vfo;

RADIO_SelectVfos();
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
RADIO_SetupRegisters(true);
//SETTINGS_SaveChannel(channel, gEeprom.RX_CHANNEL, gRxVfo, 1);

//SETTINGS_SaveChannel(channel, gEeprom.RX_VFO, gRxVfo, 1);

gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;

gUpdateStatus = true;
Expand All @@ -589,7 +602,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
}

#endif
}
}
Expand Down Expand Up @@ -697,7 +710,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)

static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_CHANNEL];
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];

if (bKeyHeld || !bKeyPressed)
{
Expand Down Expand Up @@ -762,8 +775,8 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (Channel == Next)
return;

gEeprom.MrChannel[gEeprom.TX_CHANNEL] = Next;
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Next;
gEeprom.MrChannel[gEeprom.TX_VFO] = Next;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Next;

if (!bKeyHeld)
{
Expand All @@ -776,9 +789,9 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
#ifdef ENABLE_NOAA
else
{
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
gEeprom.NoaaChannel[gEeprom.TX_CHANNEL] = Channel;
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Channel;
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
}
#endif

Expand Down
10 changes: 5 additions & 5 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void MENU_AcceptSetting(void)
#if 0
gEeprom.MrChannel[0] = gSubMenuSelection;
#else
gEeprom.MrChannel[gEeprom.TX_CHANNEL] = gSubMenuSelection;
gEeprom.MrChannel[gEeprom.TX_VFO] = gSubMenuSelection;
#endif
gRequestSaveChannel = 2;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
Expand All @@ -492,7 +492,7 @@ void MENU_AcceptSetting(void)
// save the channel name
memset(gTxVfo->Name, 0, sizeof(gTxVfo->Name));
memmove(gTxVfo->Name, edit, 10);
SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_CHANNEL, gTxVfo, 3);
SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_VFO, gTxVfo, 3);
gFlagReconfigureVfos = true;
return;

Expand Down Expand Up @@ -921,12 +921,12 @@ void MENU_ShowCurrentSetting(void)
#if 0
gSubMenuSelection = gEeprom.MrChannel[0];
#else
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_CHANNEL];
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO];
#endif
break;

case MENU_MEM_NAME:
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_CHANNEL];
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO];
break;

case MENU_SAVE:
Expand Down Expand Up @@ -1106,7 +1106,7 @@ void MENU_ShowCurrentSetting(void)
#if 0
gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[0], 1, false, 1);
#else
gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_CHANNEL], 1, false, 1);
gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 1);
#endif
break;

Expand Down
Loading

0 comments on commit e042b21

Please sign in to comment.