123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- #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));
- }
|