Skip to content

Commit c7745d7

Browse files
committed
Force channel-only mode by disabling VFO access
1 parent 876ab82 commit c7745d7

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed

board.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ void BOARD_EEPROM_Init(void)
532532
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
533533
gEeprom.BACKLIGHT = (Data[5] < 6) ? Data[5] : 5;
534534
gEeprom.TAIL_NOTE_ELIMINATION = (Data[6] < 2) ? Data[6] : true;
535-
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;
535+
gEeprom.VFO_OPEN = false;
536536

537537
// 0E80..0E87
538538
EEPROM_ReadBuffer(0x0E80, Data, 8);
@@ -685,8 +685,10 @@ void BOARD_EEPROM_Init(void)
685685
gSetting_350EN = (Data[5] < 2) ? Data[5] : true;
686686
gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true;
687687

688-
if (!gEeprom.VFO_OPEN) {
688+
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0])) {
689689
gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0];
690+
}
691+
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1])) {
690692
gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1];
691693
}
692694

@@ -776,4 +778,3 @@ void BOARD_FactoryReset(bool bIsAll)
776778
}
777779
}
778780
}
779-

radio.c

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,28 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Configure)
166166
}
167167
#endif
168168
if (IS_MR_CHANNEL(Channel)) {
169-
Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO);
170-
if (Channel == 0xFF) {
171-
Channel = gEeprom.FreqChannel[VFO];
172-
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
169+
uint8_t NextChannel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO);
170+
171+
if (NextChannel == 0xFF) {
172+
if (gEeprom.VFO_OPEN) {
173+
Channel = gEeprom.FreqChannel[VFO];
174+
gEeprom.ScreenChannel[VFO] = Channel;
175+
} else {
176+
NextChannel = gEeprom.MrChannel[VFO];
177+
if (!IS_MR_CHANNEL(NextChannel) || gMR_ChannelAttributes[NextChannel] == 0xFF) {
178+
NextChannel = RADIO_FindNextChannel(MR_CHANNEL_FIRST, RADIO_CHANNEL_UP, false, VFO);
179+
if (NextChannel == 0xFF) {
180+
NextChannel = MR_CHANNEL_FIRST;
181+
}
182+
}
183+
gEeprom.MrChannel[VFO] = NextChannel;
184+
gEeprom.ScreenChannel[VFO] = NextChannel;
185+
Channel = NextChannel;
186+
}
173187
} else {
174-
gEeprom.ScreenChannel[VFO] = Channel;
175-
gEeprom.MrChannel[VFO] = Channel;
188+
gEeprom.ScreenChannel[VFO] = NextChannel;
189+
gEeprom.MrChannel[VFO] = NextChannel;
190+
Channel = NextChannel;
176191
}
177192
}
178193
} else {
@@ -181,15 +196,25 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Configure)
181196

182197
Attributes = gMR_ChannelAttributes[Channel];
183198
if (Attributes == 0xFF) {
184-
uint8_t Index;
185-
186199
if (IS_MR_CHANNEL(Channel)) {
187-
Channel = gEeprom.FreqChannel[VFO];
188-
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
200+
uint8_t Fallback = RADIO_FindNextChannel(MR_CHANNEL_FIRST, RADIO_CHANNEL_UP, false, VFO);
201+
202+
if (Fallback != 0xFF && gMR_ChannelAttributes[Fallback] != 0xFF) {
203+
Channel = Fallback;
204+
gEeprom.ScreenChannel[VFO] = Fallback;
205+
gEeprom.MrChannel[VFO] = Fallback;
206+
Attributes = gMR_ChannelAttributes[Channel];
207+
} else {
208+
Channel = gEeprom.FreqChannel[VFO];
209+
gEeprom.ScreenChannel[VFO] = Channel;
210+
}
211+
}
212+
if (Attributes == 0xFF) {
213+
uint8_t Index = Channel - FREQ_CHANNEL_FIRST;
214+
215+
RADIO_InitInfo(pRadio, Channel, Index, gLowerLimitFrequencyBandTable[Index]);
216+
return;
189217
}
190-
Index = Channel - FREQ_CHANNEL_FIRST;
191-
RADIO_InitInfo(pRadio, Channel, Index, gLowerLimitFrequencyBandTable[Index]);
192-
return;
193218
}
194219

195220
Band = Attributes & MR_CH_BAND_MASK;
@@ -853,4 +878,3 @@ void RADIO_SendEndOfTransmission(void)
853878
}
854879
BK4819_ExitDTMF_TX(true);
855880
}
856-

settings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ void SETTINGS_SaveSettings(void)
101101
State[4] = gEeprom.DUAL_WATCH;
102102
State[5] = gEeprom.BACKLIGHT;
103103
State[6] = gEeprom.TAIL_NOTE_ELIMINATION;
104-
State[7] = gEeprom.VFO_OPEN;
104+
gEeprom.VFO_OPEN = false;
105+
State[7] = false;
105106

106107
EEPROM_WriteBuffer(0x0E78, State);
107108

@@ -267,4 +268,3 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool bUpdat
267268
gMR_ChannelAttributes[Channel] = Attributes;
268269
}
269270
}
270-

0 commit comments

Comments
 (0)