@@ -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,17 +443,28 @@ 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
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+ ) {
452461mvGravity0 .reset ();
453462mvGravity1 .reset ();
454463mvGravity2 .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
468481beep ();
469482
483+ calibrationPrecisionIncrement =0 ;
484+
470485currentStep ++;
471486startStep ();
472487 }