mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Menu list on-screen order now easier to change
This commit is contained in:
parent
0c4b656ad2
commit
732028b3e9
@ -1435,7 +1435,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
if (gMenuCursor != MENU_SCR)
|
||||
gAnotherVoiceID = MenuList[gMenuCursor].voice_id;
|
||||
gAnotherVoiceID = MenuList[MenuList_sorted[gMenuCursor]].voice_id;
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
20
main.c
20
main.c
@ -104,24 +104,10 @@ void Main(void)
|
||||
|
||||
BootMode = BOOT_GetMode();
|
||||
|
||||
// count the number of menu items
|
||||
gMenuListCount = 0;
|
||||
while (MenuList[gMenuListCount].name[0] != '\0')
|
||||
gMenuListCount++;
|
||||
gF_LOCK = (BootMode == BOOT_MODE_F_LOCK); // flag to say include the hidden menu items
|
||||
|
||||
if (BootMode == BOOT_MODE_F_LOCK)
|
||||
{
|
||||
gF_LOCK = true; // flag to say include the hidden menu items
|
||||
}
|
||||
else
|
||||
{ // hide the hidden menu items
|
||||
|
||||
gMenuListCount -= 9;
|
||||
|
||||
#ifndef ENABLE_F_CAL_MENU
|
||||
gMenuListCount++;
|
||||
#endif
|
||||
}
|
||||
// sort the menu list
|
||||
UI_SortMenu(!gF_LOCK);
|
||||
|
||||
// wait for user to release all butts before moving on
|
||||
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) ||
|
||||
|
88
ui/menu.c
88
ui/menu.c
@ -36,15 +36,18 @@
|
||||
#include "ui/menu.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
// NOTE. this menu list is half way through a change, what might seem
|
||||
// pointless at this time is for there for a reason.
|
||||
// ***************************************************************************************
|
||||
// NOTE. the oder of menu entries you on-screen is now solely determined by the enum list order in ui/menu.h
|
||||
//
|
||||
// the order of entries in this list below is no longer important, no longer has to match the enum list
|
||||
|
||||
const t_menu_item MenuList[] =
|
||||
{
|
||||
// text, voice ID, menu ID
|
||||
|
||||
{"SQL", VOICE_ID_SQUELCH, MENU_SQL },
|
||||
{"STEP", VOICE_ID_FREQUENCY_STEP, MENU_STEP },
|
||||
{"W/N", VOICE_ID_CHANNEL_BANDWIDTH, MENU_W_N },
|
||||
{"T PWR", VOICE_ID_POWER, MENU_TXP }, // was "TXP"
|
||||
{"R DCS", VOICE_ID_DCS, MENU_R_DCS }, // was "R_DCS"
|
||||
{"R CTCS", VOICE_ID_CTCSS, MENU_R_CTCS }, // was "R_CTCS"
|
||||
@ -52,9 +55,9 @@ const t_menu_item MenuList[] =
|
||||
{"T CTCS", VOICE_ID_CTCSS, MENU_T_CTCS }, // was "T_CTCS"
|
||||
{"T DIR", VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION, MENU_SFT_D }, // was "SFT_D"
|
||||
{"T OFFS", VOICE_ID_TX_OFFSET_FREQUENCY, MENU_OFFSET }, // was "OFFSET"
|
||||
{"T VFO", VOICE_ID_INVALID, MENU_XB }, // was "WX"
|
||||
{"T TOUT", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT"
|
||||
{"W/N", VOICE_ID_CHANNEL_BANDWIDTH, MENU_W_N },
|
||||
{"T VFO", VOICE_ID_INVALID, MENU_XB }, // was "WX"
|
||||
{"2nd RX", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR"
|
||||
{"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR"
|
||||
{"BUSYCL", VOICE_ID_BUSY_LOCKOUT, MENU_BCL }, // was "BCL"
|
||||
{"CH SAV", VOICE_ID_MEMORY_CHANNEL, MENU_MEM_CH }, // was "MEM-CH"
|
||||
@ -67,7 +70,6 @@ const t_menu_item MenuList[] =
|
||||
#endif
|
||||
{"BLT", VOICE_ID_INVALID, MENU_ABR }, // was "ABR"
|
||||
{"BLTTRX", VOICE_ID_INVALID, MENU_ABR_ON_TX_RX },
|
||||
{"DUALRX", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR"
|
||||
{"BEEP", VOICE_ID_BEEP_PROMPT, MENU_BEEP },
|
||||
#ifdef ENABLE_VOICE
|
||||
{"VOICE", VOICE_ID_VOICE_PROMPT, MENU_VOICE },
|
||||
@ -122,7 +124,7 @@ const t_menu_item MenuList[] =
|
||||
{"RESET", VOICE_ID_INITIALISATION, MENU_RESET }, // might be better to move this to the hidden menu items ?
|
||||
|
||||
// hidden menu items from here on
|
||||
// enabled if pressing both the PTT and upper side button at power-on
|
||||
// enabled by pressing both the PTT and upper side button at power-on
|
||||
|
||||
{"F LOCK", VOICE_ID_INVALID, MENU_F_LOCK },
|
||||
{"TX 200", VOICE_ID_INVALID, MENU_200TX }, // was "200TX"
|
||||
@ -130,16 +132,18 @@ const t_menu_item MenuList[] =
|
||||
{"TX 500", VOICE_ID_INVALID, MENU_500TX }, // was "500TX"
|
||||
{"350 EN", VOICE_ID_INVALID, MENU_350EN }, // was "350EN"
|
||||
{"SCR EN", VOICE_ID_INVALID, MENU_SCREN }, // was "SCREN"
|
||||
|
||||
{"TX EN", VOICE_ID_INVALID, MENU_TX_EN }, // enable TX
|
||||
#ifdef ENABLE_F_CAL_MENU
|
||||
{"F CALI", VOICE_ID_INVALID, MENU_F_CALI }, // reference xtal calibration
|
||||
#endif
|
||||
{"BATCAL", VOICE_ID_INVALID, MENU_BATCAL }, // battery voltage calibration
|
||||
|
||||
{"", VOICE_ID_INVALID, 0xff } // end of list - DO NOT delete or move this this
|
||||
};
|
||||
|
||||
// number of hidden menu items at the end of the list - KEEP THIS UP-TO-DATE
|
||||
const unsigned int gHidden_menu_count = 9;
|
||||
|
||||
// ***************************************************************************************
|
||||
|
||||
const char gSubMenu_TXP[3][5] =
|
||||
{
|
||||
"LOW",
|
||||
@ -349,16 +353,66 @@ const char gSubMenu_SIDE_BUTT[9][16] =
|
||||
"TX\n1750Hz"
|
||||
};
|
||||
|
||||
// ***************************************************************************************
|
||||
|
||||
uint8_t MenuList_sorted[ARRAY_SIZE(MenuList)];
|
||||
|
||||
bool gIsInSubMenu;
|
||||
uint8_t gMenuCursor;
|
||||
int8_t gMenuScrollDirection;
|
||||
int32_t gSubMenuSelection;
|
||||
|
||||
// edit box
|
||||
char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/difference
|
||||
char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/differences
|
||||
char edit[17];
|
||||
int edit_index;
|
||||
|
||||
// ***************************************************************************************
|
||||
|
||||
void UI_SortMenu(const bool hide_hidden)
|
||||
{
|
||||
// sort the menu order according to the MENU-ID value (enum list in id/menu.h)
|
||||
//
|
||||
// this means the menu order is entirely determined by the enum list (found in id/menu.h)
|
||||
// it now no longer depends on the order of entries in the above const list (they can be any order)
|
||||
|
||||
unsigned int i;
|
||||
|
||||
unsigned int hidden_menu_count = gHidden_menu_count;
|
||||
|
||||
#ifndef ENABLE_F_CAL_MENU
|
||||
hidden_menu_count--;
|
||||
#endif
|
||||
|
||||
gMenuListCount = ARRAY_SIZE(MenuList_sorted);
|
||||
|
||||
for (i = 0; i < gMenuListCount; i++)
|
||||
MenuList_sorted[i] = MenuList[i].menu_id;
|
||||
|
||||
// don't sort the hidden entries at the end, keep them at the end of the list
|
||||
|
||||
for (i = 0; i < (gMenuListCount - hidden_menu_count - 1); i++)
|
||||
{
|
||||
unsigned int k;
|
||||
unsigned int menu_id1 = MenuList_sorted[i];
|
||||
for (k = i + 1; k < (gMenuListCount - hidden_menu_count); k++)
|
||||
{
|
||||
unsigned int menu_id2 = MenuList_sorted[k];
|
||||
if (menu_id2 < menu_id1)
|
||||
{ // swap
|
||||
const unsigned int id = menu_id1;
|
||||
menu_id1 = menu_id2;
|
||||
menu_id2 = id;
|
||||
MenuList_sorted[i] = menu_id1;
|
||||
MenuList_sorted[k] = menu_id2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hide_hidden)
|
||||
gMenuListCount -= hidden_menu_count; // hide the hidden menu items
|
||||
}
|
||||
|
||||
void UI_DisplayMenu(void)
|
||||
{
|
||||
const unsigned int menu_list_width = 6; // max no. of characters on the menu list (left side)
|
||||
@ -377,7 +431,7 @@ void UI_DisplayMenu(void)
|
||||
for (i = 0; i < 3; i++)
|
||||
if (gMenuCursor > 0 || i > 0)
|
||||
if ((gMenuListCount - 1) != gMenuCursor || i != 2)
|
||||
UI_PrintString(MenuList[gMenuCursor + i - 1].name, 0, 0, i * 2, 8);
|
||||
UI_PrintString(MenuList[MenuList_sorted[gMenuCursor + i - 1]].name, 0, 0, i * 2, 8);
|
||||
|
||||
// invert the current menu list item pixels
|
||||
for (i = 0; i < (8 * menu_list_width); i++)
|
||||
@ -410,26 +464,26 @@ void UI_DisplayMenu(void)
|
||||
{ // leading menu items - small text
|
||||
const int k = menu_index + i - 2;
|
||||
if (k < 0)
|
||||
UI_PrintStringSmall(MenuList[gMenuListCount + k].name, 0, 0, i); // wrap-a-round
|
||||
UI_PrintStringSmall(MenuList[MenuList_sorted[gMenuListCount + k]].name, 0, 0, i); // wrap-a-round
|
||||
else
|
||||
if (k >= 0 && k < (int)gMenuListCount)
|
||||
UI_PrintStringSmall(MenuList[k].name, 0, 0, i);
|
||||
UI_PrintStringSmall(MenuList[MenuList_sorted[k]].name, 0, 0, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
// current menu item - keep big n fat
|
||||
if (menu_index >= 0 && menu_index < (int)gMenuListCount)
|
||||
UI_PrintString(MenuList[menu_index].name, 0, 0, 2, 8);
|
||||
UI_PrintString(MenuList[MenuList_sorted[menu_index]].name, 0, 0, 2, 8);
|
||||
i++;
|
||||
|
||||
while (i < 4)
|
||||
{ // trailing menu item - small text
|
||||
const int k = menu_index + i - 2;
|
||||
if (k >= 0 && k < (int)gMenuListCount)
|
||||
UI_PrintStringSmall(MenuList[k].name, 0, 0, 1 + i);
|
||||
UI_PrintStringSmall(MenuList[MenuList_sorted[k]].name, 0, 0, 1 + i);
|
||||
else
|
||||
if (k >= (int)gMenuListCount)
|
||||
UI_PrintStringSmall(MenuList[gMenuListCount - k].name, 0, 0, 1 + i); // wrap-a-round
|
||||
UI_PrintStringSmall(MenuList[MenuList_sorted[gMenuListCount - k]].name, 0, 0, 1 + i); // wrap-a-round
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -440,7 +494,7 @@ void UI_DisplayMenu(void)
|
||||
else
|
||||
if (menu_index >= 0 && menu_index < (int)gMenuListCount)
|
||||
{ // current menu item
|
||||
strcpy(String, MenuList[menu_index].name);
|
||||
strcpy(String, MenuList[MenuList_sorted[menu_index]].name);
|
||||
// strcat(String, ":");
|
||||
UI_PrintString(String, 0, 0, 0, 8);
|
||||
// UI_PrintStringSmall(String, 0, 0, 0);
|
||||
|
81
ui/menu.h
81
ui/menu.h
@ -38,8 +38,11 @@ typedef struct {
|
||||
//
|
||||
enum
|
||||
{
|
||||
// ************************************
|
||||
|
||||
MENU_SQL = 0,
|
||||
MENU_STEP,
|
||||
MENU_W_N,
|
||||
MENU_TXP,
|
||||
MENU_R_DCS,
|
||||
MENU_R_CTCS,
|
||||
@ -47,9 +50,9 @@ enum
|
||||
MENU_T_CTCS,
|
||||
MENU_SFT_D,
|
||||
MENU_OFFSET,
|
||||
MENU_XB,
|
||||
MENU_TOT,
|
||||
MENU_W_N,
|
||||
MENU_XB,
|
||||
MENU_TDR,
|
||||
MENU_SCR,
|
||||
MENU_BCL,
|
||||
MENU_MEM_CH,
|
||||
@ -62,7 +65,6 @@ enum
|
||||
#endif
|
||||
MENU_ABR,
|
||||
MENU_ABR_ON_TX_RX,
|
||||
MENU_TDR,
|
||||
MENU_BEEP,
|
||||
#ifdef ENABLE_VOICE
|
||||
MENU_VOICE,
|
||||
@ -116,6 +118,7 @@ enum
|
||||
MENU_SIDE2_LONG,
|
||||
MENU_RESET,
|
||||
|
||||
// ************************************
|
||||
// items after here are normally hidden
|
||||
|
||||
MENU_F_LOCK,
|
||||
@ -129,54 +132,60 @@ enum
|
||||
#ifdef ENABLE_F_CAL_MENU
|
||||
MENU_F_CALI, // reference xtal calibration
|
||||
#endif
|
||||
MENU_BATCAL // battery voltage calibration
|
||||
MENU_BATCAL, // battery voltage calibration
|
||||
|
||||
// ************************************
|
||||
};
|
||||
|
||||
extern const t_menu_item MenuList[];
|
||||
extern const unsigned int gHidden_menu_count;
|
||||
|
||||
extern const char gSubMenu_TXP[3][5];
|
||||
extern const char gSubMenu_SFT_D[3][4];
|
||||
extern const char gSubMenu_W_N[2][7];
|
||||
extern const char gSubMenu_OFF_ON[2][4];
|
||||
extern const char gSubMenu_SAVE[5][4];
|
||||
extern const char gSubMenu_TOT[11][7];
|
||||
extern const char gSubMenu_CHAN[3][10];
|
||||
extern const char gSubMenu_XB[3][10];
|
||||
extern const t_menu_item MenuList[];
|
||||
extern uint8_t MenuList_sorted[];
|
||||
|
||||
extern const char gSubMenu_TXP[3][5];
|
||||
extern const char gSubMenu_SFT_D[3][4];
|
||||
extern const char gSubMenu_W_N[2][7];
|
||||
extern const char gSubMenu_OFF_ON[2][4];
|
||||
extern const char gSubMenu_SAVE[5][4];
|
||||
extern const char gSubMenu_TOT[11][7];
|
||||
extern const char gSubMenu_CHAN[3][10];
|
||||
extern const char gSubMenu_XB[3][10];
|
||||
#ifdef ENABLE_VOICE
|
||||
extern const char gSubMenu_VOICE[3][4];
|
||||
extern const char gSubMenu_VOICE[3][4];
|
||||
#endif
|
||||
extern const char gSubMenu_SC_REV[3][13];
|
||||
extern const char gSubMenu_MDF[4][15];
|
||||
extern const char gSubMenu_SC_REV[3][13];
|
||||
extern const char gSubMenu_MDF[4][15];
|
||||
#ifdef ENABLE_ALARM
|
||||
extern const char gSubMenu_AL_MOD[2][5];
|
||||
extern const char gSubMenu_AL_MOD[2][5];
|
||||
#endif
|
||||
extern const char gSubMenu_D_RSP[4][11];
|
||||
extern const char gSubMenu_PTT_ID[5][15];
|
||||
extern const char gSubMenu_PONMSG[4][8];
|
||||
extern const char gSubMenu_ROGER[3][9];
|
||||
extern const char gSubMenu_RESET[2][4];
|
||||
extern const char gSubMenu_F_LOCK[6][4];
|
||||
extern const char gSubMenu_BACKLIGHT[8][7];
|
||||
extern const char gSubMenu_RX_TX[4][6];
|
||||
extern const char gSubMenu_D_RSP[4][11];
|
||||
extern const char gSubMenu_PTT_ID[5][15];
|
||||
extern const char gSubMenu_PONMSG[4][8];
|
||||
extern const char gSubMenu_ROGER[3][9];
|
||||
extern const char gSubMenu_RESET[2][4];
|
||||
extern const char gSubMenu_F_LOCK[6][4];
|
||||
extern const char gSubMenu_BACKLIGHT[8][7];
|
||||
extern const char gSubMenu_RX_TX[4][6];
|
||||
#ifdef ENABLE_AM_FIX_TEST1
|
||||
extern const char gSubMenu_AM_fix_test1[4][8];
|
||||
extern const char gSubMenu_AM_fix_test1[4][8];
|
||||
#endif
|
||||
extern const char gSubMenu_BAT_TXT[3][8];
|
||||
extern const char gSubMenu_BAT_TXT[3][8];
|
||||
|
||||
extern const char gSubMenu_SCRAMBLER[11][7];
|
||||
extern const char gSubMenu_SCRAMBLER[11][7];
|
||||
|
||||
extern const char gSubMenu_SIDE_BUTT[9][16];
|
||||
extern const char gSubMenu_SIDE_BUTT[9][16];
|
||||
|
||||
extern bool gIsInSubMenu;
|
||||
extern bool gIsInSubMenu;
|
||||
|
||||
extern uint8_t gMenuCursor;
|
||||
extern int8_t gMenuScrollDirection;
|
||||
extern int32_t gSubMenuSelection;
|
||||
extern uint8_t gMenuCursor;
|
||||
extern int8_t gMenuScrollDirection;
|
||||
extern int32_t gSubMenuSelection;
|
||||
|
||||
extern char edit_original[17];
|
||||
extern char edit[17];
|
||||
extern int edit_index;
|
||||
extern char edit_original[17];
|
||||
extern char edit[17];
|
||||
extern int edit_index;
|
||||
|
||||
void UI_SortMenu(const bool hide_hidden);
|
||||
void UI_DisplayMenu(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user