Lập trình Windows Phone Module 4 – Bài 7: Sensors

Khái niệm Sensors

Orientation – Cảm biến xoay màn hình

Accelerometer – Cảm biến gia tốc kế

Compass – Cảm biến la bàn số

Gyroscope – Cảm biến con quay hồi chuyển

 

pptx14 trang | Chia sẻ: Mr Hưng | Lượt xem: 753 | Lượt tải: 0download
Nội dung tài liệu Lập trình Windows Phone Module 4 – Bài 7: Sensors, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
Lập trình Windows Phone Module 4 – Bài 7: SensorsGV Biên soạn: Trần Duy ThanhNội dungKhái niệm SensorsOrientation – Cảm biến xoay màn hìnhAccelerometer – Cảm biến gia tốc kếCompass – Cảm biến la bàn sốGyroscope – Cảm biến con quay hồi chuyển1. Khái niệm Sensors 2. Orientation – Cảm biến xoay màn hình 3. Accelerometer – Cảm biến gia tốc kế using Microsoft.Devices.Sensors;using Microsoft.Xna.Framework;3. Accelerometer – Cảm biến gia tốc kếAccelerometer accelerometer = new Accelerometer();accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(10);accelerometer.CurrentValueChanged += accelerometer_CurrentValueChanged; accelerometer.Start();3. Accelerometer – Cảm biến gia tốc kếprivate void accelerometer_CurrentValueChanged( object sender, SensorReadingEventArgs e){ AccelerometerReading reading = e.SensorReading; Vector3 acceleration = reading.Acceleration; //acceleration.X, acceleration.Y, acceleration.Z}4. Compass – Cảm biến la bàn số 4. Compass – Cảm biến la bàn số Compass compass=new Compass();compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(33); compass.CurrentValueChanged += compass_CurrentValueChanged; // for calibration. compass.Calibrate += compass_Calibrate;compass.Start();4. Compass – Cảm biến la bàn sốprivate double headingAccuracy; private void compass_CurrentValueChanged( object sender, SensorReadingEventArgs e) { double trueHeading = e.SensorReading.TrueHeading; float headingRadians = MathHelper.ToRadians((float)trueHeading);headingAccuracy = Math.Abs(e.SensorReading.HeadingAccuracy);//xử lý headingAccuracy }5. Gyroscope – Cảm biến con quay hồi chuyển 5. Gyroscope – Cảm biến con quay hồi chuyểnprivate Gyroscope gyroscope;gyroscope = new Gyroscope();gyroscope.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);gyroscope.CurrentValueChanged += gyroscope_CurrentValueChanged;gyroscope.Start();5. Gyroscope – Cảm biến con quay hồi chuyểnprivate void gyroscope_CurrentValueChanged(object sender, SensorReadingEventArgs e) {Vector3 currentRotationRate = e.SensorReading.RotationRate;currentRotationRate.X currentRotationRate.Y currentRotationRate.Z }Thảo luận

Các file đính kèm theo tài liệu này:

  • pptxwp_module4_bai7_sensors_1732.pptx
Tài liệu liên quan