special_motion.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "special_motion.h"
  2. int down_send_count = 0;
  3. int is_down;
  4. int jump_send_count = 0;
  5. int is_jump = 0;
  6. void special_motion(int time_stamp, uint16_t h_press, uint16_t s_press, int16_t h_pos[3], int16_t s_pos[3], int16_t *down, int16_t *jump, float acc[3])
  7. {
  8. int32_t left_press = (((int32_t)h_press & 0x0000ffff)<<8);
  9. int32_t right_press = (((int32_t)s_press & 0x0000ffff)<<8);
  10. /*
  11. 处理蹲的动作
  12. */
  13. short down_tag = 0;
  14. down_tag = press_down_detect_new(time_stamp, left_press, right_press, h_pos[2], s_pos[2], acc[2]);
  15. if (down_tag)
  16. {
  17. /*
  18. gpio_mt_run(300);
  19. */
  20. down_send_count = 20;
  21. }
  22. if(down_send_count > 0)
  23. {
  24. is_down = 1;
  25. down_send_count --;
  26. }
  27. else
  28. {
  29. is_down = 0;
  30. }
  31. /*
  32. 处理跳的动作
  33. */
  34. short jump_tag = 0;
  35. jump_tag = press_jump_detect(h_pos, s_pos);
  36. if (jump_tag)
  37. {
  38. /*
  39. gpio_mt_run(300);
  40. */
  41. jump_send_count = 20;
  42. }
  43. //连续发20次蹲,终端再处理
  44. if(jump_send_count > 0)
  45. {
  46. is_jump = 1;
  47. jump_send_count --;
  48. }
  49. else
  50. {
  51. is_jump = 0;
  52. }
  53. *down = is_down;
  54. *jump = is_jump;
  55. }