Exemple #1
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine("Creating anonymous routes");
            metawear.GetModule <ISettings>().EditBleConnParams(maxConnInterval: 7.5f);
            await Task.Delay(1500);

            var routes = await metawear.CreateAnonymousRoutesAsync();

            var logging = metawear.GetModule <ILogging>();

            logging.Stop();

            Console.WriteLine($"{routes.Count} active loggers discovered");
            foreach (var r in routes)
            {
                r.Subscribe(_ =>
                            Console.WriteLine($"identifier: {r.Identifier}, time: {_.FormattedTimestamp}, data: [{BitConverter.ToString(_.Bytes).ToLower().Replace("-", ", 0x")}]")
                            );
            }

            await logging.DownloadAsync();

            metawear.GetModule <IMacro>().EraseAll();
            var debug = metawear.GetModule <IDebug>();

            debug.ResetAfterGc();
            await debug.DisconnectAsync();
        }
Exemple #2
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine($"Configuring {args[0]}...");

            var acc  = metawear.GetModule <IAccelerometer>();
            var gyro = metawear.GetModule <IGyroBmi160>();

            acc.Configure(odr: 25f);
            gyro.Configure(odr: OutputDataRate._25Hz);

            await gyro.AngularVelocity.AddRouteAsync(source => source.Buffer().Name("gyro"));

            await acc.Acceleration.AddRouteAsync(source => source.Fuse("gyro").Stream(_ => {
                var array = _.Value <IData[]>();

                // accelerometer is the source input, index 0
                // gyro name is first input, index 1
                Console.WriteLine($"acc = {array[0].Value<Acceleration>()}, gyro = {array[1].Value<AngularVelocity>()}");
            }));

            gyro.AngularVelocity.Start();
            acc.Acceleration.Start();

            gyro.Start();
            acc.Start();

            await Task.Delay(15000);

            Console.WriteLine("Resetting device");
            await metawear.GetModule <IDebug>().ResetAsync();
        }
Exemple #3
0
        internal static async Task <IMetaWearBoard> PrepareBleConn(string mac)
        {
            var m = await ScanConnect.Connect(mac);

            // Adjust the max connection interval to support the 100Hz stream
            m.GetModule <ISettings>()?.EditBleConnParams(maxConnInterval: 7.5f);
            await Task.Delay(1500);

            Console.WriteLine($"Connected to {mac}");
            return(m);
        }
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine($"Configuring {args[0]}...");

            var acc  = metawear.GetModule <IAccelerometer>();
            var gyro = metawear.GetModule <IGyroBmi160>();

            acc.Configure(odr: 25f);
            gyro.Configure(odr: OutputDataRate._25Hz);
            await gyro.AngularVelocity.AddRouteAsync(source => source.Buffer().Name("gyro"));

            await acc.Acceleration.AddRouteAsync(source => source.Fuse("gyro").Stream(_ => {
                var array = _.Value <IData[]>();

                // accelerometer is the source input, index 0
                // gyro name is first input, index 1
                // Console.WriteLine($"acc = {array[0].Value<Acceleration>()}, gyro = {array[1].Value<AngularVelocity>()}");
                Console.WriteLine("acc = {0}, gyro = {1}", array[0].Value <Acceleration>(), array[1].Value <Acceleration>());
                string fileName = @"E:\JKU\Praktikum SE\C# Projects\MetaWear-Tutorial-CSharp\NetCoreExamples\Output.txt";
                // Check if file already exists. If yes, delete it.
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                try
                {
                    // Create a new file
                    using (FileStream fs = File.Create(fileName))
                    {
                        // Add some text to file
                        Byte[] title = new UTF8Encoding(true).GetBytes("Output.txt");
                        fs.Write(title, 0, title.Length);
                    }
                }
                catch (Exception Ex)
                {
                    Console.WriteLine(Ex.ToString());
                }
            }));

            gyro.AngularVelocity.Start();
            acc.Acceleration.Start();

            gyro.Start();
            acc.Start();

            await Task.Delay(15000);

            Console.WriteLine("Resetting device");
            await metawear.GetModule <IDebug>().ResetAsync();
        }
Exemple #5
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine("Removing macros");
            metawear.GetModule <IMacro>().EraseAll();

            var debug = metawear.GetModule <IDebug>();

            debug.ResetAfterGc();
            await debug.DisconnectAsync();
        }
Exemple #6
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine($"Configuring {args[0]}...");
            await Setup(metawear);

            Console.WriteLine("Press [Enter] to reset the board");
            Console.ReadLine();

            Console.WriteLine("Resetting device...");
            await metawear.GetModule <IDebug>().ResetAsync();
        }
Exemple #7
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            var macro = metawear.GetModule <IMacro>();

            Console.WriteLine($"Configuring {args[0]}...");
            macro.StartRecord();
            await LedController.Setup(metawear);

            await macro.EndRecordAsync();

            Console.WriteLine("Resetting device");
            await metawear.GetModule <IDebug>().ResetAsync();
        }
Exemple #8
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine($"Configuring {metawear.MacAddress}...");
            await SetupLogger(metawear);

            Console.WriteLine("Logging data for 15s");
            await Task.Delay(15000);

            Console.WriteLine("Downloading data");
            await DownloadData(metawear);

            await metawear.GetModule <IDebug>().ResetAsync();
        }
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine($"Configuring {args[0]}...");
            var task = await Setup(metawear);

            // Start the periodic task
            task.Start();

            Console.WriteLine("Streaming data for 15s");
            await Task.Delay(15000);

            // Remove scheduled task
            task.Remove();

            await metawear.GetModule <IDebug>().DisconnectAsync();
        }
Exemple #10
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            Console.WriteLine($"Configuring {args[0]}...");

            var acc  = metawear.GetModule <IAccelerometer>();
            var gyro = metawear.GetModule <IGyroBmi160>();

            acc.Configure(odr: 25f);
            gyro.Configure(odr: OutputDataRate._25Hz);
            MergedData mergedata = new MergedData();
            await gyro.AngularVelocity.AddRouteAsync(source => source.Stream(data =>
            {
                AngularVelocity gyroData = data.Value <AngularVelocity>();
                mergedata.gyUpdate(gyroData);
                //Console.Clear();
                Console.WriteLine(mergedata.ToString());
            }));

            await acc.Acceleration.AddRouteAsync(source => source.Stream(data =>
            {
                Acceleration accData = data.Value <Acceleration>();
                mergedata.acUpdate(accData);
                //Console.Clear();
                Console.WriteLine(mergedata.ToString());
            }));

            //Console.WriteLine(array1.ToString());
            //gyro.AngularVelocity.Start();
            //acc.Acceleration.Start
            gyro.Start();
            acc.Start();
            //TODO Synchronise gyro and acc to get matching data
            await Task.Delay(15000);

            gyro.Stop();
            acc.Stop();

            Console.WriteLine();
            //Console.WriteLine(x1);
            Console.ReadLine();
        }
Exemple #11
0
        static async Task RunAsync(string[] args)
        {
            var metawear = await ScanConnect.Connect(args[0]);

            var led = metawear.GetModule <ILed>();

            // Set a solid pattern for the green led
            led.EditPattern(Color.Green, Pattern.Solid);
            // Play pattern
            led.Play();

            await Task.Delay(5000);

            // Stop and clear pattern
            led.Stop(true);

            // Have remote device disconnect instead to ensure the
            // LED stop command is received
            await metawear.GetModule <IDebug>().DisconnectAsync();
        }