0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

Added channel names to SLIST1/2 menus

This commit is contained in:
OneOfEleven 2023-09-19 11:44:49 +01:00
parent 8aafba846d
commit f4a65c5b87
5 changed files with 259 additions and 250 deletions

View File

@ -284,13 +284,19 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_MEM_CH: case MENU_MEM_CH:
case MENU_1_CALL: case MENU_1_CALL:
case MENU_SLIST1: // case MENU_SLIST1:
case MENU_SLIST2: // case MENU_SLIST2:
case MENU_DEL_CH: case MENU_DEL_CH:
*pMin = 0; *pMin = 0;
*pMax = 199; *pMax = 199;
break; break;
case MENU_SLIST1:
case MENU_SLIST2:
*pMin = -1;
*pMax = 199;
break;
case MENU_SAVE: case MENU_SAVE:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SAVE) - 1; *pMax = ARRAY_SIZE(gSubMenu_SAVE) - 1;

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

143
ui/menu.c
View File

@ -308,6 +308,8 @@ void UI_DisplayMenu(void)
memset(String, 0, sizeof(String)); memset(String, 0, sizeof(String));
bool already_printed = false;
switch (gMenuCursor) switch (gMenuCursor)
{ {
case MENU_SQL: case MENU_SQL:
@ -356,9 +358,10 @@ void UI_DisplayMenu(void)
if (!gIsInSubMenu || gInputBoxIndex == 0) if (!gIsInSubMenu || gInputBoxIndex == 0)
{ {
sprintf(String, "%d.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000); sprintf(String, "%d.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000);
break; UI_PrintString(String, 50, 127, 1, 8);
} }
else
{
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
String[i ] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; String[i ] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
String[3] = '.'; String[3] = '.';
@ -369,7 +372,12 @@ void UI_DisplayMenu(void)
String[ 9] = 0; String[ 9] = 0;
String[10] = 0; String[10] = 0;
String[11] = 0; String[11] = 0;
UI_PrintString(String, 50, 127, 1, 8);
}
UI_PrintString("MHz", 50, 127, 3, 8);
already_printed = true;
break; break;
case MENU_W_N: case MENU_W_N:
@ -445,6 +453,8 @@ void UI_DisplayMenu(void)
case MENU_1_CALL: case MENU_1_CALL:
case MENU_DEL_CH: case MENU_DEL_CH:
UI_GenerateChannelStringEx(String, RADIO_CheckValidChannel(gSubMenuSelection, false, 0), gSubMenuSelection); UI_GenerateChannelStringEx(String, RADIO_CheckValidChannel(gSubMenuSelection, false, 0), gSubMenuSelection);
UI_PrintString(String, 50, 127, 0, 8);
already_printed = true;
break; break;
case MENU_SAVE: case MENU_SAVE:
@ -539,7 +549,22 @@ void UI_DisplayMenu(void)
break; break;
case MENU_VOL: case MENU_VOL:
// 1st text line
sprintf(String, "%u.%02uV", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100); sprintf(String, "%u.%02uV", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
UI_PrintString(String, 50, 127, 1, 8);
{ // 2nd text line .. percentage
UI_PrintString(String, 50, 127, 1, 8);
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
sprintf(String, "%u%%", (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
UI_PrintString(String, 50, 127, 3, 8);
#if 0
sprintf(String, "Curr %u", gBatteryCurrent); // needs scaling into mA
UI_PrintString(String, 50, 127, 5, 8);
#endif
}
already_printed = true;
break; break;
case MENU_RESET: case MENU_RESET:
@ -552,66 +577,68 @@ void UI_DisplayMenu(void)
case MENU_F_CALI: case MENU_F_CALI:
{ {
const uint32_t value = 22656 + gSubMenuSelection;
//gEeprom.BK4819_XTAL_FREQ_LOW = gSubMenuSelection; // already set when the user was adjusting the value
BK4819_WriteRegister(BK4819_REG_3B, value);
sprintf(String, "%d", gSubMenuSelection); sprintf(String, "%d", gSubMenuSelection);
UI_PrintString(String, 50, 127, 0, 8); UI_PrintString(String, 50, 127, 0, 8);
const uint32_t value = 22656 + gSubMenuSelection;
//gEeprom.BK4819_XTAL_FREQ_LOW = gSubMenuSelection;
BK4819_WriteRegister(BK4819_REG_3B, value);
const uint32_t xtal_Hz = (0x4f0000u + value) * 5; const uint32_t xtal_Hz = (0x4f0000u + value) * 5;
sprintf(String, "%u.%06u", xtal_Hz / 1000000, xtal_Hz % 1000000); sprintf(String, "%u.%06u", xtal_Hz / 1000000, xtal_Hz % 1000000);
UI_PrintString(String, 50, 127, 2, 8); UI_PrintString(String, 50, 127, 2, 8);
UI_PrintString("MHz", 50, 127, 4, 8); UI_PrintString("MHz", 50, 127, 4, 8);
already_printed = true;
} }
break; break;
} }
if (gMenuCursor == MENU_AM) if (!already_printed)
{ // the radio doesn't really do AM UI_PrintString(String, 50, 127, 2, 8);
UI_PrintString(String, 50, 127, 1, 8);
#if 0 if (gMenuCursor == MENU_SLIST1 || gMenuCursor == MENU_SLIST2)
if (gSubMenuSelection > 0)
{ {
UI_PrintString("not", 50, 127, 3, 8); i = (gMenuCursor == MENU_SLIST1) ? 0 : 1;
UI_PrintString("really", 50, 127, 5, 8);
} // if (gSubMenuSelection == 0xFF)
#endif if (gSubMenuSelection < 0)
strcpy(String, "NULL");
else
UI_GenerateChannelStringEx(String, true, gSubMenuSelection);
// if (gSubMenuSelection == 0xFF || !gEeprom.SCAN_LIST_ENABLED[i])
if (gSubMenuSelection < 0 || !gEeprom.SCAN_LIST_ENABLED[i])
{
UI_PrintString(String, 50, 127, 0, 8);
} }
else else
if (gMenuCursor == MENU_VOL)
{ // 2nd text line .. percentage
UI_PrintString(String, 50, 127, 1, 8);
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v :
(gBatteryVoltageAverage > gMax_bat_v) ? gMax_bat_v :
gBatteryVoltageAverage;
sprintf(String, "%u%%", (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
UI_PrintString(String, 50, 127, 3, 8);
#if 0
sprintf(String, "Curr %u", gBatteryCurrent); // needs scaling into mA
UI_PrintString(String, 50, 127, 5, 8);
#endif
}
else
if (gMenuCursor == MENU_OFFSET)
{ {
UI_PrintString(String, 50, 127, 1, 8); UI_PrintString(String, 50, 127, 0, 8);
UI_PrintString("MHz", 50, 127, 3, 8);
} if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i]))
else
if (gMenuCursor != MENU_F_CALI)
{ {
sprintf(String, "PRI1:%u", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
UI_PrintString(String, 50, 127, 2, 8); UI_PrintString(String, 50, 127, 2, 8);
} }
if ((gMenuCursor == MENU_RESET || gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH) && gAskForConfirmation) if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i]))
{ // display confirmation {
strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!"); sprintf(String, "PRI2:%u", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
UI_PrintString(String, 50, 127, 4, 8); UI_PrintString(String, 50, 127, 4, 8);
} }
else }
if ((gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH) && !gAskForConfirmation) }
if (gMenuCursor == MENU_MEM_CH ||
gMenuCursor == MENU_DEL_CH ||
gMenuCursor == MENU_1_CALL ||
gMenuCursor == MENU_SLIST1 ||
gMenuCursor == MENU_SLIST2)
{ // display the channel name { // display the channel name
if (gSubMenuSelection >= 0)
{
const uint16_t channel = (uint16_t)gSubMenuSelection; const uint16_t channel = (uint16_t)gSubMenuSelection;
const bool valid = RADIO_CheckValidChannel(channel, false, 0); const bool valid = RADIO_CheckValidChannel(channel, false, 0);
if (valid) if (valid)
@ -636,7 +663,8 @@ void UI_DisplayMenu(void)
s[i] = 0; s[i] = 0;
} }
} }
UI_PrintString(s, 50, 127, 4, 8); UI_PrintString(s, 50, 127, 2, 8);
}
} }
} }
@ -671,35 +699,10 @@ void UI_DisplayMenu(void)
UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false); UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false);
} }
if (gMenuCursor == MENU_SLIST1 || gMenuCursor == MENU_SLIST2) if ((gMenuCursor == MENU_RESET || gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH) && gAskForConfirmation)
{ { // display confirmation
i = gMenuCursor - MENU_SLIST1; strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!");
UI_PrintString(String, 50, 127, 5, 8);
if (gSubMenuSelection == 0xFF)
strcpy(String, "NULL");
else
UI_GenerateChannelStringEx(String, true, gSubMenuSelection);
if (gSubMenuSelection == 0xFF || !gEeprom.SCAN_LIST_ENABLED[i])
{
UI_PrintString(String, 50, 127, 2, 8);
}
else
{
UI_PrintString(String, 50, 127, 0, 8);
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i]))
{
sprintf(String, "PRI1:%u", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
UI_PrintString(String, 50, 127, 2, 8);
}
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i]))
{
sprintf(String, "PRI2:%u", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
UI_PrintString(String, 50, 127, 4, 8);
}
}
} }
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();