typedef enum _SM_USER_MODE
{
SM_POWERUP,
SM_ONLINE,
SM_OFFLINE,
SM_IDENTIFY
} SM_USER_MODE;
Example Usage
typedef enum _SM_USER_MODE
{
SM_POWERUP,
SM_IDLE
} SM_USER_MODE;
void my_function (void)
{
static int user_mode = SM_POWERUP;
static int user_mode_last = ~SM_POWERUP;
BYTE this_is_new_mode = 0;
//----- CHECK FOR THIS IS NEW MODE -----
if (user_mode_last != user_mode)
{
this_is_new_mode = 1;
user_mode_last = user_mode;
}
//--------------------------------
//--------------------------------
//----- PROCESS CURRENT MODE -----
//--------------------------------
//--------------------------------
switch (user_mode)
{
case SM_POWERUP:
//--------------------
//--------------------
//----- POWER UP -----
//--------------------
//--------------------
if (this_is_new_mode)
{
//----- JUST ENTERED THIS MODE -----
}
//Do something, then
//user_mode = SM_IDLE;
break;
case SM_IDLE:
//----------------
//----------------
//----- IDLE -----
//----------------
//----------------
if (this_is_new_mode)
{
//----- JUST ENTERED THIS MODE -----
}
break;
//<<<<< ADD OTHER MODES HERE
} //switch (user_mode)
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.