Ejemplo n.º 1
0
static PRESULT mlimit_itembtnref_callback(POBJECT_HEAD pObj, VEVENT event, UINT32 param1, UINT32 param2)
{
	PRESULT ret = PROC_PASS;
	VACTION unact;
	UINT8 back_saved;

	struct nim_device *nim_dev;

	nim_dev= antset_cur_tuner==0? g_nim_dev : g_nim_dev2;
	
	switch(event)
	{
	case EVN_UNKNOWN_ACTION:
		unact = (VACTION)(param1>>16);
		if(unact == VACT_GOTOREF)
		{
			api_diseqc_goto_reference(nim_dev,0);
			win_compopup_init(WIN_POPUP_TYPE_OK);
			win_compopup_set_msg(NULL, NULL, RS_MSG_MOVE_DISH_TO_REFERENCE_POINT);
            win_compopup_set_btnstr(0, RS_DISEQC12_MOVEMENT_STOP);
			win_compopup_open_ext(&back_saved);
			api_diseqc_halt_motor(nim_dev,0);	
		}
		break;
	}	

	return ret;
}
Ejemplo n.º 2
0
static PRESULT motorset_itembtn_callback(POBJECT_HEAD pObj, VEVENT event, UINT32 param1, UINT32 param2)
{
	PRESULT ret = PROC_PASS;
	VACTION unact;
	UINT8 bID;
	UINT8 back_saved;
	win_popup_choice_t choice;
	UINT32 position,sat_pos;
	struct nim_device *nim_dev;
	S_NODE s_node;

	nim_dev = antset_cur_tuner==0? g_nim_dev : g_nim_dev2;
	

	bID = OSD_GetObjID(pObj);

	switch(event)
	{
	case EVN_UNKNOWN_ACTION:
		unact = (VACTION)(param1>>16);

		if(unact == VACT_MOVE_WEST || unact == VACT_MOVE_EAST)
		{
			if(bID != MOVESAVE_ID)	break;

			if(diskmotor_move_state == 0 )
			{
				if(unact == VACT_MOVE_WEST)
				{
#ifdef FIRST_MOVE_BY_STEP				
					api_diseqc_drive_motor_west_by_steps(nim_dev,1,0);
					diskmotor_move_step = 0;
#else
					api_diseqc_drive_motor_west(nim_dev,0);
#endif
					diskmotor_move_state = 1;
				}
				else	//VACT_MOVE_EAST
				{
#ifdef FIRST_MOVE_BY_STEP				
					api_diseqc_drive_motor_east_by_steps(nim_dev,1,0);
					diskmotor_move_step = 0;
#else
					api_diseqc_drive_motor_east(nim_dev,0);
#endif					
					diskmotor_move_state = 2;				
				}

				api_stop_timer(&diskmove_timer_id);
                osal_task_sleep(100);
				DBG_PRINTF("Start move %d\n",diskmotor_move_state);
				diskmove_timer_id = api_start_timer(MOVE_TIERR_NAME, MOVE_TIERR_TIME,win_disk_move_handler);
				

SET_MOVE_DISPLAY:
				win_motorset_draw_info(diskmotor_move_state);
				win_motorset_movebtn_setstr(1);
				win_motorset_movebtn_draw(1);				
			}
			else
			{
				if( (diskmotor_move_state == 1 && unact == VACT_MOVE_WEST)
					|| (diskmotor_move_state ==2 && unact == VACT_MOVE_EAST))
				{	
					/* Continue move West or East*/
					DBG_PRINTF("Continue move %d\n",diskmotor_move_state);

#ifdef FIRST_MOVE_BY_STEP
					api_stop_timer(&diskmove_timer_id);
					if(diskmotor_move_step == 0)
					{
						osal_task_sleep(100);
						if(diskmotor_move_state== 1)
							api_diseqc_drive_motor_west(nim_dev,0);
						else
							api_diseqc_drive_motor_east(nim_dev,0);
						diskmotor_move_step = 1;
						DBG_PRINTF("First time continue move\n");
					}
                    //else
					//    DBG_PRINTF("Continue move %d\n",diskmotor_move_state);
#endif
					osal_task_sleep(100);
					diskmove_timer_id = api_start_timer(MOVE_TIERR_NAME, MOVE_TIERR_TIME,win_disk_move_handler);
				
				}
				else
					goto STOP_MOVE;
			}
			
		}
		else if(unact == VACT_ENTER)
		{			
			if(bID == MOVESAVE_ID)
			{
				if(diskmotor_move_state != 0)
					goto STOP_MOVE;
				else
				{
					/* Save current postion */
					OSD_GetEditFieldIntValue(&motorset_edf3,&position);

					get_tuner_sat(antset_cur_tuner,SAT_IDX,&s_node);
					if(position<=MAX_POSNUM)
					{
						sat_pos = antset_cur_tuner==0? s_node.position : s_node.tuner2_antena.position;

						if(sat_pos == position && position== 0)
						{
							win_compopup_init(WIN_POPUP_TYPE_OK);
							win_compopup_set_msg("Position not specified (1~63)", NULL, 0);
							win_compopup_open_ext(&back_saved);
							break;
						}
					
						win_compopup_init(WIN_POPUP_TYPE_OKNO);
						if(position == 0)
							win_compopup_set_msg("Are you sure to clear this satellite's position?", NULL, 0);
						else
							win_compopup_set_msg("Are you sure to change this satellite's position?", NULL, 0);							
						choice = win_compopup_open_ext(&back_saved);
						if(choice == WIN_POP_CHOICE_YES)
						{
							if(sat_pos != position)
							{
								recreate_sat_view(VIEW_ALL,0);
								if(antset_cur_tuner == 0)
									s_node.position = position;
								else
									s_node.tuner2_antena.position = position;
								modify_sat(s_node.sat_id, &s_node);
								update_data();
							}

							if(position != 0)
								api_diseqc_store_satellite_position(nim_dev, (UINT8)position,0);
						}
					}
					else
					{
						
					}
				}
			}
			else if(bID == GOTONN_ID)
			{
			
				position = (UINT32)win_motorset_gotonn_sub_list();
				if(position <= MAX_POSNUM)
				{
					if(position == 0)
						api_diseqc_goto_reference(nim_dev,0);
					else
						api_diseqc_goto_satellite_position(nim_dev,position,0);
					win_compopup_init(WIN_POPUP_TYPE_OK);
					win_compopup_set_msg("Wait to move the position!", NULL, 0);
                    win_compopup_set_btnstr(0, RS_DISEQC12_MOVEMENT_STOP);
					win_compopup_open_ext(&back_saved);
					api_diseqc_halt_motor(nim_dev,0);					
				}
				
			}
			else if(bID == RECACULATE_ID)
			{
				get_tuner_sat(antset_cur_tuner,SAT_IDX,&s_node);

				if(s_node.position==0)
				{
					win_compopup_init(WIN_POPUP_TYPE_SMSG);
					win_compopup_set_msg("Position is NULL", NULL,0);
					win_compopup_open_ext(&back_saved);
					osal_task_sleep(500);
					win_compopup_smsg_restoreback();
				}

				win_compopup_init(WIN_POPUP_TYPE_OKNO);
				win_compopup_set_msg("Are you sure re-calulate all satellite positions?", NULL, 0);
				choice = win_compopup_open_ext(&back_saved);
				if(choice == WIN_POP_CHOICE_YES)
					api_diseqc_calculate_satellite_position(nim_dev,s_node.position,0,0, 0);
			}
				
		}
		
		break;
	case EVN_UNKNOWNKEY_GOT:

		//if(bID == MOVESAVE_ID)
		if(diskmotor_move_state)
		{
STOP_MOVE:
			DBG_PRINTF("Stoped\n");
			api_stop_timer(&diskmove_timer_id);
			osal_task_sleep(50);
			api_diseqc_halt_motor(nim_dev,0);
			diskmotor_move_state = 0;

			win_motorset_draw_info(diskmotor_move_state);
			win_motorset_movebtn_setstr(0);
			win_motorset_movebtn_draw(1);
		}
		
		break;
	}
	return ret;
}