More improved channel checks.

This commit is contained in:
Dual Tachyon 2023-08-29 03:35:21 +01:00
parent f05df4f802
commit 5c0a732d88
7 changed files with 22 additions and 22 deletions

View File

@ -250,7 +250,7 @@ void FUN_0000773c(void)
gStepDirection = 0;
if (g_20000413 != 1) {
if (g_20000410 < 200) {
if (IS_MR_CHANNEL(g_20000410)) {
gEeprom.MrChannel[gEeprom.RX_CHANNEL] = g_20000414;
gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = Previous;
RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, 2);
@ -264,7 +264,7 @@ void FUN_0000773c(void)
return;
}
if (gInfoCHAN_A->CHANNEL_SAVE >= 200) {
if (!IS_MR_CHANNEL(gInfoCHAN_A->CHANNEL_SAVE)) {
RADIO_ApplyOffset(gInfoCHAN_A);
RADIO_ConfigureSquelchAndOutputPower(gInfoCHAN_A);
SETTINGS_SaveChannel(gInfoCHAN_A->CHANNEL_SAVE, gEeprom.RX_CHANNEL, gInfoCHAN_A, 1);
@ -1451,8 +1451,8 @@ void APP_ChangeStepDirectionMaybe(bool bFlag, int8_t Direction)
g_20000410 = gInfoCHAN_A->CHANNEL_SAVE;
g_20000415 = 0;
gStepDirection = Direction;
if (g_20000410 < 200) {
if (bFlag == 1) {
if (IS_MR_CHANNEL(g_20000410)) {
if (bFlag) {
g_20000414 = g_20000410;
}
FUN_00007dd4();

View File

@ -874,7 +874,7 @@ void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
gInputBoxIndex = 0;
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (Value < 200) {
if (IS_MR_CHANNEL(Value)) {
gAnotherVoiceID = Key;
gSubMenuSelection = Value;
return;

View File

@ -348,7 +348,7 @@ void BOARD_EEPROM_Init(void)
// 0E70..0E77
EEPROM_ReadBuffer(0x0E70, Data, 8);
if (Data[0] < 200) {
if (IS_MR_CHANNEL(Data[0])) {
gEeprom.CHAN_1_CALL = Data[0];
} else {
gEeprom.CHAN_1_CALL = 0;

12
radio.c
View File

@ -44,7 +44,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
uint8_t PriorityCh1;
uint8_t PriorityCh2;
if (Channel >= 200) {
if (!IS_MR_CHANNEL(Channel)) {
return false;
}
@ -90,9 +90,9 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan
for (i = 0; i < 200; i++) {
if (Channel == 0xFF) {
Channel = 199;
} else if (Channel >= 200) {
Channel = 0;
Channel = MR_CHANNEL_LAST;
} else if (Channel > MR_CHANNEL_LAST) {
Channel = MR_CHANNEL_FIRST;
}
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) {
return Channel;
@ -315,13 +315,13 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
if (Frequency - 10800000 < 2799991) {
gEeprom.VfoInfo[VFO].FREQUENCY_DEVIATION_SETTING = FREQUENCY_DEVIATION_OFF;
} else if (Channel >= 200) {
} else if (!IS_MR_CHANNEL(Channel)) {
Frequency = FREQUENCY_FloorToStep(gEeprom.VfoInfo[VFO].FREQUENCY_OF_DEVIATION, gEeprom.VfoInfo[VFO].StepFrequency, 0);
gEeprom.VfoInfo[VFO].FREQUENCY_OF_DEVIATION = Frequency;
}
RADIO_ApplyOffset(pRadio);
memset(gEeprom.VfoInfo[VFO].Name, 0, sizeof(gEeprom.VfoInfo[VFO].Name));
if (Channel < 200) {
if (IS_MR_CHANNEL(Channel)) {
// 16 bytes allocated but only 12 used
EEPROM_ReadBuffer(0x0F50 + (Channel * 0x10), gEeprom.VfoInfo[VFO].Name + 0, 8);
EEPROM_ReadBuffer(0x0F58 + (Channel * 0x10), gEeprom.VfoInfo[VFO].Name + 8, 2);

View File

@ -176,15 +176,15 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
OffsetMR = 0x0000 + (Channel * 16);
OffsetVFO = OffsetMR;
if (Channel >= 200) {
if (!IS_MR_CHANNEL(Channel)) {
if (VFO == 0) {
OffsetVFO = 0x0C80 + ((Channel - 200) * 32);
OffsetVFO = 0x0C80 + ((Channel - FREQ_CHANNEL_FIRST) * 32);
} else {
OffsetVFO = 0x0C90 + ((Channel - 200) * 32);
OffsetVFO = 0x0C90 + ((Channel - FREQ_CHANNEL_FIRST) * 32);
}
}
// Mode 2 == Delete
if (Mode == 2 || Channel >= 200) {
if (Mode == 2 || !IS_MR_CHANNEL(Channel)) {
uint32_t State32[2];
uint8_t State8[8];

View File

@ -148,7 +148,7 @@ void UI_DisplayMain(void)
}
// 0x8F3C
if (gEeprom.ScreenChannel[i] < 200) {
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) {
memcpy(pLine1 + 2, BITMAP_M, sizeof(BITMAP_M));
if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != i) {
NUMBER_ToDigits(gEeprom.ScreenChannel[i] + 1, String);
@ -217,7 +217,7 @@ void UI_DisplayMain(void)
if (gInputBoxIndex && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[i]) && gEeprom.TX_CHANNEL == i) {
UI_DisplayFrequency(gInputBox, 31, i * 4, true, false);
} else {
if (gEeprom.ScreenChannel[i] < 200) {
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) {
if (gEeprom.CHANNEL_DISPLAY_MODE == 2 && (gEeprom.VfoInfo[i].Name[0] == 0 || gEeprom.VfoInfo[i].Name[0] == 0xFF)) {
sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1);
UI_PrintString(String, 31, 112, i * 4, 8, true);
@ -239,7 +239,7 @@ void UI_DisplayMain(void)
NUMBER_ToDigits(gEeprom.VfoInfo[i].pDCS_Current->Frequency, String);
}
UI_DisplayFrequency(String, 31, i * 4, false, false);
if (gEeprom.ScreenChannel[i] < 200) {
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) {
const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[i]];
if (Attributes & MR_CH_SCANLIST1) {
memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList));
@ -275,7 +275,7 @@ void UI_DisplayMain(void)
NUMBER_ToDigits(gEeprom.VfoInfo[i].pDCS_Current->Frequency, String);
}
UI_DisplayFrequency(String, 31, i * 4, false, false);
if (gEeprom.ScreenChannel[i] < 200) {
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) {
const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[i]];
if (Attributes & MR_CH_SCANLIST1) {
memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList));

View File

@ -469,11 +469,11 @@ void UI_DisplayMenu(void)
UI_PrintString(String, 50, 127, 2, 8, 1);
} else {
UI_PrintString(String, 50, 127, 0, 8, 1);
if (gEeprom.SCANLIST_PRIORITY_CH1[i] < 200) {
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i])) {
sprintf(String, "PRI1:%d", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
UI_PrintString(String, 50, 127, 2, 8, 1);
}
if (gEeprom.SCANLIST_PRIORITY_CH2[i] < 200) {
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i])) {
sprintf(String, "PRI2:%d", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
UI_PrintString(String, 50, 127, 4, 8, 1);
}