Пример #1
0
        public void StopAndClear()
        {
            byte[][] expected = new byte[][] {
                new byte[] { 0x02, 0x02, 0x01 }
            };

            led.Stop(true);

            byte[][] actual = platform.GetCommands();
            Assert.That(expected, Is.EqualTo(actual));
        }
Пример #2
0
        private async void Disconnect(object sender, RoutedEventArgs args)
        {
            ILed led = board.GetModule <ILed>();

            led.Stop(true);
            board.TearDown();
            device = null;

            ConnectionStatus.Text = "Disconnected.";

            ConnectButton.IsEnabled    = true;
            DisconnectButton.IsEnabled = false;
        }
Пример #3
0
        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();
            }
        }