AHRSInterface.GyroCal.computegyroCalButton_Click C# (CSharp) Method

computegyroCalButton_Click() private method

private computegyroCalButton_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void computegyroCalButton_Click(object sender, EventArgs e)
        {
            int i,j;

            calStatusText.Text = "Computing Calibration...";

            bias[0] = 0;
            for (i = 0; i < SAMPLES; i++)
            {
                bias[0] += loggedData[i, 0];
            }
            bias[0] = bias[0] / SAMPLES;

            bias[1] = 0;
            for (i = 0; i < SAMPLES; i++)
            {
                bias[1] += loggedData[i, 1];
            }
            bias[1] = bias[1] / SAMPLES;

            bias[2] = 0;
            for (i = 0; i < SAMPLES; i++)
            {
                bias[2] += loggedData[i, 2];
            }
            bias[2] = bias[2] / SAMPLES;
            calMat[0, 0] = 1.0;
            calMat[0, 1] = 0.0;
            calMat[0, 2] = 0.0;
            calMat[1, 0] = 0.0;
            calMat[1, 1] = 1.0;
            calMat[1, 2] = 0.0;
            calMat[2, 0] = 0.0;
            calMat[2, 1] = 0.0;
            calMat[2, 2] = 1.0;

            gyroAlignment00.Text = calMat[0, 0].ToString();
            gyroAlignment01.Text = calMat[0, 1].ToString();
            gyroAlignment02.Text = calMat[0, 2].ToString();

            gyroAlignment10.Text = calMat[1, 0].ToString();
            gyroAlignment11.Text = calMat[1, 1].ToString();
            gyroAlignment12.Text = calMat[1, 2].ToString();

            gyroAlignment20.Text = calMat[2, 0].ToString();
            gyroAlignment21.Text = calMat[2, 1].ToString();
            gyroAlignment22.Text = calMat[2, 2].ToString();

            biasX.Text = bias[0].ToString();
            biasY.Text = bias[1].ToString();
            biasZ.Text = bias[2].ToString();

            calStatusText.Text = "Done";
            flashCommitButton.Enabled = true;
            gyroAlignmentCommitButton.Enabled = true;
        }