Skip to content

Commit

Permalink
Fixed menu step bug - never worked !
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Sep 28, 2023
1 parent 8652594 commit 1f1a10b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 39 deletions.
20 changes: 13 additions & 7 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,27 +611,33 @@ static void FREQ_NextChannel(void)

static void MR_NextChannel(void)
{
uint8_t Ch;
uint8_t Ch1 = gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT];
uint8_t Ch2 = gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT];
uint8_t PreviousCh = gNextMrChannel;
bool bEnabled = gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT];
const uint8_t PreviousCh = gNextMrChannel;
const uint8_t Ch1 = gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT];
const uint8_t Ch2 = gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT];
const bool bEnabled = gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT];
uint8_t Ch;

if (bEnabled)
{
if (gCurrentScanList == 0)
{
gPreviousMrChannel = gNextMrChannel;
if (RADIO_CheckValidChannel(Ch1, false, 0))
gNextMrChannel = Ch1;
{
gNextMrChannel = Ch1;
// goto Skip;
}
else
gCurrentScanList = 1;
}

if (gCurrentScanList == 1)
{
if (RADIO_CheckValidChannel(Ch2, false, 0))
gNextMrChannel = Ch2;
{
gNextMrChannel = Ch2;
// goto Skip;
}
else
gCurrentScanList = 2;
}
Expand Down
2 changes: 1 addition & 1 deletion app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1;
return;
}
gSubMenuSelection = gTxVfo->STEP_SETTING;
gTxVfo->STEP_SETTING = gSubMenuSelection;
return;

case MENU_TXP:
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
65 changes: 34 additions & 31 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ EEPROM_Config_t gEeprom;
void SETTINGS_SaveFM(void)
{
unsigned int i;

struct
{
uint16_t Frequency;
uint8_t Channel;
bool IsChannelSelected;
uint8_t Padding[4];
} State;

memset(&State, 0xFF, sizeof(State));
State.Channel = gEeprom.FM_SelectedChannel;
State.Frequency = gEeprom.FM_SelectedFrequency;
State.IsChannelSelected = gEeprom.FM_IsMrMode;

EEPROM_WriteBuffer(0x0E88, &State);
for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
Expand All @@ -57,7 +57,7 @@ void SETTINGS_SaveVfoIndices(void)
#ifndef ENABLE_NOAA
EEPROM_ReadBuffer(0x0E80, State, sizeof(State));
#endif

State[0] = gEeprom.ScreenChannel[0];
State[1] = gEeprom.MrChannel[0];
State[2] = gEeprom.FreqChannel[0];
Expand Down Expand Up @@ -198,45 +198,46 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,

if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
{ // copy VFO to a channel

uint32_t State32[2];
uint8_t State8[8];

State32[0] = pVFO->freq_config_RX.Frequency;
State32[1] = pVFO->TX_OFFSET_FREQUENCY;
EEPROM_WriteBuffer(OffsetVFO + 0, State32);

State8[0] = pVFO->freq_config_RX.Code;
State8[1] = pVFO->freq_config_TX.Code;
State8[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType;
State8[3] = (pVFO->AM_CHANNEL_MODE << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION;
State8[4] = 0

uint8_t State[8];

((uint32_t *)State)[0] = pVFO->freq_config_RX.Frequency;
((uint32_t *)State)[1] = pVFO->TX_OFFSET_FREQUENCY;
EEPROM_WriteBuffer(OffsetVFO + 0, State);

State[0] = pVFO->freq_config_RX.Code;
State[1] = pVFO->freq_config_TX.Code;
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[4] = 0
| (pVFO->BUSY_CHANNEL_LOCK << 4)
| (pVFO->OUTPUT_POWER << 2)
| (pVFO->CHANNEL_BANDWIDTH << 1)
| (pVFO->FrequencyReverse << 0);
State8[5] = (pVFO->DTMF_PTT_ID_TX_MODE << 1) | pVFO->DTMF_DECODING_ENABLE;
State8[6] = pVFO->STEP_SETTING;
State8[7] = pVFO->SCRAMBLING_TYPE;
EEPROM_WriteBuffer(OffsetVFO + 8, State8);
State[5] = (pVFO->DTMF_PTT_ID_TX_MODE << 1) | (pVFO->DTMF_DECODING_ENABLE < 0);
State[6] = pVFO->STEP_SETTING;
State[7] = pVFO->SCRAMBLING_TYPE;
EEPROM_WriteBuffer(OffsetVFO + 8, State);

SETTINGS_UpdateChannel(Channel, pVFO, true);

if (IS_MR_CHANNEL(Channel))
{
#ifndef KEEP_MEM_NAME
// clear/reset the channel name
memset(&State8, 0xFF, sizeof(State8));
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State8);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State8);
//memset(&State, 0xFF, sizeof(State));
memset(&State, 0x00, sizeof(State)); // follow the QS way
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
#else
if (Mode >= 3)
{ // save the channel name
memmove(State8, pVFO->Name + 0, 8);
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State8);
memset(State8, 0xFF, sizeof(State8));
memmove(State8, pVFO->Name + 8, 2);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State8);
memmove(State, pVFO->Name + 0, 8);
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
//memset(State, 0xFF, sizeof(State));
memset(State, 0x00, sizeof(State)); // follow the QS way
memmove(State, pVFO->Name + 8, 2);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
}
#endif
}
Expand Down Expand Up @@ -282,15 +283,17 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
const uint16_t OffsetMR = Channel * 16;
if (!keep)
{ // clear/reset the channel name
memset(&State, 0xFF, sizeof(State));
//memset(&State, 0xFF, sizeof(State));
memset(&State, 0x00, sizeof(State)); // follow the QS way
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
}
// else
// { // update the channel name
// memmove(State, pVFO->Name + 0, 8);
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
// memset(State, 0xFF, sizeof(State));
// //memset(State, 0xFF, sizeof(State));
// memset(State, 0x00, sizeof(State)); // follow the QS way
// memmove(State, pVFO->Name + 8, 2);
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
// }
Expand Down

0 comments on commit 1f1a10b

Please sign in to comment.