示例#1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var addresses = LpmsBluetoothDevice.Enumerate(TimeSpan.FromSeconds(15));

            if (addresses.Length == 0)
            {
                MessageBox.Show("No sensors detected.");
                Shutdown();
            }

            Sensors = addresses.Select(a => new Sensor(a)).ToArray();
        }
示例#2
0
        public Sensor(BluetoothAddress address)
        {
            device = new LpmsBluetoothDevice(address);
            device.Connect(TimeSpan.FromSeconds(10));

            device.Mode            = DeviceMode.Command;
            device.FilterMode      = FilterMode.GyroscopeAccelerometerMagnetometer;
            device.OutputFields    = OutputFields.Quaternion;
            device.StreamFrequency = 100;
            device.UpdateConfiguration();

            device.ResetTimeStamp();
            device.Mode = DeviceMode.Stream;

            thread = new Thread(ReadData)
            {
                IsBackground = true,
                Name         = "Sensor"
            };
            thread.Start();
        }