Skip to content

Commit

Permalink
set sensibility for playing sound independent from sensor sensibility
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Oct 13, 2021
1 parent 4d678f6 commit 7b589d8
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.woheller69.level.orientation;

import android.util.Log;

/*
* This file is part of Level (an Android Bubble Level).
* <https://github.com/avianey/Level>
Expand Down Expand Up @@ -44,10 +46,11 @@ private Orientation(int reverse, int rotation) {
}

public boolean isLevel(float pitch, float roll, float balance, float sensibility) {
if (sensibility<0.2f) sensibility=0.2f; //minimum sensibility for playing sound (play sound even if sensor sensibility is better)
switch (this) {
case BOTTOM :
case TOP :
return balance <= sensibility
return balance <= sensibility
&& balance >= - sensibility;
case LANDING :
return roll <= sensibility
Expand All @@ -56,7 +59,7 @@ public boolean isLevel(float pitch, float roll, float balance, float sensibility
|| Math.abs(pitch) >= 180 - sensibility);
case LEFT :
case RIGHT :
return Math.abs(pitch) <= sensibility
return Math.abs(pitch) <= sensibility
|| Math.abs(pitch) >= 180 - sensibility;
}
return false;
Expand Down

0 comments on commit 7b589d8

Please sign in to comment.