0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-19 00:11:18 +03:00

Channel name edit cleanup

This commit is contained in:
OneOfEleven 2023-09-20 13:34:00 +01:00
parent fd7f09a3ff
commit 7582bec615
4 changed files with 12 additions and 53 deletions

View File

@ -1508,61 +1508,20 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (gMenuCursor == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0) if (gMenuCursor == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character { // change the character
if (bKeyPressed && edit_index < 10) if (bKeyPressed && edit_index < 10 && Direction != 0)
{ {
#if 0 const char unwanted[] = "$%&!\"':;?^`|{}";
char c1 = edit[edit_index]; char c = edit[edit_index] + Direction;
char c2 = 0; unsigned int i = 0;
while (i < sizeof(unwanted) && c >= 32 && c <= 126)
if (Direction == 0)
return;
if (Direction < 0)
{ {
switch (c1) if (c == unwanted[i++])
{ { // choose next character
case 'a': c2 = 'Z'; break; c += Direction;
case 'A': c2 = '9'; break; i = 0;
case '0': c2 = '.'; break;
case '.': c2 = '-'; break;
case '-': c2 = '_'; break;
case '_': c2 = ' '; break;
case ' ': c2 = 'z'; break;
} }
} }
else
{
switch (c1)
{
case ' ': c2 = '_'; break;
case '_': c2 = '-'; break;
case '-': c2 = '.'; break;
case '.': c2 = '0'; break;
case '9': c2 = 'A'; break;
case 'Z': c2 = 'a'; break;
case 'z': c2 = ' '; break;
}
}
if (c2 == 0)
{
if ((c1 >= '0' && c1 <= '9') ||
(c1 >= 'A' && c1 <= 'Z') ||
(c1 >= 'a' && c1 <= 'z'))
{
c2 = c1 + Direction;
}
else
{
c2 = 'A';
}
}
edit[edit_index] = c2;
#else
const char c = edit[edit_index] + Direction;
edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c; edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
#endif
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
} }

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.