Ejemplo n.º 1
0
        public void GyroscopeData_Comparison(
            float x1,
            float y1,
            float z1,
            float x2,
            float y2,
            float z2,
            bool equals)
        {
            var data1 = new GyroscopeData(x1, y1, z1);
            var data2 = new GyroscopeData(x2, y2, z2);

            if (equals)
            {
                Assert.True(data1.Equals(data2));
                Assert.True(data1 == data2);
                Assert.False(data1 != data2);
                Assert.Equal(data1, data2);
                Assert.Equal(data1.GetHashCode(), data2.GetHashCode());
            }
            else
            {
                Assert.False(data1.Equals(data2));
                Assert.False(data1 == data2);
                Assert.True(data1 != data2);
                Assert.NotEqual(data1, data2);
                Assert.NotEqual(data1.GetHashCode(), data2.GetHashCode());
            }
        }
Ejemplo n.º 2
0
        static void DataUpdated(object sender, GyrometerReadingChangedEventArgs e)
        {
            var reading = e.Reading;
            var data    = new GyroscopeData(reading.AngularVelocityX, reading.AngularVelocityY, reading.AngularVelocityZ);

            OnChanged(data);
        }
Ejemplo n.º 3
0
        void Gyroscope_ReadingChanged(object sender, GyroscopeChangedEventArgs e)
        {
            GyroscopeData data = e.Reading;

            valX = data.AngularVelocity.X;
            valY = data.AngularVelocity.Y;
            valZ = data.AngularVelocity.Z;
        }
Ejemplo n.º 4
0
        private void Gyroscope_ReadingChanged(object sender, GyroscopeChangedEventArgs e)
        {
            GyroscopeData reading = e.Reading;
            Vector3Data   data    = AngularVelocity;

            data.TimeStamp = DateTime.UtcNow;
            data.Value     = reading.AngularVelocity;
            data.SendNotification();
        }
Ejemplo n.º 5
0
        void ISensorEventListener.OnSensorChanged(SensorEvent e)
        {
            if ((e?.Values?.Count ?? 0) < 3)
            {
                return;
            }

            var data = new GyroscopeData(e.Values[0], e.Values[1], e.Values[2]);

            Gyroscope.OnChanged(data);
        }
Ejemplo n.º 6
0
        void DataUpdated(CMGyroData data, NSError error)
        {
            if (data == null)
            {
                return;
            }

            var field    = data.RotationRate;
            var gyroData = new GyroscopeData(field.x, field.y, field.z);

            RaiseReadingChanged(gyroData);
        }
Ejemplo n.º 7
0
        void RaiseReadingChanged(GyroscopeData data)
        {
            var args = new GyroscopeChangedEventArgs(data);

            if (UseSyncContext)
            {
                MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, args));
            }
            else
            {
                ReadingChanged?.Invoke(null, args);
            }
        }
Ejemplo n.º 8
0
        void ISensorEventListener.OnSensorChanged(SensorEvent?e)
        {
            var values = e?.Values ?? Array.Empty <float>();

            if (values.Count < 3)
            {
                return;
            }

            var data = new GyroscopeData(values[0], values[1], values[2]);

            Callback?.Invoke(data);
        }
Ejemplo n.º 9
0
        void DataUpdated(CMGyroData data, NSError error)
        {
            if (data == null)
            {
                return;
            }

#pragma warning disable CA1416 // https://github.com/xamarin/xamarin-macios/issues/14619
            var field = data.RotationRate;
#pragma warning restore CA1416
            var gyroData = new GyroscopeData(field.x, field.y, field.z);
            RaiseReadingChanged(gyroData);
        }
Ejemplo n.º 10
0
        private void Gyroscope_ReadingChanged(object sender, GyroscopeChangedEventArgs e)
        {
            Random        r    = new Random();
            GyroscopeData data = e.Reading;
            // Process Angular Velocity X, Y, and Z reported in rad/s
            //lbLogo.Text = $"Reading: X: {data.AngularVelocity.X}, Y: {data.AngularVelocity.Y}, Z: {data.AngularVelocity.Z}";
            float x = Math.Abs(data.AngularVelocity.X);
            float y = Math.Abs(data.AngularVelocity.Y);
            float z = Math.Abs(data.AngularVelocity.Z);

            if ((x > 1) || (y > 1) || (z > 1))
            {
                imgBola.Source = imagens[r.Next(0, imagens.Count - 1)];
            }
        }
Ejemplo n.º 11
0
 public GyroscopeChangedEventArgs(GyroscopeData reading) =>
Ejemplo n.º 12
0
 internal static void OnChanged(GyroscopeData reading) =>
 OnChanged(new GyroscopeChangedEventArgs(reading));
 internal GyroscopeChangedEventArgs(GyroscopeData reading) => Reading = reading;
Ejemplo n.º 14
0
        void ISensorEventListener.OnSensorChanged(SensorEvent e)
        {
            var data = new GyroscopeData(e.Values[0], e.Values[1], e.Values[2]);

            Gyroscope.OnChanged(data);
        }
Ejemplo n.º 15
0
        public void OnSensorChanged(SensorEvent e)
        {
            var data = new GyroscopeData(e.Values[0], e.Values[1], e.Values[2]);

            Gyroscope.OnChanged(data);
        }