Exemplo n.º 1
0
Arquivo: ui.c Projeto: InSoonPark/asf
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED1);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED1);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if (2 > cpt_sof)
		return;
	cpt_sof = 0;

	// No Scan buttons

	// Look touch sensor activity for the X and Y events
	if (is_touch_sensor_2())
		udi_hid_mouse_moveX(MOUSE_MOVE_RANGE);
	if (is_touch_sensor_3())
		udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
	if (is_touch_sensor_1())
		udi_hid_mouse_moveY(MOUSE_MOVE_RANGE);
	if (is_touch_sensor_0())
		udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
}
Exemplo n.º 2
0
bool is_joystick_left(void){
  return is_touch_sensor_3();
}
Exemplo n.º 3
0
//!
//! @brief Looks for mouse events.
//!
bool is_usb_mouse_event( void )
{
   static uint8_t   disp=1;
   static uint16_t  count=0;
#if BOARD != EVK1104 && BOARD != UC3C_EK && BOARD != EVK1105
   static bool old_click_0=false;  // false means released, true means pushed
   static bool old_click_1=false;  // false means released, true means pushed
#endif
#if BOARD == EVK1100
   static bool old_click_2=false;  // false means released, true means pushed
#endif
   bool b_activity;

   u8_report_buttons=0;
   u8_report_disp_x=0;
   u8_report_disp_y=0;
   u8_report_disp_wheel=0;
   b_activity=false;

#if BOARD == EVK1101
   signed int res;

   // Get accelerometer acquisition and process data
   acc_update();

   // Look joystick activity for the Wheel events
   // input is pulled up, if 1 : input is not active
   if( is_joystick_up() )
     u8_report_disp_wheel=disp, b_activity=true;

   if( is_joystick_down() )
     u8_report_disp_wheel=-disp, b_activity=true;

   // Look accelerometer activity for the X and Y events
   if( 0!=(res=is_acc_abs_angle_x(40)) )
   {
     if(      res>0 )
       u8_report_disp_x=-10*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_x=10*disp, b_activity=true;
   }
   else if( 0!=(res=is_acc_abs_angle_x(30)) )
   {
     if(      res>0 )
       u8_report_disp_x=-6*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_x=6*disp, b_activity=true;
   }
   else if( 0!=(res=is_acc_abs_angle_x(20)) )
   {
     if(      res>0 )
       u8_report_disp_x=-4*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_x=4*disp, b_activity=true;
   }

   else if( 0!=(res=is_acc_abs_angle_x(15)) )
   {
     if(      res>0 )
       u8_report_disp_x=-2*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_x=2*disp, b_activity=true;
   }
   else if( 0!=(res=is_acc_abs_angle_x(10)) )
   {
     if(      res>0 )
       u8_report_disp_x=-disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_x=disp, b_activity=true;
   }



   if( 0!=(res=is_acc_abs_angle_y(40)) )
   {
     if(      res>0 )
       u8_report_disp_y=-10*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_y=10*disp, b_activity=true;
   }
   else if( 0!=(res=is_acc_abs_angle_y(30)) )
   {
     if(      res>0 )
       u8_report_disp_y=-6*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_y=6*disp, b_activity=true;
   }
   else if( 0!=(res=is_acc_abs_angle_y(20)) )
   {
     if(      res>0 )
       u8_report_disp_y=-4*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_y=4*disp, b_activity=true;
   }
   else if( 0!=(res=is_acc_abs_angle_y(15)) )
   {
     if(      res>0 )
       u8_report_disp_y=-2*disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_y=2*disp, b_activity=true;
   }
   else if( 0!=(res=is_acc_abs_angle_y(10)) )
   {
     if(      res>0 )
       u8_report_disp_y=-disp, b_activity=true;
     else if( res<0 )
       u8_report_disp_y=disp, b_activity=true;
   }

#elif BOARD == EVK1100

   // Look Joystick activity for the X and Y events
   // input is pulled up, if 1 : input is not active
   if (is_joystick_right())
      u8_report_disp_x=disp, b_activity=true;

   if (is_joystick_left())
      u8_report_disp_x=-disp, b_activity=true;

   if (is_joystick_down())
      u8_report_disp_y=disp, b_activity=true;

   if (is_joystick_up())
      u8_report_disp_y=-disp, b_activity=true;

#elif BOARD == EVK1105

   // Right
   if (is_touch_sensor_2())
      u8_report_disp_x=disp, b_activity=true;
   // Left
   if (is_touch_sensor_3())
      u8_report_disp_x=-disp, b_activity=true;
   // Down
   if (is_touch_sensor_1())
      u8_report_disp_y=disp, b_activity=true;
   // Up
   if (is_touch_sensor_0())
      u8_report_disp_y=-disp, b_activity=true;

#elif BOARD == EVK1104
   if (gpio_get_pin_value(GPIO_PUSH_BUTTON_SW2) == GPIO_PUSH_BUTTON_SW2_PRESSED)
      u8_report_disp_y=-disp, b_activity=true;
#elif BOARD == UC3C_EK
   // mouse pointer down
   if( !gpio_get_pin_value(GPIO_PUSH_BUTTON_0)) {
     u8_report_disp_y=disp, b_activity=true;
   }

      // mouse pointer up
   if( !gpio_get_pin_value(GPIO_PUSH_BUTTON_1)) {
     u8_report_disp_y=-disp, b_activity=true;
   }
#endif

   if( b_activity )
   {
      count++;
      if( count >= DISP_LIMIT_HIGH )
         disp=3;
      else if( count >= DISP_LIMIT_LOW )
         disp=2;
   }
   else
      count=0, disp=1;



   // Look for button activity
#if BOARD != EVK1104 && BOARD != UC3C_EK && BOARD != EVK1105
   // input is pulled up, if 1 : input is not active
   if( (!gpio_get_pin_value(GPIO_PUSH_BUTTON_0))
   ||  (is_joystick_pressed()                  ) )
   {
      Set_bits(u8_report_buttons, BUTTON_0_EVENT_PUSH);
      if( old_click_0==false )
         old_click_0=true, b_activity=true;
   }
   else
      if( old_click_0==true )
         old_click_0=false, b_activity=true;



   if( !gpio_get_pin_value(GPIO_PUSH_BUTTON_1) )
   {
      Set_bits(u8_report_buttons, BUTTON_1_EVENT_PUSH);
      if( old_click_1==false )
         old_click_1=true, b_activity=true;
   }
   else
      if( old_click_1==true )
         old_click_1=false, b_activity=true;
#endif
#if BOARD == EVK1100
   if( !gpio_get_pin_value(GPIO_PUSH_BUTTON_2) )
   {
      Set_bits(u8_report_buttons, BUTTON_2_EVENT_PUSH);
      if( old_click_2==false )
         old_click_2=true, b_activity=true;
   }
   else
      if( old_click_2==true )
         old_click_2=false, b_activity=true;
#endif

   if( b_activity )  return true;
   else              return false;
}
Exemplo n.º 4
0
bool controller_connect(void)
{
  return is_touch_sensor_3();
}