Ejemplo n.º 1
0
        public void ItCanConnect()
        {
            var comm       = new BluetoothCommunication("COM4");
            var controller = new BrickController(comm);

            controller.Connect();
        }
Ejemplo n.º 2
0
        public async Task ItCanConnect()
        {
            var comm       = new MockCommunication();
            var controller = new BrickController(comm);
            await controller.Connect();

            Assert.AreEqual(1, comm.ReceivedData.Count);
        }
Ejemplo n.º 3
0
        public async Task ItCanTurnMotor()
        {
            var comm       = new BluetoothCommunication("COM4");
            var controller = new BrickController(comm);

            controller.Connect();

            await controller.TurnMotorAsync(OutputPort.C, 50, 1);
        }
Ejemplo n.º 4
0
        public async Task ItCanTurnMotor()
        {
            var comm       = new MockCommunication();
            var controller = new BrickController(comm);
            await controller.Connect();

            await controller.TurnMotorAsync(OutputPort.A, 50, 1);

            Assert.AreEqual(2, comm.ReceivedData.Count);
        }
Ejemplo n.º 5
0
        public void ItCanSendTankCommands()
        {
            var comm       = new BluetoothCommunication("COM4");
            var controller = new BrickController(comm);

            Console.WriteLine("Connecting...");
            controller.Connect();

            controller.TankMove(50, 50, 2);
            controller.TankMove(50, -50, 2);
            controller.TankMove(-50, -50, 2);
        }
Ejemplo n.º 6
0
        public async Task ItCanSendTankCommands()
        {
            var comm       = new MockCommunication();
            var controller = new BrickController(comm);

            Console.WriteLine("Connecting...");
            await controller.Connect();

            Console.WriteLine("Tank Move...");
            controller.TankMove(50, 50, 1);
            controller.TankMove(-50, -50, 1);
        }
Ejemplo n.º 7
0
        async void Button_OnClicked(object sender, EventArgs e)
        {
            var comm = DependencyService.Get <IXamarinCommunication>();

            var devices = await comm.GetDeviceList();

            var selection = await DisplayActionSheet("Select Bluetooth Device", "Cancel",
                                                     null, devices);

            comm.SelectDevice(selection);
            _controller = new BrickController(comm);
            await _controller.Connect();
        }
Ejemplo n.º 8
0
        static void Main()
        {
            var comm       = new BluetoothCommunication("COM4");
            var controller = new BrickController(comm);

            Task.Run(async() =>
            {
                await controller.Connect();

                for (var i = 0; i < 100; i++)
                {
                    while (controller.UltrasonicRange > 10)
                    {
                        Console.WriteLine(controller.UltrasonicRange);
                        controller.TankMove(50, 50, 0.5);
                    }

                    controller.TankMove(50, -50, 1);
                }
            });
        }