Reduction in magic numbers.

This commit is contained in:
Dual Tachyon 2023-08-20 20:04:40 +01:00
parent 697360b103
commit 85b67d4874
6 changed files with 37 additions and 19 deletions

View File

@ -398,7 +398,7 @@ void BOARD_EEPROM_Init(void)
if (Data[2] < 3) {
gEeprom.CROSS_BAND_RX_TX = Data[2];
} else {
gEeprom.CROSS_BAND_RX_TX = 0;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
}
if (Data[3] < 5) {
gEeprom.BATTERY_SAVE = Data[3];
@ -408,7 +408,7 @@ void BOARD_EEPROM_Init(void)
if (Data[4] < 3) {
gEeprom.DUAL_WATCH = Data[4];
} else {
gEeprom.DUAL_WATCH = 1;
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A;
}
if (Data[5] < 6) {
gEeprom.BACKLIGHT = Data[5];

4
gui.c
View File

@ -252,10 +252,10 @@ void GUI_DisplayStatusLine(void)
if (gEeprom.VOX_SWITCH) {
memcpy(gStatusLine + 71, BITMAP_VOX, sizeof(BITMAP_VOX));
}
if (gEeprom.CROSS_BAND_RX_TX != 0) {
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) {
memcpy(gStatusLine + 58, BITMAP_WX, sizeof(BITMAP_WX));
}
if (gEeprom.DUAL_WATCH != 0) {
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
memcpy(gStatusLine + 45, BITMAP_TDR, sizeof(BITMAP_TDR));
}
if (gEeprom.KEYPAD_TONE != 0) {

View File

@ -69,10 +69,10 @@ void HELPER_CheckBootKey(uint8_t KeyType)
g_2000044C = 0x39;
gF_LOCK = 1;
} else if (KeyType == 2) {
gEeprom.DUAL_WATCH = 0;
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF;
gEeprom.BATTERY_SAVE = 0;
gEeprom.VOX_SWITCH = false;
gEeprom.CROSS_BAND_RX_TX = 0;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
gEeprom.AUTO_KEYPAD_LOCK = false;
gEeprom.KEY_1_SHORT_PRESS_ACTION = 0;
gEeprom.KEY_1_LONG_PRESS_ACTION = 0;

22
radio.c
View File

@ -146,11 +146,11 @@ void RADIO_ConfigureChannel(uint8_t RadioNum, uint32_t Arg)
if (ChNum < 217) {
if (ChNum >= 207) {
RADIO_InitInfo(pRadio, gEeprom.EEPROM_0E80_0E83[RadioNum], 2, NoaaFrequencyTable[ChNum - 207]);
if (gEeprom.CROSS_BAND_RX_TX == 0) {
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) {
return;
}
g_2000036F = 1;
gEeprom.CROSS_BAND_RX_TX = 0;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
return;
}
if (ChNum < 200) {
@ -429,19 +429,19 @@ void RADIO_ApplyOffset(RADIO_Info_t *pInfo)
void RADIO_ConfigureTX(void)
{
if (gEeprom.CROSS_BAND_RX_TX == 2) { // == CHAN B
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) {
gEeprom.TX_CHANNEL = 1;
} else if (gEeprom.CROSS_BAND_RX_TX == 1) { // == CHAN A
} else if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A) {
gEeprom.TX_CHANNEL = 0;
} else if (gEeprom.DUAL_WATCH == 2) { // == CHAN B
} else if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) {
gEeprom.TX_CHANNEL = 1;
} else if (gEeprom.DUAL_WATCH == 1) { // == CHAN A
} else if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A) {
gEeprom.TX_CHANNEL = 0;
}
gTxRadioInfo = &gEeprom.RadioInfo[gEeprom.TX_CHANNEL];
gEeprom.RX_CHANNEL = gEeprom.TX_CHANNEL;
if (gEeprom.CROSS_BAND_RX_TX != 0) { // != OFF
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) {
if (gEeprom.TX_CHANNEL == 0) {
gEeprom.RX_CHANNEL = 1;
} else {
@ -456,7 +456,7 @@ void RADIO_ConfigureTX(void)
void RADIO_ConfigureCrossTX(void)
{
gCrossTxRadioInfo = gInfoCHAN_A;
if (gEeprom.CROSS_BAND_RX_TX != 0) { // != OFF
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) {
gCrossTxRadioInfo = &gEeprom.RadioInfo[gEeprom.TX_CHANNEL];
}
}
@ -581,7 +581,7 @@ void RADIO_ConfigureNOAA(void)
g_2000036F = 1;
if (gEeprom.NOAA_AUTO_SCAN) {
if (gEeprom.DUAL_WATCH != 0) {
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
if (gEeprom.EEPROM_0E80_0E83[0] < 207) {
if (gEeprom.EEPROM_0E80_0E83[1] < 207) {
gIsNoaaMode = false;
@ -662,7 +662,7 @@ void RADIO_SomethingElse(uint8_t Arg)
uint8_t Channel;
Channel = gEeprom.RX_CHANNEL;
if (gEeprom.CROSS_BAND_RX_TX != 0) {
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) {
Channel = gEeprom.TX_CHANNEL;
}
g_20000371[Channel] = Arg;
@ -674,7 +674,7 @@ void RADIO_SomethingElse(uint8_t Arg)
void RADIO_SomethingWithTransmit(void)
{
if (gEeprom.DUAL_WATCH != 0) {
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
g_2000033A = 360;
gSystickFlag7 = 0;
if (g_2000041F == 0) {

View File

@ -62,7 +62,7 @@ void SystickHandler(void)
gBatterySaveCountdownExpired = true;
}
}
if (gCurrentStep == 0 && g_20000381 == 0 && gEeprom.DUAL_WATCH != 0) {
if (gCurrentStep == 0 && g_20000381 == 0 && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
if (gCurrentFunction != FUNCTION_2 && gCurrentFunction != FUNCTION_TRANSMIT) {
if (gCurrentFunction != FUNCTION_4) {
if (g_2000033A != 0) {
@ -75,7 +75,7 @@ void SystickHandler(void)
}
}
if (gCurrentStep == 0 && g_20000381 == 0 && gEeprom.DUAL_WATCH == 0) {
if (gCurrentStep == 0 && g_20000381 == 0 && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) {
if (gIsNoaaMode && gCurrentFunction != FUNCTION_2 && gCurrentFunction != FUNCTION_TRANSMIT) {
if (gCurrentFunction != FUNCTION_4) {
if (g_20000356 != 0) {

View File

@ -35,6 +35,24 @@ enum {
F_LOCK_438 = 5U,
};
enum {
SCAN_RESUME_TO = 0U,
SCAN_RESUME_CO = 1U,
SCAN_RESUME_SE = 2U,
};
enum {
CROSS_BAND_OFF = 0U,
CROSS_BAND_CHAN_A = 1U,
CROSS_BAND_CHAN_B = 2U,
};
enum {
DUAL_WATCH_OFF = 0U,
DUAL_WATCH_CHAN_A = 1U,
DUAL_WATCH_CHAN_B = 2U,
};
typedef struct {
uint8_t EEPROM_0E80_0E83[2];
uint8_t EEPROM_0E82_0E85[2];