Exemple #1
0
 static PSVRSensorReport()
 {
     BMI055Integrator.Init(BMI055Integrator.AScale.AFS_2G, BMI055Integrator.Gscale.GFS_2000DPS);
 }
Exemple #2
0
        public static PSVRSensorReport parseSensor(byte[] data)
        {
            PSVRSensorReport sensor = new PSVRSensorReport();

            if (data == null)
            {
                return(sensor);
            }

            sensor.Buttons = (HeadsetButtons)data[0];
            sensor.Volume  = data[2];

            sensor.Worn          = (data[8] & 0x1) == 0x1 ? true : false;        //confirmed
            sensor.DisplayActive = (data[8] & 0x2) == 0x2 ? false : true;
            sensor.Muted         = (data[8] & 0x8) == 0x8 ? true : false;        //confirmed

            sensor.EarphonesConnected = (data[8] & 0x10) == 0x10 ? true : false; //confirmed

            sensor.Timestamp1 = getUIntFromUInt32(data, 16);

            sensor.RawGyroYaw1   = getIntFromInt16(data, 20);
            sensor.RawGyroPitch1 = getIntFromInt16(data, 22);
            sensor.RawGyroRoll1  = getIntFromInt16(data, 24);

            sensor.RawMotionX1 = getAccelShort(data, 26);
            sensor.RawMotionY1 = getAccelShort(data, 28);
            sensor.RawMotionZ1 = getAccelShort(data, 30);

            sensor.Timestamp2 = getUIntFromUInt32(data, 32);

            sensor.RawGyroYaw2   = getIntFromInt16(data, 36);
            sensor.RawGyroPitch2 = getIntFromInt16(data, 38);
            sensor.RawGyroRoll2  = getIntFromInt16(data, 40);

            sensor.RawMotionX2 = getAccelShort(data, 42);
            sensor.RawMotionY2 = getAccelShort(data, 44);
            sensor.RawMotionZ2 = getAccelShort(data, 46);

            sensor.CalStatus = data[48];
            sensor.Ready     = data[49];

            sensor.A = data[50];
            sensor.B = data[51];
            sensor.C = data[52];

            sensor.VoltageValue     = data[53];
            sensor.VoltageReference = data[54];
            sensor.IRSensor         = getIntFromInt16(data, 55);

            sensor.D = data[58];
            sensor.E = data[59];
            sensor.F = data[60];
            sensor.G = data[61];
            sensor.H = data[62];

            sensor.PacketSequence = data[63];

            //BMI055Integrator.Parse(data, 26, 20, sensor.Timestamp1);
            //sensor.Pose = BMI055Integrator.Parse(data, 42, 36, sensor.Timestamp2);

            BMI055Integrator.Parse(sensor);

            return(sensor);
        }