Пример #1
0
static void check_buttons(void)
{
#ifdef CONFIG_DEBUG_EASY_RESET
	/* if up and down is pressed then resets the watch */
	if (ports_button_pressed(PORTS_BTN_UP | PORTS_BTN_DOWN, 0))
	{
		WDTCTL = 0; // Forces a reset since a write to WDTCTL isn't allowed without the password.
	}
#endif
	if (menu_editmode.enabled) {
		editmode_handler();

	} else if (menumode.enabled) {
		menumode_handler();

	} else {
		if (ports_button_pressed(PORTS_BTN_LSTAR, 1)) {
			if (menumode.item->lstar_btn_fn)
				menumode.item->lstar_btn_fn();

		} else if (ports_button_pressed(PORTS_BTN_STAR, !!(menumode.item->lstar_btn_fn))) {
			menumode_enable();

		} else if (ports_button_pressed(PORTS_BTN_LNUM, 1)) {
			if (menumode.item->lnum_btn_fn)
				menumode.item->lnum_btn_fn();

		} else if (ports_button_pressed(PORTS_BTN_NUM, !!(menumode.item->lnum_btn_fn))) {
			if (menumode.item->num_btn_fn)
				menumode.item->num_btn_fn();

		} else if (ports_button_pressed(PORTS_BTN_UP | PORTS_BTN_DOWN, 0)) {
			if (menumode.item->updown_btn_fn)
				menumode.item->updown_btn_fn();

		} else if (ports_button_pressed(PORTS_BTN_UP, 0)) {
			if (menumode.item->up_btn_fn)
				menumode.item->up_btn_fn();

		} else if (ports_button_pressed(PORTS_BTN_DOWN, 0)) {
			if (menumode.item->down_btn_fn)
				menumode.item->down_btn_fn();
		}
	}

	ports_buttons_clear();
}
Пример #2
0
//* ************************************************************************************************
/// @fn			check_buttons(void)
/// @brief		Check for buttons and launch the proper routines
/// @return		none
//* ************************************************************************************************
static void check_buttons(void)
{
	// We are in edit mode, call it's handler routine
	if (menu_editmode.enabled)
	{
		editmode_handler();
	}
	// We are in menu mode, call it's handler routine
	else if (menumode.enabled)
	{
		menumode_handler();
	}
	// We are in a module, trigger button events
	else
	{
		// (long) STAR button
		if (BIT_IS_SET(ports_pressed_btns, PORTS_BTN_LSTAR))
		{
			if (menumode.item->lstar_btn_fn)
				menumode.item->lstar_btn_fn();
		}
		// STAR button
		else if (BIT_IS_SET(ports_pressed_btns, PORTS_BTN_STAR))
		{
			// Enables the menu mode
			menumode_enable();
		}
		// (long) NUM button
		else if (BIT_IS_SET(ports_pressed_btns, PORTS_BTN_LNUM))
		{
			if (menumode.item->lnum_btn_fn)
				menumode.item->lnum_btn_fn();
		}
		// NUM button
		else if (BIT_IS_SET(ports_pressed_btns, PORTS_BTN_NUM))
		{
			if (menumode.item->num_btn_fn)
				menumode.item->num_btn_fn();
		}
		// UP & DOWN buttons
		else if (BIT_IS_SET(ports_pressed_btns, PORTS_BTN_UP | PORTS_BTN_DOWN))
		{
			if (menumode.item->updown_btn_fn)
				menumode.item->updown_btn_fn();
		}
		// UP button
		else if (BIT_IS_SET(ports_pressed_btns, PORTS_BTN_UP))
		{
			if (menumode.item->up_btn_fn)
				menumode.item->up_btn_fn();
		}
		// DOWN button
		else if (BIT_IS_SET(ports_pressed_btns, PORTS_BTN_DOWN))
		{
			if (menumode.item->down_btn_fn)
				menumode.item->down_btn_fn();
		}
	}
	
	ports_pressed_btns = 0;
}