diff --git a/app/app.c b/app/app.c index 20d33f99..db1a20ef 100644 --- a/app/app.c +++ b/app/app.c @@ -611,11 +611,11 @@ 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) { @@ -623,7 +623,10 @@ static void MR_NextChannel(void) { gPreviousMrChannel = gNextMrChannel; if (RADIO_CheckValidChannel(Ch1, false, 0)) - gNextMrChannel = Ch1; + { + gNextMrChannel = Ch1; +// goto Skip; + } else gCurrentScanList = 1; } @@ -631,7 +634,10 @@ static void MR_NextChannel(void) if (gCurrentScanList == 1) { if (RADIO_CheckValidChannel(Ch2, false, 0)) - gNextMrChannel = Ch2; + { + gNextMrChannel = Ch2; +// goto Skip; + } else gCurrentScanList = 2; } diff --git a/app/menu.c b/app/menu.c index 44730ec2..60108265 100644 --- a/app/menu.c +++ b/app/menu.c @@ -323,7 +323,7 @@ void MENU_AcceptSetting(void) gRequestSaveChannel = 1; return; } - gSubMenuSelection = gTxVfo->STEP_SETTING; + gTxVfo->STEP_SETTING = gSubMenuSelection; return; case MENU_TXP: diff --git a/firmware.bin b/firmware.bin index 8c42281a..648cd590 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index d6d0d2f1..c62223c1 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/settings.c b/settings.c index a2a9830c..56cd4054 100644 --- a/settings.c +++ b/settings.c @@ -30,7 +30,7 @@ EEPROM_Config_t gEeprom; void SETTINGS_SaveFM(void) { unsigned int i; - + struct { uint16_t Frequency; @@ -38,12 +38,12 @@ EEPROM_Config_t gEeprom; 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]); @@ -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]; @@ -198,27 +198,26 @@ 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); @@ -226,17 +225,19 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, { #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 } @@ -282,7 +283,8 @@ 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); } @@ -290,7 +292,8 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) // { // 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); // }