From ae6fb50e10eddb9e3d7eabe2e335b48835355d95 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Fri, 28 Jun 2024 05:13:24 +0200 Subject: [PATCH] Scanlist refactoring --- app/main.c | 2 +- bitmaps.c | 98 ++++++++++++++++++++++------------------------------- bitmaps.h | 11 +++--- radio.c | 8 ++--- ui/main.c | 16 +++------ ui/menu.c | 6 ++-- ui/status.c | 22 +++++++----- 7 files changed, 70 insertions(+), 93 deletions(-) diff --git a/app/main.c b/app/main.c index 3cd1258..25273e9 100644 --- a/app/main.c +++ b/app/main.c @@ -558,7 +558,7 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) #ifdef ENABLE_FEAT_F4HWN // Exclude work with list 1, 2, 3 or all list - if(gScanStateDir != SCAN_OFF && (gEeprom.SCAN_LIST_DEFAULT < 3 || gEeprom.SCAN_LIST_DEFAULT == 4)) + if(gScanStateDir != SCAN_OFF && (gEeprom.SCAN_LIST_DEFAULT > 0 || gEeprom.SCAN_LIST_DEFAULT < 5)) { if(FUNCTION_IsRx()) { diff --git a/bitmaps.c b/bitmaps.c index 92b6eee..3baabd7 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -159,78 +159,60 @@ const uint8_t BITMAP_VFO_NotDefault[8] = 0b00001000 }; -const uint8_t BITMAP_ScanList1[7] = -{ // '1' symbol - 0b01111111, - 0b01111111, - 0b01111011, - 0b01000001, - 0b01111111, - 0b01111111, - 0b01111111, -}; - -const uint8_t BITMAP_ScanList2[7] = -{ // '2' symbol - 0b01111111, - 0b01111111, - 0b01001101, - 0b01010101, - 0b01011011, - 0b01111111, - 0b01111111, -}; - -const uint8_t BITMAP_ScanList3[7] = -{ // '3' symbol - 0b01111111, - 0b01111111, - 0b01011101, - 0b01010101, - 0b01101011, - 0b01111111, - 0b01111111, -}; - -const uint8_t BITMAP_ScanList4[7] = +const uint8_t BITMAP_ScanList0[5] = { // '0' symbol - 0b01111111, 0b01111111, 0b01000011, 0b01011101, 0b01100001, 0b01111111, +}; + +const uint8_t BITMAP_ScanList1[5] = +{ // '1' symbol + 0b01111111, + 0b01111011, + 0b01000001, + 0b01111111, 0b01111111, }; -const uint8_t BITMAP_ScanList5[11] = -{ - // 'All List' symbol +const uint8_t BITMAP_ScanList2[5] = +{ // '2' symbol + 0b01111111, + 0b01001101, + 0b01010101, + 0b01011011, 0b01111111, - 0b01100011, - 0b01011101, - 0b01011101, - 0b01101011, - 0b01110111, - 0b01101011, - 0b01011101, - 0b01011101, - 0b01100011, - 0b01111111 }; -const uint8_t BITMAP_ScanList6[9] = +const uint8_t BITMAP_ScanList3[5] = +{ // '3' symbol + 0b01111111, + 0b01011101, + 0b01010101, + 0b01101011, + 0b01111111, +}; + +const uint8_t BITMAP_ScanListAll[15] = { // 'All' symbol - 0b00011100, - 0b00100010, - 0b00100010, - 0b00010100, - 0b00001000, - 0b00010100, - 0b00100010, - 0b00100010, - 0b00011100 + 0b01111111, + 0b01000011, + 0b01110101, + 0b01000011, + 0b01111111, + 0b01111111, + 0b01000001, + 0b01011111, + 0b01011111, + 0b01111111, + 0b01111111, + 0b01000001, + 0b01011111, + 0b01011111, + 0b01111111, }; const uint8_t BITMAP_compand[6] = diff --git a/bitmaps.h b/bitmaps.h index 3236161..d2a03fa 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -30,12 +30,11 @@ extern const uint8_t BITMAP_Ready[7]; extern const uint8_t BITMAP_Antenna[5]; extern const uint8_t BITMAP_VFO_Default[8]; extern const uint8_t BITMAP_VFO_NotDefault[8]; -extern const uint8_t BITMAP_ScanList1[7]; -extern const uint8_t BITMAP_ScanList2[7]; -extern const uint8_t BITMAP_ScanList3[7]; -extern const uint8_t BITMAP_ScanList4[7]; -extern const uint8_t BITMAP_ScanList5[11]; -extern const uint8_t BITMAP_ScanList6[9]; +extern const uint8_t BITMAP_ScanList0[5]; +extern const uint8_t BITMAP_ScanList1[5]; +extern const uint8_t BITMAP_ScanList2[5]; +extern const uint8_t BITMAP_ScanList3[5]; +extern const uint8_t BITMAP_ScanListAll[15]; extern const uint8_t BITMAP_compand[6]; #ifndef ENABLE_CUSTOM_MENU_LAYOUT diff --git a/radio.c b/radio.c index fa3515e..a7bf080 100644 --- a/radio.c +++ b/radio.c @@ -80,19 +80,19 @@ bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanL //LogUart(str); - if(scanList == 0 && att.scanlist1 != 1) + if(scanList == 0 && (att.scanlist1 == 1 || att.scanlist2 == 1 || att.scanlist3 == 1)) { return false; } - else if(scanList == 1 && att.scanlist2 != 1) + else if(scanList == 1 && att.scanlist1 != 1) { return false; } - else if(scanList == 2 && att.scanlist3 != 1) + else if(scanList == 2 && att.scanlist2 != 1) { return false; } - else if(scanList == 3 && (att.scanlist1 == 1 || att.scanlist2 == 1 || att.scanlist3 == 1)) + else if(scanList == 3 && att.scanlist3 != 1) { return false; } diff --git a/ui/main.c b/ui/main.c index bda93f9..74272c6 100644 --- a/ui/main.c +++ b/ui/main.c @@ -909,22 +909,22 @@ void UI_DisplayMain(void) if (att.scanlist1) { - memcpy(p_line0 + 128 - (shiftList * 7), BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); + memcpy(p_line0 + 128 - (shiftList * 5), BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); shiftList--; } if (att.scanlist2) { - memcpy(p_line0 + 128 - (shiftList * 7), BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + memcpy(p_line0 + 128 - (shiftList * 5), BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); shiftList--; } if (att.scanlist3) { - memcpy(p_line0 + 128 - (shiftList * 7), BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); + memcpy(p_line0 + 128 - (shiftList * 5), BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); } if(countList == 0) { - memcpy(p_line0 + 128 - (1 * 7), BITMAP_ScanList4, sizeof(BITMAP_ScanList4)); + memcpy(p_line0 + 128 - (1 * 5), BITMAP_ScanList0, sizeof(BITMAP_ScanList0)); } /* @@ -978,14 +978,6 @@ void UI_DisplayMain(void) { // no channel name, show the channel number instead sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); } - else - { - // Too many list, so remove last character name - if(String[9] != 0 && countList == 3) - { - String[9] = 0; - } - } if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) { UI_PrintString(String, 32, 0, line, 8); diff --git a/ui/menu.c b/ui/menu.c index b5e426f..f84a143 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -811,10 +811,10 @@ void UI_DisplayMenu(void) break; case MENU_S_LIST: - if (gSubMenuSelection < 3) - sprintf(String, "LIST [%u]", 1 + gSubMenuSelection); - else if (gSubMenuSelection == 3) + if (gSubMenuSelection == 0) strcpy(String, "LIST [0]\nNO LIST"); + else if (gSubMenuSelection < 4) + sprintf(String, "LIST [%u]", gSubMenuSelection); else if (gSubMenuSelection == 4) strcpy(String, "LISTS\n[1, 2, 3]"); else if (gSubMenuSelection == 5) diff --git a/ui/status.c b/ui/status.c index ed68613..c928363 100644 --- a/ui/status.c +++ b/ui/status.c @@ -50,7 +50,9 @@ static void convertTime(uint8_t *line, uint8_t type) m = t / 60; s = t - (m * 60); - gStatusLine[14] = 0x00; // Quick fix on display (on scanning I, II, etc.) + gStatusLine[0] = 0x00; // Quick fix on display (on scanning I, II, etc.) + gStatusLine[7] = 0x00; // Quick fix on display (on scanning I, II, etc.) + gStatusLine[14] = 0x00; // Quick fix on display (on scanning I, II, etc.) sprintf(str, "%02d:%02d", m, s); UI_PrintStringSmallBufferNormal(str, line + 0); @@ -95,23 +97,25 @@ void UI_DisplayStatus() if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) { if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning()) { // channel mode switch(gEeprom.SCAN_LIST_DEFAULT) { - case 0: - memcpy(line + x + 2, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); + case 0: + memcpy(line + 0, BITMAP_ScanList0, sizeof(BITMAP_ScanList0)); break; - case 1: - memcpy(line + x + 2, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + case 1: + memcpy(line + 0, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); break; case 2: - memcpy(line + x + 2, BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); + memcpy(line + 0, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); break; case 3: - memcpy(line + x + 2, BITMAP_ScanList4, sizeof(BITMAP_ScanList4)); + memcpy(line + 0, BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); break; case 4: - memcpy(line + x + 0, BITMAP_ScanList5, sizeof(BITMAP_ScanList5)); + memcpy(line + 0, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); + memcpy(line + 5, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + memcpy(line + 10, BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); break; case 5: - memcpy(line + x + 1, BITMAP_ScanList6, sizeof(BITMAP_ScanList6)); + memcpy(line + 0, BITMAP_ScanListAll, sizeof(BITMAP_ScanListAll)); break; } }