diff --git a/App/dcs.c b/App/dcs.c index a54f48b2..f7177bdf 100644 --- a/App/dcs.c +++ b/App/dcs.c @@ -48,6 +48,13 @@ const uint16_t DCS_Options[104] = { 0x01C3, 0x01CA, 0x01D3, 0x01D9, 0x01DA, 0x01DC, 0x01E3, 0x01EC, }; +// Indices in DCS_Options for the 21 non-PMR446 DCS codes. +static const uint8_t DCS_ExtraIdx[21] = { + 5, 9, 19, 25, 34, 36, 41, 43, 44, 48, + 50, 54, 56, 60, 71, 72, 73, 74, 75, 82, + 83 +}; + static uint32_t DCS_CalculateGolay(uint32_t CodeWord) { unsigned int i; @@ -141,3 +148,30 @@ uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option) return 0xFF; } + +uint8_t DCS_GetDcsApprovedIndex(uint8_t Option) +{ + unsigned int i; + unsigned int extra_pos = 0; + uint8_t approved_index = 0; + + if (Option >= ARRAY_SIZE(DCS_Options)) + return 0xFF; + + for (i = 0; i < ARRAY_SIZE(DCS_Options); i++) { + const bool is_extra = extra_pos < ARRAY_SIZE(DCS_ExtraIdx) && + i == DCS_ExtraIdx[extra_pos]; + + if (is_extra) { + extra_pos++; + continue; + } + + if (i == Option) + return approved_index; + + approved_index++; + } + + return 0xFF; +} diff --git a/App/dcs.h b/App/dcs.h index c05ecff2..73fa1159 100644 --- a/App/dcs.h +++ b/App/dcs.h @@ -41,5 +41,6 @@ uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option); uint8_t DCS_GetCdcssCode(uint32_t Code); uint8_t DCS_GetCtcssCode(int Code); uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option); +uint8_t DCS_GetDcsApprovedIndex(uint8_t Option); #endif diff --git a/App/ui/menu.c b/App/ui/menu.c index dbf076c8..a343a153 100644 --- a/App/ui/menu.c +++ b/App/ui/menu.c @@ -1499,9 +1499,22 @@ void UI_DisplayMenu(void) if (gSubMenuSelection == 0) sprintf(top_right_badge, "00/00"); else if (approved_index != 0xFF) - sprintf(top_right_badge, "%02u/%02u", (unsigned)gSubMenuSelection, approved_index + 1); + sprintf(top_right_badge, "%02u/%02u", (unsigned)gSubMenuSelection, (unsigned)approved_index + 1); else sprintf(top_right_badge, "%02u/--", (unsigned)gSubMenuSelection); + } else if (UI_MENU_GetCurrentMenuId() == MENU_R_DCS || + UI_MENU_GetCurrentMenuId() == MENU_T_DCS) { + const bool is_normal_dcs = + gSubMenuSelection > 0 && gSubMenuSelection <= ARRAY_SIZE(DCS_Options); + const uint8_t approved_index = + is_normal_dcs ? DCS_GetDcsApprovedIndex(gSubMenuSelection - 1) : 0xFF; + + if (gSubMenuSelection == 0) + sprintf(top_right_badge, "000/000"); + else if (approved_index != 0xFF) + sprintf(top_right_badge, "%03u/%03u", (unsigned)gSubMenuSelection, (unsigned)approved_index + 1); + else + sprintf(top_right_badge, "%03u/---", (unsigned)gSubMenuSelection); } else { sprintf(top_right_badge, "%03d", gSubMenuSelection); }