I am trying to calibrate an accelerometer, but I cannot get 6 sample values ββat 6 different acceleration readings needed for calibration. Preliminary W is a double array [6] [3] designed to populate these sample values. This is 6 by 3 because every acceleration read has components x, y and z.
I plan to try them by pressing a button on 6 different acceleration readings. This button makes the "calibrate" true.
Of course, I will first do a βcalibrationβ of true to start this chain.
For some incomprehensible reason, the preliminary W [i] = currentAcc seems to populate from 0 to i with the same value, not just i. I made sure that currentAcc is different every time I click the calibrate button.
What is wrong with my code?
public synchronized void run() {
Log.d(TAG, "+ in Calibrator thread +");
int i = -1;
while (calibrating) {
if (calibrate) {
i = i + 1;
calibrate = false;
preliminaryW[i] = currentAcc;
if (i == 5) {
calibrating = false;
}
}
}
}
source
share