@@ -63,7 +63,7 @@ public class CalibrationActivity extends AppCompatActivity implements SensorEven
6363private Vibrator vibrator ;
6464
6565private final static int ACCELEROMETER_UPDATE_INTERVAL_MICROS =10000 ;
66- private final static float MIN_CALIBRATION_PRECISION =0.15f ;
66+ private final static float MIN_CALIBRATION_PRECISION =0.05f ;
6767private final static int SIZE_OF_MEANVARIANCE =300 ;// 4 seconds
6868
6969
@@ -77,6 +77,8 @@ public class CalibrationActivity extends AppCompatActivity implements SensorEven
7777private final float []calibrationGain =new float [3 ];// The Gains of accelerometers
7878private 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+
8082private AppCompatButton buttonNext ;
8183private ProgressBar progressBar ;
8284private ImageView imageViewMain ;
@@ -441,7 +443,7 @@ public void onSensorChanged(SensorEvent event) {
441443getString (R .string .calibration_tolerance ),
442444mvGravity0 .getTolerance ()));
443445int 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 ) ))));
445447progressBar .setSecondaryProgress (Math .max (progress1 ,progress2 ));
446448progressBar .setProgress (Math .min (progress1 ,progress2 ));
447449
@@ -452,13 +454,17 @@ public void onSensorChanged(SensorEvent event) {
452454
453455//if (mvGravity0.isReady() && (mvGravity0.getTolerance() > MIN_CALIBRATION_PRECISION)) {
454456if (mvGravity0 .isReady () && (
455- (Math .abs (mvGravity0 .getMeanValue () -event .values [0 ]) >MIN_CALIBRATION_PRECISION ) ||
456- (Math .abs (mvGravity1 .getMeanValue () -event .values [1 ]) >MIN_CALIBRATION_PRECISION ) ||
457- (Math .abs (mvGravity2 .getMeanValue () -event .values [2 ]) >MIN_CALIBRATION_PRECISION ))
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 ) ))
458460 ) {
459461mvGravity0 .reset ();
460462mvGravity1 .reset ();
461463mvGravity2 .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+
462468 }
463469
464470// END OF CALIBRATION STEP
@@ -474,6 +480,8 @@ public void onSensorChanged(SensorEvent event) {
474480
475481beep ();
476482
483+ calibrationPrecisionIncrement =0 ;
484+
477485currentStep ++;
478486startStep ();
479487 }