コード例 #1
0
ファイル: joystick_controller.c プロジェクト: InSoonPark/asf
__interrupt
#endif
void touch_button_isr(void)
{
  manage_button_isr(QT1081_TOUCH_SENSOR_UP, JOYSTICK_STATUS_UP, JOYSTICK_STATUS_RELEASED_UP);
  manage_button_isr(QT1081_TOUCH_SENSOR_DOWN, JOYSTICK_STATUS_DOWN, JOYSTICK_STATUS_RELEASED_DOWN);
  manage_button_isr(QT1081_TOUCH_SENSOR_RIGHT, JOYSTICK_STATUS_RIGHT, JOYSTICK_STATUS_RELEASED_RIGHT);
  manage_button_isr(QT1081_TOUCH_SENSOR_LEFT, JOYSTICK_STATUS_LEFT, JOYSTICK_STATUS_RELEASED_LEFT);
  manage_button_isr(QT1081_TOUCH_SENSOR_ENTER, JOYSTICK_STATUS_PRESSED, JOYSTICK_STATUS_RELEASED_PRESSED);

  // Handle left slide
  if (IS_JOYSTICK_RELEASED_KEY_PRESSED() && IS_JOYSTICK_KEY_LEFT())
  {
    CLEAR_JOYSTICK_RELEASED_KEY_PRESSED();
    CLEAR_JOYSTICK_KEY_LEFT();
    joystick_status |= JOYSTICK_STATUS_SLIDING_LEFT;
  }
  if (IS_JOYSTICK_KEY_SLIDING_LEFT() && IS_JOYSTICK_RELEASED_KEY_LEFT())
  {
    CLEAR_JOYSTICK_KEY_SLIDING_LEFT();
    CLEAR_JOYSTICK_RELEASED_KEY_LEFT();
    joystick_status |= JOYSTICK_STATUS_SLIDE_LEFT;
  }
  // Handle right slide
  if (IS_JOYSTICK_RELEASED_KEY_PRESSED() && IS_JOYSTICK_KEY_RIGHT())
  {
    CLEAR_JOYSTICK_RELEASED_KEY_PRESSED();
    CLEAR_JOYSTICK_KEY_RIGHT();
    joystick_status |= JOYSTICK_STATUS_SLIDING_RIGHT;
  }
  if (IS_JOYSTICK_KEY_SLIDING_RIGHT() && IS_JOYSTICK_RELEASED_KEY_RIGHT())
  {
    CLEAR_JOYSTICK_KEY_SLIDING_RIGHT();
    CLEAR_JOYSTICK_RELEASED_KEY_RIGHT();
    joystick_status |= JOYSTICK_STATUS_SLIDE_RIGHT;
  }

  if (fast_mode && cpu_is_timeout(&joystick_key_sensibility_timer))
  {
    CLEAR_JOYSTICK_RELEASED_KEY_RIGHT();
    CLEAR_JOYSTICK_RELEASED_KEY_LEFT();
  }

  if (!IS_JOYSTICK_KEY_LEFT() && !IS_JOYSTICK_KEY_RIGHT())
    fast_mode = false;

  gpio_tgl_gpio_pin(LED0_GPIO);
}
コード例 #2
0
__interrupt
#endif
void touch_button_isr(void)
{
  manage_button_isr(QT1081_TOUCH_SENSOR_UP, JOYSTICK_STATUS_UP, JOYSTICK_STATUS_RELEASED_UP);
  manage_button_isr(QT1081_TOUCH_SENSOR_DOWN, JOYSTICK_STATUS_DOWN, JOYSTICK_STATUS_RELEASED_DOWN);
  manage_button_isr(QT1081_TOUCH_SENSOR_RIGHT, JOYSTICK_STATUS_RIGHT, JOYSTICK_STATUS_RELEASED_RIGHT);
  manage_button_isr(QT1081_TOUCH_SENSOR_LEFT, JOYSTICK_STATUS_LEFT, JOYSTICK_STATUS_RELEASED_LEFT);
  manage_button_isr(QT1081_TOUCH_SENSOR_ENTER, JOYSTICK_STATUS_PRESSED, JOYSTICK_STATUS_RELEASED_PRESSED);

  if (IS_JOYSTICK_KEY_UP())
    gpio_clr_gpio_pin(LED1_GPIO);
  else
    gpio_set_gpio_pin(LED1_GPIO);
  if (IS_JOYSTICK_KEY_PRESSED())
    gpio_clr_gpio_pin(LED2_GPIO);
  else
    gpio_set_gpio_pin(LED2_GPIO);
  if (IS_JOYSTICK_KEY_DOWN())
    gpio_clr_gpio_pin(LED3_GPIO);
  else
    gpio_set_gpio_pin(LED3_GPIO);
}