Exemplo n.º 1
0
        void Accelerometer_ReadingChanged(object sender, AccelerometerChangedEventArgs e)
        {
            var data = e.Reading;

            // Process Acceleration X, Y, and Z

            AcX1 = data.Acceleration.X;
            AcY1 = data.Acceleration.Y;
            AcZ1 = data.Acceleration.Z;
            /*Reading: \r\n */
            AccelerometerData1 = $" AcX: {AcX1.ToString("0.000")} \r\n AcY: {AcY1.ToString("0.000")} \r\n AcZ: {AcZ1.ToString("0.000")} ";
        }
Exemplo n.º 2
0
        public void OnSensorChanged(SensorEvent e)
        {
            // Process Acceleration X, Y, and Z
            if (e.Sensor.StringType == Android.Hardware.Sensor.StringTypeAccelerometer || e.Sensor.StringType == Android.Hardware.Sensor.StringTypeGravity)
            {
                AcX1 = e.Values[0];
                AcY1 = e.Values[1];
                AcZ1 = e.Values[2];
                AccelerometerData1 = $" AcX: {AcX1.ToString("0.000")} \r\n AcY: {AcY1.ToString("0.000")} \r\n AcZ: {AcZ1.ToString("0.000")} ";
            }
            else if (e.Sensor.StringType == Android.Hardware.Sensor.StringTypeLinearAcceleration)
            {
                AcX2 = e.Values[0];
                AcY2 = e.Values[1];
                AcZ2 = e.Values[2];
                AccelerometerData2 = $" AcX: {AcX2.ToString("0.000")} \r\n AcY: {AcY2.ToString("0.000")} \r\n AcZ: {AcZ2.ToString("0.000")} ";
            }

            else
            {
                AccelerometerData2 = "UnDefined Type!";
            }
        }