Ejemplo n.º 1
0
void multi_release()
{
    free(ball);
    free(first_player);
    free(second_player);
    ball = NULL;
    first_player = NULL;
    second_player = NULL;
    multi_first_score->score = 0;
    multi_second_score->score = 0;
    switch_to_menu();
}
static void key_handler(void *msg)
{
	key_t key_msg = (key_t)(uint32_t)msg;
	uint8_t key = KEY_VALUE(key_msg);
	
	if (KEY_TYPE(key_msg) == MASK_KEY_RELEASE)
	{
		return;
	}

	if (KEY_TYPE(key_msg) != MASK_KEY_PRESS && (key == KEY_OK || key == KEY_CANCEL))
	{
		return;
	}
	
	beeper_beep(BEEPER_VOL_LOW, 50, 50, 1);

	if (key == KEY_LEFT || key == KEY_UP)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			s_unfocus_fun_arr[s_focus_item]();
			
			s_focus_item += DIVIDE_MODE_COUNT - 1;
			s_focus_item %= DIVIDE_MODE_COUNT;
			
			s_focus_fun_arr[s_focus_item]();
		}
		else
		{
			s_edit_fun_arr[s_edit_item](key);
		}
		
		lcd_validate_cmd();
	}
	else if (key == KEY_RIGHT || key == KEY_DOWN)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			s_unfocus_fun_arr[s_focus_item]();
			
			s_focus_item++;
			s_focus_item %= DIVIDE_MODE_COUNT;
			
			s_focus_fun_arr[s_focus_item]();
		}
		else
		{
			s_edit_fun_arr[s_edit_item](key);
		}

		lcd_validate_cmd();
	}
	else if (key == KEY_OK)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			s_enter_edit_fun_arr[s_focus_item]();
		}
		else
		{
			s_confirm_edit_fun_arr[s_focus_item]();
			
			s_edit_item = DIVIDE_MODE_NONE;
		}
		
		lcd_validate_cmd();
	}
	else if (key == KEY_CANCEL)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			/* save */
			set_dp_dn_divide_mode_setting(&s_divide_mode_setting);
			
			switch_to_menu(MENU_ID_EMPTY_LOAD_SETTING);
		}
		else
		{
			s_focus_fun_arr[s_focus_item]();
			
			lcd_validate_cmd();
			
			s_edit_item = DIVIDE_MODE_NONE;
		}
	}
}
Ejemplo n.º 3
0
void init_menu(void)
{
	switch_to_menu(MENU_ID_WELCOME);
}
Ejemplo n.º 4
0
static void key_handler(void *msg)
{
	key_t key_msg = (key_t)(uint32_t)msg;
	uint8_t key = KEY_VALUE(key_msg);

	if (KEY_TYPE(key_msg) != MASK_KEY_PRESS && (key == KEY_OK || key == KEY_CANCEL))
	{
		return;
	}
	
	if (KEY_TYPE(key_msg) != MASK_KEY_RELEASE)
	{
		beeper_beep(BEEPER_VOL_LOW, 50, 50, 1);
		
		if (key == KEY_UP)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				s_cur_resist += BIG_RESIST_STEP;
				if (s_cur_resist > MAX_RESIST)
				{
					s_cur_resist = MAX_RESIST;
				}	
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_DOWN)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				if (s_cur_resist > BIG_RESIST_STEP)
				{
					s_cur_resist -= BIG_RESIST_STEP;
				}
				else
				{
					s_cur_resist = SMALL_RESIST_STEP;
				}
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_LEFT)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				if (s_cur_resist > SMALL_RESIST_STEP)
				{
					s_cur_resist -= SMALL_RESIST_STEP;
				}
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_RIGHT)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{	
				s_cur_resist += SMALL_RESIST_STEP;
				if (s_cur_resist > MAX_RESIST)
				{
					s_cur_resist = MAX_RESIST;
				}
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_OK)
		{
			if (KEY_TYPE(key_msg) == MASK_KEY_PRESS)
			{
				TEST_CMD test_cmd;
				
				if (s_cr_mode == CR_FOCUS_MODE)
				{	
					s_cur_resist = s_cr_mode_resist_set;
					draw_edit_resist_val(s_cur_resist);
				
					lcd_validate_cmd();
				
					s_cr_mode = CR_EDIT_MODE;		
					
					/* notify to start test */
					test_cmd.channel   = SLAVE_PORT_0;
					test_cmd.test_type = TEST_TYPE_CR_MODE;
					test_cmd.test_config.cr_mode_config.resist_val = s_cur_resist;
					test_cmd_notify(&test_cmd);

					TRACE("start testing\n");

					all_pass_led_on();
				}
				else
				{
					s_cr_mode_resist_set = s_cur_resist;
					draw_focus_resist_val(s_cr_mode_resist_set);
				
					lcd_validate_cmd();

					save_parameter(STRUCT_OFFSET(PARAMETER, cr_mode_resist_set), &s_cr_mode_resist_set, sizeof(s_cr_mode_resist_set));
					
					s_cr_mode = CR_FOCUS_MODE;
					
					/* notify to stop test */
					test_cmd.channel   = SLAVE_PORT_0;
					test_cmd.test_type = TEST_TYPE_NONE;
					test_cmd_notify(&test_cmd);		

					TRACE("stop testing\n");

					all_pass_led_off();
				}
			}
		}
		else if (key == KEY_CANCEL)
		{
			if (s_cr_mode == CR_FOCUS_MODE)
			{
				switch_to_menu(MENU_ID_MAIN);
			}
			else
			{
				TEST_CMD test_cmd;
				
				draw_focus_resist_val(s_cr_mode_resist_set);
				
				lcd_validate_cmd();
				
				s_cr_mode = CR_FOCUS_MODE;

				/* notify to stop test */
				test_cmd.channel   = SLAVE_PORT_0;
				test_cmd.test_type = TEST_TYPE_NONE;
				test_cmd_notify(&test_cmd);	

				TRACE("stop testing\n");

				all_pass_led_off();	
			}
		}
	}
	else
	{
		/* release */
		if (key == KEY_UP || key == KEY_DOWN
			|| key == KEY_LEFT || key == KEY_RIGHT)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				TEST_CMD test_cmd;
					
				/* notify */
				test_cmd.channel   = SLAVE_PORT_0;
				test_cmd.test_type = TEST_TYPE_CR_MODE;
				test_cmd.test_config.cr_mode_config.resist_val = s_cur_resist;
				test_cmd_notify(&test_cmd);

				TRACE("start testing\n");
			}
		}
	}
}