Exemplo n.º 1
0
        private void btnSetCalib_Click(object sender, EventArgs e)
        {
            if (cmbSensor.SelectedIndex < 1)
            {
                return;
            }
            var calibData = new USBCalibrationData();

            calibData.Init();
            calibData.Command = (byte)CALIB_SET;
            calibData.Sensor  = (byte)cmbSensor.SelectedIndex;
            short.TryParse(minX.Text, out calibData.RawMin[0]);
            short.TryParse(minY.Text, out calibData.RawMin[1]);
            short.TryParse(minZ.Text, out calibData.RawMin[2]);
            short.TryParse(maxX.Text, out calibData.RawMax[0]);
            short.TryParse(maxY.Text, out calibData.RawMax[1]);
            short.TryParse(maxZ.Text, out calibData.RawMax[2]);
            var command = USBCommandData.Create(CMD_CALIBRATE, calibData);
            var packet  = USBPacket.Create((byte)(COMMAND_DATA | DeviceType), (ushort)(DateTime.Now.Ticks / 1000), command);
            var d       = StructToBytes(packet);

            SetPacketCrc(ref d);
            //var data = new byte[USBPacket.Size];
            //Array.Copy(d, 1, data, 0, USBPacket.Size);
            lock (MonitorForm.OutgoingPackets)
                MonitorForm.OutgoingPackets.Enqueue(d);
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            seqErrors    = 0;
            lastSequence = 0;

            InfoRow.Cells[1].Value = "Missed: 0";
            InfoRow.Cells[2].Value = "Total: 0";
            InfoRow.Cells[3].Value = "Last: 0";
            InfoRow.Cells[4].Value = "Current: 0";


            var calibData = new USBCalibrationData();

            //if (AccelOffsetRow.Selected)
            calibData.Sensor = SENSOR_ACCEL;
            //else if (GyroOffsetRow.Selected)
            //    calibData.Sensor = SENSOR_GYRO;
            //else if (MagOffsetRow.Selected)
            //    calibData.Sensor = SENSOR_MAG;
            //else
            //    return;

            var posScales = new short[3];

            short.TryParse(txtPosX.Text, out posScales[0]);
            short.TryParse(txtPosY.Text, out posScales[1]);
            short.TryParse(txtPosZ.Text, out posScales[2]);

            var negScales = new short[3];

            short.TryParse(txtNegX.Text, out negScales[0]);
            short.TryParse(txtNegY.Text, out negScales[1]);
            short.TryParse(txtNegZ.Text, out negScales[2]);


            calibData.PosScale = posScales;
            calibData.NegScale = negScales;

            var command = USBCommandData.Create(CMD_CALIBRATE, calibData);
            var packet  = USBPacket.Create(COMMAND_DATA | HMD_SOURCE, (ushort)(DateTime.Now.Ticks / 1000), command);

            lock (_outgoing)
                _outgoing.Enqueue(packet);
        }