From d180585e526c963fa0b27b5a92981e4ecd4b953a Mon Sep 17 00:00:00 2001 From: Dual Tachyon Date: Mon, 18 Sep 2023 20:53:19 +0100 Subject: [PATCH] Simplified logic to remove duplicate code. --- ui/main.c | 54 +++++++++++------------------------------------------- 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/ui/main.c b/ui/main.c index 800cd8f5..e3f64324 100644 --- a/ui/main.c +++ b/ui/main.c @@ -230,49 +230,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 (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) { - switch (gEeprom.CHANNEL_DISPLAY_MODE) { - case MDF_FREQUENCY: - if (gCurrentFunction == FUNCTION_TRANSMIT) { - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { - Channel = gEeprom.RX_CHANNEL; - } else { - Channel = gEeprom.TX_CHANNEL; - } - if (Channel == i) { - NUMBER_ToDigits(gEeprom.VfoInfo[i].pTX->Frequency, String); - } else { - NUMBER_ToDigits(gEeprom.VfoInfo[i].pRX->Frequency, String); - } - } else { - NUMBER_ToDigits(gEeprom.VfoInfo[i].pRX->Frequency, String); - } - UI_DisplayFrequency(String, 31, i * 4, false, false); - 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)); - } - if (Attributes & MR_CH_SCANLIST2) { - memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - } - } - UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); - break; - case MDF_CHANNEL: - sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); - UI_PrintString(String, 31, 112, i * 4, 8, true); - break; - case MDF_NAME: - if(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); - } else { - UI_PrintString(gEeprom.VfoInfo[i].Name, 31, 112, i * 4, 8, true); - } - break; - } - } else { + if (!IS_MR_CHANNEL(gEeprom.ScreenChannel[i]) || gEeprom.CHANNEL_DISPLAY_MODE == MDF_FREQUENCY) { if (gCurrentFunction == FUNCTION_TRANSMIT) { if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { Channel = gEeprom.RX_CHANNEL; @@ -298,6 +256,16 @@ void UI_DisplayMain(void) } } UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); + } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_CHANNEL) { + sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); + UI_PrintString(String, 31, 112, i * 4, 8, true); + } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) { + if(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); + } else { + UI_PrintString(gEeprom.VfoInfo[i].Name, 31, 112, i * 4, 8, true); + } } } }