Click here to Skip to main content
15,898,222 members

Comments by Nikhil_Malik (Top 17 by date)

Nikhil_Malik 8-Nov-14 1:35am View    
OK.. Thanx for the help anyway.
Nikhil_Malik 8-Nov-14 0:53am View    
The code i have written is working fine. There is no problem with it. Now I want to extent this code so that the readings of accelerometer can be send via bluetooth to other device instead of being displayed in the textbox.? Did you get it now.?
Nikhil_Malik 7-Nov-14 13:21pm View    
Got you. I will remember it. I hope you got what m trying to do.?
Nikhil_Malik 7-Nov-14 13:12pm View    
Did you get what m trying to do now and where M stuck.?
Nikhil_Malik 7-Nov-14 13:07pm View    
Deleted
namespace Demo
{
public partial class MainPage : PhoneApplicationPage
{
Accelerometer accelerometer;
// Constructor
public MainPage()
{
InitializeComponent();

if (!Accelerometer.IsSupported)
{
readings.Text = "No accelerometer sensor found.";
}

if (accelerometer==null)
{
accelerometer = new Accelerometer();
accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(5);
accelerometer.CurrentValueChanged += new EventHandler<sensorreadingeventargs<accelerometerreading>>(accelerometerEventHandler);
accelerometer.Start();
}
}

private void accelerometerEventHandler(object sender, SensorReadingEventArgs<accelerometerreading> e)
{
Dispatcher.BeginInvoke(()=> UpdateUI(e.SensorReading));
}

private void UpdateUI(AccelerometerReading accelerometerReading)
{
Vector3 accelerateDir = accelerometerReading.Acceleration;
readings.Text = "X: "+accelerateDir.X.ToString()+"\nY: "+accelerateDir.Y.ToString()+"\nZ: "+accelerateDir.Z.ToString();
}


}
}