The Microsoft Surface Pro has a gyroscope and accelerometer, Windows 8, and the full .NET framework.
Most articles I find that talk about the motion API point to the Windows Phone 8 API.
What .NET Framework namespaces and classes should I be using to get gyroscope and accelerometer data from?
A 3D gyroscope measures the angular velocity of its rotation in a reference frame along its three sensitivity axes. For an ideal sensor, these outputs are equal to the projections of the rotation angular velocity on the sensitivity, that is, intrinsic coordinate system axes.
Sensor Data Service - Delivers data from a variety of sensors. Sensor Service - A service for sensors that manages different sensors' functionality. Skype Updater - Enables the detection, download and installation of updates for Skype.
The Windows Sensor API provides a set of methods, properties, and events to work with connected sensors and sensor data. The Windows Location API, which is built on the Windows Sensor API, provides a set of programming objects, including scripting objects, for working with location information.
If you want to check if gyroscope is present or not, check the parameters that only gyroscope can measure. For example rotation rate is something only gyroscope measures. Have a look at an example code which says whether gyroscope is present or not: var gyroPresent = false; window.
I just worked based off the documentation - http://msdn.microsoft.com/en-us/library/ie/windows.devices.sensors
using Windows.Devices.Sensors;
private Accelerometer _accelerometer;
private void DoStuffWithAccel()
{
_accelerometer = Accelerometer.GetDefault();
if (_accelerometer != null)
{
AccelerometerReading reading = _accelerometer.GetCurrentReading();
if (reading != null)
double xreading = reading.AccelerationX;
... etc.
}
}
Haven't tested it, but it should work for any Windows Store App - If you're trying to make it run as a console/windows forms app, you need to change the targetplatform by:
For the surface pro you need to use the Windows 8.1
library, instead of the Windows Phone 8.1
library.
It should be in the same Windows.Devices.Sensors
namespace.
using Windows.Devices.Sensors;
...
//if you aren't already doing so, and you want the default sensor
private void Init()
{
_accelerometer = Accelerometer.GetDefault();
_gyrometer = Gyrometer.GetDefault();
}
...
private void DisplayAccelReading(object sender, object args)
{
AccelerometerReading reading = _accelerometer.GetCurrentReading();
if (reading == null)
return;
ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.AccelerationX);
ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.AccelerationY);
ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.AccelerationZ);
}
...
private void DisplayGyroReading(object sender, object args)
{
GyrometerReading reading = _gyrometer.GetCurrentReading();
if (reading == null)
return;
ScenarioOutput_AngVelX.Text =
String.Format("{0,5:0.00}", reading.AngularVelocityX);
ScenarioOutput_AngVelY.Text =
String.Format("{0,5:0.00}", reading.AngularVelocityY);
ScenarioOutput_AngVelZ.Text =
String.Format("{0,5:0.00}", reading.AngularVelocityZ);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With