Show homologated CTCSS index in Rx/Tx CTCSS menus

This commit is contained in:
Armel FAUVEAU committed 2026-04-15 00:20:13 +02:00
1 parent f59370cee6
commit e536725731
3 files changed
+60 -3

No files matched your search

+33
View File
@@ -26,6 +26,12 @@ const uint16_t CTCSS_Options[50] = {
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541
};
// Indices in CTCSS_Options for the 12 non-homologated tones.
static const uint8_t CTCSS_ExtraIdx[12] = {
1, 26, 28, 30, 32, 34, 36, 38, 39, 41,
45, 49
};
const uint16_t DCS_Options[104] = {
0x0013, 0x0015, 0x0016, 0x0019, 0x001A, 0x001E, 0x0023, 0x0027,
0x0029, 0x002B, 0x002C, 0x0035, 0x0039, 0x003A, 0x003B, 0x003C,
@@ -108,3 +114,30 @@ uint8_t DCS_GetCtcssCode(int Code)
return Result;
}
uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option)
{
unsigned int i;
unsigned int extra_pos = 0;
uint8_t approved_index = 0;
if (Option >= ARRAY_SIZE(CTCSS_Options))
return 0xFF;
for (i = 0; i < ARRAY_SIZE(CTCSS_Options); i++) {
const bool is_extra = extra_pos < ARRAY_SIZE(CTCSS_ExtraIdx) &&
i == CTCSS_ExtraIdx[extra_pos];
if (is_extra) {
extra_pos++;
continue;
}
if (i == Option)
return approved_index;
approved_index++;
}
return 0xFF;
}
+1 -1
View File
@@ -40,6 +40,6 @@ extern const uint16_t DCS_Options[104];
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);
#endif
+26 -2
View File
@@ -27,6 +27,7 @@
#include "../driver/eeprom.h"
#include "../driver/st7565.h"
#include "../external/printf/printf.h"
#include "../font.h"
#include "../frequencies.h"
#include "../helper/battery.h"
#include "../misc.h"
@@ -1351,8 +1352,31 @@ void UI_DisplayMenu(void)
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
#endif
) {
sprintf(String, "%03d", gSubMenuSelection);
UI_PrintStringSmallNormal(String, 107, 0, 0);
uint8_t text_x = 107;
if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS ||
UI_MENU_GetCurrentMenuId() == MENU_T_CTCS) {
const uint8_t approved_index =
(gSubMenuSelection > 0) ? DCS_GetCtcssApprovedIndex(gSubMenuSelection - 1) : 0xFF;
if (gSubMenuSelection == 0)
sprintf(String, "00 (00)");
else if (approved_index != 0xFF)
sprintf(String, "%02u (%02u)", (unsigned)gSubMenuSelection, approved_index + 1);
else
sprintf(String, "%02u (--)", (unsigned)gSubMenuSelection);
{
const uint8_t char_spacing = ARRAY_SIZE(gFontSmall[0]) + 1;
const size_t text_width = strlen(String) * char_spacing;
text_x = (text_width < LCD_WIDTH) ? (uint8_t)(LCD_WIDTH - text_width) : 0;
}
} else {
sprintf(String, "%03d", gSubMenuSelection);
}
UI_PrintStringSmallNormal(String, text_x, 0, 0);
}
if ((UI_MENU_GetCurrentMenuId() == MENU_RESET ||