Skip to content

Commit 5fe3ed0

Browse files
Update to v1.2.4
2 parents 3791726 + 429efc3 commit 5fe3ed0

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

apk/Clinometer-1.2.4.apk

5.7 MB
Binary file not shown.

apk/Clinometer-latest.apk

237 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010

1111
// -----------------------------------------------------------------------------------------
1212
// We use the Semantic Versioning (https://semver.org/):
13-
versionName '1.2.3'
14-
versionCode 9
13+
versionName '1.2.4'
14+
versionCode 10
1515
// -----------------------------------------------------------------------------------------
1616

1717
vectorDrawables.useSupportLibrary = true

app/src/main/java/eu/basicairdata/clinometer/CalibrationActivity.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public class CalibrationActivity extends AppCompatActivity implements SensorEven
7777
private final float[] calibrationGain = new float[3]; // The Gains of accelerometers
7878
private final float[] calibrationAngle = new float[3]; // The calibration angles
7979

80+
private float calibrationPrecisionIncrement = 0; // The increment of the MIN_CALIBRATION_PRECISION in case of calibration reset
81+
8082
private AppCompatButton buttonNext;
8183
private ProgressBar progressBar;
8284
private ImageView imageViewMain;
@@ -441,17 +443,28 @@ public void onSensorChanged(SensorEvent event) {
441443
getString(R.string.calibration_tolerance),
442444
mvGravity0.getTolerance()));
443445
int progress1 = (int) (10 * mvGravity0.percentLoaded());
444-
int progress2 = (int) (Math.min(1000, Math.max(0, 1000 - 1000 *(mvGravity0.getTolerance() / MIN_CALIBRATION_PRECISION))));
446+
int progress2 = (int) (Math.min(1000, Math.max(0, 1000 - 1000 *(mvGravity0.getTolerance() / (MIN_CALIBRATION_PRECISION + calibrationPrecisionIncrement)))));
445447
progressBar.setSecondaryProgress(Math.max(progress1, progress2));
446448
progressBar.setProgress(Math.min(progress1, progress2));
447449

448450

449451
// DEVICE MOVED
450452

451-
if (mvGravity0.isReady() && (mvGravity0.getTolerance() > MIN_CALIBRATION_PRECISION)) {
453+
//Log.d("Clinometer",String.format("[#] Mean value = %+1.5f Reading = %+1.5f Difference = %+1.5f", mvGravity0.getMeanValue(), event.values[0], mvGravity0.getMeanValue() - event.values[0]));
454+
455+
//if (mvGravity0.isReady() && (mvGravity0.getTolerance() > MIN_CALIBRATION_PRECISION)) {
456+
if (mvGravity0.isReady() && (
457+
(Math.abs(mvGravity0.getMeanValue() - event.values[0]) > (MIN_CALIBRATION_PRECISION + calibrationPrecisionIncrement)) ||
458+
(Math.abs(mvGravity1.getMeanValue() - event.values[1]) > (MIN_CALIBRATION_PRECISION + calibrationPrecisionIncrement)) ||
459+
(Math.abs(mvGravity2.getMeanValue() - event.values[2]) > (MIN_CALIBRATION_PRECISION + calibrationPrecisionIncrement)))
460+
) {
452461
mvGravity0.reset();
453462
mvGravity1.reset();
454463
mvGravity2.reset();
464+
if (calibrationPrecisionIncrement < 0.15f) calibrationPrecisionIncrement += 0.01f;
465+
//Log.d("Clinometer",String.format("[#] Mean value = %+1.5f Reading = %+1.5f Difference = %+1.5f", mvGravity0.getMeanValue(), event.values[0], mvGravity0.getMeanValue() - event.values[0]));
466+
Log.d("Clinometer",String.format("[#] New calibration precision = %+1.5f", MIN_CALIBRATION_PRECISION + calibrationPrecisionIncrement));
467+
455468
}
456469

457470
// END OF CALIBRATION STEP
@@ -467,6 +480,8 @@ public void onSensorChanged(SensorEvent event) {
467480

468481
beep();
469482

483+
calibrationPrecisionIncrement = 0;
484+
470485
currentStep++;
471486
startStep();
472487
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixes the calibration problem in some devices
1.26 MB
Binary file not shown.

0 commit comments

Comments
 (0)