I am designing a flexible menu for an embedded device. Because of cost considerations, the touch screen is not used in the design. Transitions between options will be done via buttons. The challenge I have come across is that menu options are not determined yet that is why that part should be flexible. what I have done is that
typedef uint16_t com_t;
/* Limited Level */
#define LIMITED_SETTINGS_BASE (com_t)0x0000
/* Basic Level */
#define MENU_LANGUAGE_BASIC_BASE (com_t)0x0020
#define SPEED_DEFAULT_BASIC_BASE (com_t)0x0040
#define CUSTOM_SETTINGS_BASIC_BASE (com_t)0x0060
#define OTHER_PARAMETERS_BASIC_BASE (com_t)0x0080
/* Manufacture Level */
#define MENU_LANGUAGE_MANUFACTURE_BASE (com_t)0x00A0
#define DEFAULT_SETTINGS_MANUFACTURE_BASE (com_t)0x00C0
#define CUSTOM_SETTINGS_MANUFACTURE_BASE (com_t)0x00E0
#define MANUFACTURE_SETTINGS_BASE (com_t)0x00F0
#define OTHER_PARAMETERS_MANUFACTURE_BASE (com_t)0x0200
const com_t limited_settings[] =
{
LIMITED_SETTINGS_BASE+0x01, /* Start-up Menu */
LIMITED_SETTINGS_BASE+0x02, /* Not assigned */
LIMITED_SETTINGS_BASE+0x03, /* Not assigned */
LIMITED_SETTINGS_BASE+0x04, /* Not assigned */
LIMITED_SETTINGS_BASE+0x05 /* Not assigned */
};
/* 2.*/
const com_t menu_language_settings_basic[] =
{
MENU_LANGUAGE_BASIC_BASE+0x01, /* Not assigned */
MENU_LANGUAGE_BASIC_BASE+0x02, /* Not assigned */
MENU_LANGUAGE_BASIC_BASE+0x03, /* Not assigned */
MENU_LANGUAGE_BASIC_BASE+0x04, /* Not assigned */
MENU_LANGUAGE_BASIC_BASE+0x05 /* Not assigned */
};
/* 3.*/
const com_t speed_default_settings_basic[] =
{
SPEED_DEFAULT_BASIC_BASE+0x01, /* Not assigned */
SPEED_DEFAULT_BASIC_BASE+0x02, /* Not assigned */
SPEED_DEFAULT_BASIC_BASE+0x03, /* Not assigned */
SPEED_DEFAULT_BASIC_BASE+0x04, /* Not assigned */
SPEED_DEFAULT_BASIC_BASE+0x05 /* Not assigned */
};
/* 4.*/
const com_t speed_costum_settings_basic[] =
{
CUSTOM_SETTINGS_BASIC_BASE+0x01, /* Not assigned */
CUSTOM_SETTINGS_BASIC_BASE+0x02, /* Not assigned */
CUSTOM_SETTINGS_BASIC_BASE+0x03, /* Not assigned */
CUSTOM_SETTINGS_BASIC_BASE+0x04, /* Not assigned */
CUSTOM_SETTINGS_BASIC_BASE+0x05 /* Not assigned */
};
/* 5.*/
const com_t other_parameters_settings_basic[] =
{
OTHER_PARAMETERS_BASIC_BASE+0x01, /* Start-up Menu */
OTHER_PARAMETERS_BASIC_BASE+0x02, /* Not assigned */
OTHER_PARAMETERS_BASIC_BASE+0x03, /* Not assigned */
OTHER_PARAMETERS_BASIC_BASE+0x04, /* Not assigned */
OTHER_PARAMETERS_BASIC_BASE+0x05 /* Not assigned */
};
/* 6.*/
const com_t menu_language_settings_manufacture[] =
{
MENU_LANGUAGE_MANUFACTURE_BASE+0x01, /* Not assigned */
MENU_LANGUAGE_MANUFACTURE_BASE+0x02, /* Not assigned */
MENU_LANGUAGE_MANUFACTURE_BASE+0x03, /* Not assigned */
MENU_LANGUAGE_MANUFACTURE_BASE+0x04, /* Not assigned */
MENU_LANGUAGE_MANUFACTURE_BASE+0x05 /* Not assigned */
};
/* 7.*/
const com_t speed_default_settings_manufacture[] =
{
DEFAULT_SETTINGS_MANUFACTURE_BASE+0x01, /* Start-up Menu */
DEFAULT_SETTINGS_MANUFACTURE_BASE+0x02, /* Not assigned */
DEFAULT_SETTINGS_MANUFACTURE_BASE+0x03, /* Not assigned */
DEFAULT_SETTINGS_MANUFACTURE_BASE+0x04, /* Not assigned */
DEFAULT_SETTINGS_MANUFACTURE_BASE+0x05 /* Not assigned */
};
/* 8.*/
const com_t speed_costum_settings_manufacture[] =
{
CUSTOM_SETTINGS_MANUFACTURE_BASE+0x01, /* Not assigned */
CUSTOM_SETTINGS_MANUFACTURE_BASE+0x02, /* Not assigned */
CUSTOM_SETTINGS_MANUFACTURE_BASE+0x03, /* Not assigned */
CUSTOM_SETTINGS_MANUFACTURE_BASE+0x04, /* Not assigned */
CUSTOM_SETTINGS_MANUFACTURE_BASE+0x05 /* Not assigned */
};
/* 9.*/
const com_t manufacture_settings[] =
{
MANUFACTURE_SETTINGS_BASE+0x01, /* Start-up Menu */
MANUFACTURE_SETTINGS_BASE+0x02, /* Not assigned */
MANUFACTURE_SETTINGS_BASE+0x03, /* Not assigned */
MANUFACTURE_SETTINGS_BASE+0x04, /* Not assigned */
MANUFACTURE_SETTINGS_BASE+0x05 /* Not assigned */
};
/* 10.*/
const com_t other_parameters_settings_manufacture[] =
{
OTHER_PARAMETERS_MANUFACTURE_BASE+0x01, /* Not assigned */
OTHER_PARAMETERS_MANUFACTURE_BASE+0x02, /* Not assigned */
OTHER_PARAMETERS_MANUFACTURE_BASE+0x03, /* Not assigned */
OTHER_PARAMETERS_MANUFACTURE_BASE+0x04, /* Not assigned */
OTHER_PARAMETERS_MANUFACTURE_BASE+0x05 /* Not assigned */
};
So the idea of base parameters is to create domains for menu options. Menu is divided into sub-menus inside. My question is how can I create an algorithm to switch between sub-menus and options by button without creating a spaghetti code? I mean a humongous switch-case can handle this but that will be hard to read and maintain. If there is another way I am glad to know it.
Aucun commentaire:
Enregistrer un commentaire