Exemplo n.º 1
0
 public void SetMotor(int value)
 {
     var channel = DeviceChannel.DcMotor;
     Log.Info("SetPwm({0},{1})", channel, value);
     var piCommand = new PwmCommand(channel, value);
     PiController.Instance.SendCommand(piCommand);
 }
Exemplo n.º 2
0
 public void Command(PwmCommand pwmCommand)
 {
     Log.DebugFormat("PwmCommand received({0})!", pwmCommand);
     switch (pwmCommand.Channel)
     {
         case DeviceChannel.DcMotor:
             var percent = pwmCommand.DutyCyclePercent;
             var direction = percent > 0 ? MotorDirection.Forward : MotorDirection.Reverse;
             DcMotor.Go(Math.Abs(percent), direction);
             break;
         case DeviceChannel.Led:
             Led0.On(pwmCommand.DutyCyclePercent);
             break;
         case DeviceChannel.Servo:
             Servo.MoveTo(pwmCommand.DutyCyclePercent);
             break;
     }
 }
Exemplo n.º 3
0
 public void SendCommand(PwmCommand pwmCommand)
 {
     PwmController.Command(pwmCommand);
 }
Exemplo n.º 4
0
        private Task GetClawTask()
        {
            var task = new Task(() =>
            {
                Log.Info("Claw!");

                var ingestCommand = new PwmCommand {Channel = DeviceChannel.Servo, DutyCyclePercent = 10};
                PwmController.Command(ingestCommand);

                Task.Delay(TimeSpan.FromMilliseconds(750)).Wait();

                var throwCommand = new PwmCommand {Channel = DeviceChannel.Servo, DutyCyclePercent = 70};
                PwmController.Command(throwCommand);
            });

            task.WhenCompleted(ClawCompleted, ClawCompleted);

            return task;
        }
Exemplo n.º 5
0
 public void SendCommand(PwmCommand command)
 {
     Clients.All.SendPwmCommand(command);
 }