Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于ActiveDetector_Shake::getState() 代码的一些问题 #32

Open
YanFuHai06 opened this issue Sep 22, 2020 · 0 comments
Open

关于ActiveDetector_Shake::getState() 代码的一些问题 #32

YanFuHai06 opened this issue Sep 22, 2020 · 0 comments

Comments

@YanFuHai06
Copy link

感谢分享,在AliveDetector.hActiveDetector_Shake类中getState()方法有一些不理解。

bool getState() {
      if (idx < CYCLE_ACTIVE)
            return false;
        int sum = 0;
        bool flag = 0;
        for (int i = 0; i < CYCLE_ACTIVE; i++) {
            if (frames[i] > 11 || frames[i] < -11) {
                flag = 1;
            }
            if (frames[i] > 8)
                sum++;
            else if (frames[i] < -8)
                sum--;
        }
        if (abs(sum - 0) < 6 && flag == 1)
            return true;
        else
            return false;
    }
  1. 为什么frames[i]<-8时,sum需要--;

  2. 为什么最后if判断时需要判断“abs(sum-0)<6”;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant