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); }
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; } }
public void SendCommand(PwmCommand pwmCommand) { PwmController.Command(pwmCommand); }
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; }
public void SendCommand(PwmCommand command) { Clients.All.SendPwmCommand(command); }