/*! \brief Detect 30 and 60 angles */ void print_angles() { signed int res; static xyz_t angle ; // if ( ! is_acc_slow() ) { return } if( 0!=(res=is_acc_abs_angle_x(60)) ) angle.x = 60; else if( 0!=(res=is_acc_abs_angle_x(30)) ) angle.x = 30; else angle.x = 0 ; if ( angle.x > 0 ) { if( res>0 ) print_dbg("LEFT ") ; else if( res<0 ) print_dbg("RIGHT ") ; print_dbg_ulong(angle.x) ; print_dbg("\r\n") ; } if( 0!=(res=is_acc_abs_angle_y(60)) ) angle.y = 60; else if( 0!=(res=is_acc_abs_angle_y(30)) ) angle.y = 30; else angle.y = 0 ; if ( angle.y > 0 ) { if( res>0 ) print_dbg("DOWN ") ; else if( res<0 ) print_dbg("UP ") ; print_dbg_ulong(angle.y) ; print_dbg("\r\n") ; } }
//! //! @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; }