You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like when my device senses a jerk, it has both change in accelerometer and magnetometer values. I need both of their values of the 3 axes separately. That is X,Y,Z for accelerometer separately and X,Y,Z for magnetometer separately .
I have already tried the below code, but it does not work.Please help me on this.
//code below:
private void StartListening()
{
CrossDeviceMotion.Current.SensorValueChanged += (s, a) =>
{
if (lastUpdate > DateTime.MinValue)
{
//I feel like there should be some kind of a type casting of the value here but I have no
idea how to do that.
if (a.SensorType == MotionSensorType.Accelerometer)
{
CurrentData.X = ((MotionVector)a.Value).X;
CurrentData.Y = ((MotionVector)a.Value).Y;
CurrentData.Z = ((MotionVector)a.Value).Z;
}
if (a.SensorType == MotionSensorType.Magnetometer)
{
CurrentData.Pitch = ((MotionVector)a.Value).X;
CurrentData.Roll = ((MotionVector)a.Value).Y;
CurrentData.Yaw = ((MotionVector)a.Value).Z;
}
}
else
{
//I feel like there should be some kind of a type casting of the value here but I have no
idea how to do that.
if (a.SensorType == MotionSensorType.Accelerometer)
{
LastData.X = ((MotionVector)a.Value).X;
LastData.Y = ((MotionVector)a.Value).Y;
LastData.Z = ((MotionVector)a.Value).Z;
}
if (a.SensorType == MotionSensorType.Magnetometer)
{
LastData.Pitch = ((MotionVector)a.Value).X;
LastData.Roll = ((MotionVector)a.Value).Y;
LastData.Yaw = ((MotionVector)a.Value).Z;
}
lastUpdate = currentTime;
}
};
}
The text was updated successfully, but these errors were encountered:
Like when my device senses a jerk, it has both change in accelerometer and magnetometer values. I need both of their values of the 3 axes separately. That is X,Y,Z for accelerometer separately and X,Y,Z for magnetometer separately .
I have already tried the below code, but it does not work.Please help me on this.
//code below:
The text was updated successfully, but these errors were encountered: