@@ -77,6 +77,8 @@ public class CalibrationActivity extends AppCompatActivity implements SensorEven
77
77
private final float [] calibrationGain = new float [3 ]; // The Gains of accelerometers
78
78
private final float [] calibrationAngle = new float [3 ]; // The calibration angles
79
79
80
+ private float calibrationPrecisionIncrement = 0 ; // The increment of the MIN_CALIBRATION_PRECISION in case of calibration reset
81
+
80
82
private AppCompatButton buttonNext ;
81
83
private ProgressBar progressBar ;
82
84
private ImageView imageViewMain ;
@@ -441,17 +443,28 @@ public void onSensorChanged(SensorEvent event) {
441
443
getString (R .string .calibration_tolerance ),
442
444
mvGravity0 .getTolerance ()));
443
445
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 ) ))));
445
447
progressBar .setSecondaryProgress (Math .max (progress1 , progress2 ));
446
448
progressBar .setProgress (Math .min (progress1 , progress2 ));
447
449
448
450
449
451
// DEVICE MOVED
450
452
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
+ ) {
452
461
mvGravity0 .reset ();
453
462
mvGravity1 .reset ();
454
463
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
+
455
468
}
456
469
457
470
// END OF CALIBRATION STEP
@@ -467,6 +480,8 @@ public void onSensorChanged(SensorEvent event) {
467
480
468
481
beep ();
469
482
483
+ calibrationPrecisionIncrement = 0 ;
484
+
470
485
currentStep ++;
471
486
startStep ();
472
487
}
0 commit comments