private void streamSwitch_Toggled(object sender, RoutedEventArgs e) { if (streamSwitch.IsOn) { sensorfusion.Quaternion.Start(); sensorfusion.Start(); } else { sensorfusion.Stop(); sensorfusion.Quaternion.Stop(); } }
private void streamSwitch_Toggled(object sender, RoutedEventArgs e) { if (streamSwitch.IsOn) { m_SensorFusion.EulerAngles.Start(); m_SensorFusion.Start(); } else { m_SensorFusion.Stop(); m_SensorFusion.EulerAngles.Stop(); } }
static async Task Main(string[] args) { IMetaWearBoard board = null; bool succeed = false; int retries = 5; //while (!succeed && retries > 0) { //try { board = MbientLab.MetaWear.NetStandard.Application.GetMetaWearBoard(args[0]); //var board = BLEMetawear.Application.GetMetaWearBoard(args[0]); board.TimeForResponse = 100000; board.OnUnexpectedDisconnect += OnDisconneted; await board.InitializeAsync(); succeed = true; } //catch { retries--; } } ILed led = null; ISensorFusionBosch sensor = null; if (board.IsConnected) { led = board.GetModule <ILed>(); led.EditPattern(MbientLab.MetaWear.Peripheral.Led.Color.Green, MbientLab.MetaWear.Peripheral.Led.Pattern.Solid); led.Play(); sensor = board.GetModule <ISensorFusionBosch>(); sensor.Configure(); var rout = await sensor.EulerAngles.AddRouteAsync(source => { try { source.Stream(data => { var value = data.Value <EulerAngles>(); var AngularRead = (int)value.Roll; var OrbitalRead = (int)value.Pitch; //Console.Clear(); Console.Write($"\rroll: {value.Roll} pitch:{value.Pitch} Yaw:{value.Yaw} "); //Rotate(-value.Pitch, 0 , -value.Yaw); }); } catch (Exception ex) { Console.Write(ex.Message); //LogException(LoggerCategory, ex, "Could not initialize IMU stream callback"); throw; } }); sensor.EulerAngles.Start(); sensor.Start(); } ConsoleKeyInfo key = new ConsoleKeyInfo(); while (key.Key != ConsoleKey.Q) { key = Console.ReadKey(); } if (board.IsConnected) { if (led != null) { led.Stop(true); } if (sensor != null) { sensor.EulerAngles.Stop(); sensor.Stop(); } await board.DisconnectAsync(); //board.TearDown(); } }