#include "MonsterH5.h" void MonsterH5::Process(int* right_pos, int* right_att, int* right_acc, int right_zupt, int right_press, int* left_pos, int* left_att, int* left_acc, int left_zupt, int left_press, int jump, int down, int rssi) { static int right_zupt_count = 0; static int left_zupt_count = 0; static int last_right_zupt = 0; static int last_left_zupt = 0; static int right_wait = 0; static int left_wait = 0; int right_is_zupt = 0; static int left_trigger_wait = 0; static int right_trigger_wait = 0; static float left_max_z_unzero = 1.0f; static float left_min_z_unzero = 1.0f; static float right_max_z_unzero = 1.0f; static float right_min_z_unzero = 1.0f; if (right_trigger_wait > 0) { float right_acc_z = right_acc[2] / 2048.f; if (right_acc_z > right_max_z_unzero) { right_max_z_unzero = right_acc_z; } if (right_acc_z < right_min_z_unzero) { right_min_z_unzero = right_acc_z; } } else { right_max_z_unzero = 1.0f; right_min_z_unzero = 1.0f; } if (left_trigger_wait > 0) { float left_acc_z = left_acc[2] / 2048.f; if (left_acc_z > left_max_z_unzero) { left_max_z_unzero = left_acc_z; } if (left_acc_z < left_min_z_unzero) { left_min_z_unzero = left_acc_z; } } else { left_max_z_unzero = 1.0f; left_min_z_unzero = 1.0f; } if (right_zupt == 1 && last_right_zupt == 0 && (right_trigger_wait <= 0 || (right_max_z_unzero >2.0f && right_min_z_unzero <0.0f))) //if (right_zupt == 1 && last_right_zupt == 0) { std::cout << "ÓҽŴ¥·¢Ì¤µØ" << endl; result[1] = 1; right_wait = 5; right_max_z_unzero = 1.0f; right_min_z_unzero = 1.0f; } else { result[1] = 0; } if (left_zupt == 1 && last_left_zupt == 0 && (left_trigger_wait <=0 || (left_max_z_unzero > 2.0f && left_min_z_unzero < 0.0f))) { std::cout << "×ó½Å´¥·¢Ì¤µØ" << endl; result[0] = 1; left_wait = 5; left_max_z_unzero = 1.0f; left_min_z_unzero = 1.0f; } else { result[0] = 0; } //ÅжÏË«½Å´¥µ× if (right_wait > 0 && left_wait > 0) { result[2] = 1; std::cout << "Ë«½Å²ÈµØ" << std::endl; } else { result[2] = 0; } if (right_zupt == 1) { right_trigger_wait = 15; } else { right_trigger_wait--; } if (left_zupt == 1) { left_trigger_wait = 15; } else { left_trigger_wait--; } last_right_zupt = right_zupt; last_left_zupt = left_zupt; if (left_wait > 0) { left_wait--; } if (right_wait > 0) { right_wait--; } if (right_trigger_wait > 0) { right_trigger_wait--; } if (left_trigger_wait > 0) { left_trigger_wait--; } } void MonsterH5::getResult(int* dec) { memcpy(dec, result, 4 * sizeof(int)); }