Beispiel #1
0
        private void Gyroscope_OnInterrupt(object sender, GyroscopeEventArgs e)
        {
            foreach (MpuSensorValue v in e.Values)
            {
                if (Math.Abs(v.GyroZ) > 0.5)
                {
                    Direction = Direction + v.GyroZ * e.SamplePeriod;
                }
                if (Direction >= 360)
                {
                    Direction = Direction - 360;
                }
                else if (Direction < 0)
                {
                    Direction = Direction + 360;
                }
            }

            AccelerationX = -e.Values[0].AccelerationX;
            AccelerationY = e.Values[0].AccelerationY;
            AccelerationZ = e.Values[0].AccelerationZ;

            if (Math.Abs(AccelerationX) > 0.02)
            {
                Xspeed       = Xspeed + AccelerationX * e.SamplePeriod;
                Displacement = Displacement + Xspeed * e.SamplePeriod;
            }
        }
Beispiel #2
0
 void gyro(object sender, GyroscopeEventArgs g)
 {
     Debug.Log("Data G: " + g.Gyroscope.x);
 }