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)

}

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through resources like this. We hope you find it helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support here. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *