void _spheroDevice_SensorDataNotification(Sphero.Locator.SensorData data) { // If IMU data are present if (data.FilteredIMU != null) { // Update Sliders with data on UI Thread Dispatcher.BeginInvoke(() => { sldPitch.Value = data.FilteredIMU.Pitch; sldRoll.Value = data.FilteredIMU.Roll; sldYaw.Value = data.FilteredIMU.Yaw; }); } }
internal void RaiseSensorDataNotification(SensorData data) { if(SensorDataNotification != null) { SensorDataNotification(data); } }
internal void DispatchAsyncResponse(AsyncResponsePacket response) { switch(response.ResponseCode) { case AsynchronousId.POWER_NOTIFICATION: if(_core != null) { _core.RaisePowerNotification(_core, (PowerState)response.Data[0]); } break; case AsynchronousId.SENSOR_DATA_STREAMING: if (_sphero != null) { SensorData sensorData = new SensorData(_sphero.Mask, _sphero.Mask2, response.Data); _sphero.RaiseSensorDataNotification(sensorData); } break; case AsynchronousId.SSB_DATA: string data = Encoding.UTF8.GetString(response.Data, 0, response.Data.Length); Debug.WriteLine("Async SSB message : {0}", BitConverter.ToString(response.ToArray())); break; case AsynchronousId.XP_UPDATE: if (_sphero != null) { _sphero.RaiseXpNotification(response.Data[0]); } break; case AsynchronousId.BOOST_UPDATE: if (_sphero != null) { _sphero.RaiseBoostNotification(response.Data[0]); } break; case AsynchronousId.COLLISION_DETECTED: if (_sphero != null) { _sphero.RaiseCollisionDetected(new Collisions.CollisionData(response.Data)); } break; default: if (Verbose) Debug.WriteLine("Async message : {0}", BitConverter.ToString(response.ToArray())); break; } }