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

Does detect work while travelling? #26

Open
dhikshithrm opened this issue Aug 27, 2023 · 0 comments
Open

Does detect work while travelling? #26

dhikshithrm opened this issue Aug 27, 2023 · 0 comments

Comments

@dhikshithrm
Copy link

I saw this package was based on the device acceleration on the x, y, and z axes, based on the code below, it isn't clear from the code below that it's considering to ignore constant accelerations. Or does the shakeThresholdGravity keep that in check?

shake/lib/shake.dart

Lines 62 to 87 in a11b016

double gX = x / 9.80665;
double gY = y / 9.80665;
double gZ = z / 9.80665;
// gForce will be close to 1 when there is no movement.
double gForce = sqrt(gX * gX + gY * gY + gZ * gZ);
if (gForce > shakeThresholdGravity) {
var now = DateTime.now().millisecondsSinceEpoch;
// ignore shake events too close to each other (500ms)
if (mShakeTimestamp + shakeSlopTimeMS > now) {
return;
}
// reset the shake count after 3 seconds of no shakes
if (mShakeTimestamp + shakeCountResetTime < now) {
mShakeCount = 0;
}
mShakeTimestamp = now;
mShakeCount++;
if (mShakeCount >= minimumShakeCount) {
onPhoneShake();
}
}

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