/// <summary>
 /// Set a channel to fully on or off
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="fullOn">if set to <c>true</c>, all values are on; otherwise they are all off.</param>
 public void SetFull(PwmChannel channel, bool fullOn)
 {
     if (fullOn)
         SetFullOn(channel);
     else
         SetFullOff(channel);
 }
 /// <summary>
 /// Sets a single PWM channel
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="on">The on values.</param>
 /// <param name="off">The off values.</param>
 public void SetPwm(PwmChannel channel, int on, int off)
 {
     WriteRegister(Register.LED0_ON_L + 4*(int) channel, on & 0xFF);
     WriteRegister(Register.LED0_ON_H + 4*(int) channel, on >> 8);
     WriteRegister(Register.LED0_OFF_L + 4*(int) channel, off & 0xFF);
     WriteRegister(Register.LED0_OFF_H + 4*(int) channel, off >> 8);
 }
Example #3
0
 public void SetPwm(PwmChannel channel, int on, int off)
 {
     if (LogChannels.Contains(channel))
     {
         Log.Info(m => m("Stub:SetPwm({0},{1},{2})", channel, on, off));
     }
 }
Example #4
0
        private void RunLed(Pca9685Connection device, PwmChannel channel, int sleepMs, CancellationToken cancelToken)
        {
            // PMW ticks range from 0 to 4095
            int increment      = 100;
            int startCycleTick = 0;

            device.SetPwm(channel, 0, 0);
            while (!cancelToken.IsCancellationRequested)
            {
                // up we go
                for (int endCycleTick = 100; endCycleTick < 4100; endCycleTick += increment)
                {
                    device.SetPwm(channel, startCycleTick, endCycleTick);
                    Thread.Sleep(sleepMs);
                }

                // after we've gone up, show kindness and see if we're done
                if (cancelToken.IsCancellationRequested)
                {
                    break;
                }

                // and down we go
                for (int endCycleTick = 4095; endCycleTick > 0; endCycleTick -= increment)
                {
                    device.SetPwm(channel, startCycleTick, endCycleTick);
                    Thread.Sleep(sleepMs);
                }
            }
        }
Example #5
0
            public static IPwmOutput Bind(PwmChannel channel, string name = null)
            {
                var result = NewInstance(channel, name);

                Cache.Add(channel, result);
                return(result);
            }
Example #6
0
        public StepperMotor(
            IPwmDevice controller
            , PwmChannel controlChannel0
            , PwmChannel controlChannel1
            , PwmChannel controlChannel2
            , PwmChannel controlChannel3)
            : base(controller)
        {
            _channels = new [] {controlChannel0, controlChannel1, controlChannel2, controlChannel3};
            _currentStep = 0;
            StepDelayMs = 100;

            Sequence = new[]
            {
                "1000",
                "1100",
                "0100",
                "0110",
                "0010",
                "0011",
                "0001",
                "1001"
            };
        }
 private void SetFullOn(PwmChannel channel)
 {
     WriteRegister(Register.LED0_ON_H + 4*(int) channel, 0x10);
     WriteRegister(Register.LED0_OFF_H + 4*(int) channel, 0x00);
 }
Example #8
0
 public void SetFull(PwmChannel channel, bool fullOn)
 {
     Log.Debug(m => m("Stub:SetPwm({0},{1})", channel, fullOn));
 }
Example #9
0
 public void SetPwm(PwmChannel channel, int on, int off)
 {
     Log.Info(m => m("Stub:SetPwm({0},{1},{2})", channel, on, off));
 }
Example #10
0
 public ServoMotor(IPwmDevice controller, PwmChannel channel, int mimimum, int maximum): base(controller)
 {
     Channel = channel;
     MaximumPosition = maximum;
     MinimumPosition = mimimum;
 }
Example #11
0
 public Led(IPwmDevice controller, PwmChannel channel)
     : base(controller)
 {
     _channel = channel;
 }
Example #12
0
 /// <summary>
 /// Assumes a SN754410 or equivalent wired to the PWM channels
 /// </summary>
 public DcMotor(IPwmDevice controller, PwmChannel controlChannel0, PwmChannel controlChannel1)
     : base(controller)
 {
     _controlChannel0 = controlChannel0;
     _controlChannel1 = controlChannel1;
 }
Example #13
0
 public void SetPwm(PwmChannel channel, int @on, int off)
 {
 }
Example #14
0
 public void SetFull(PwmChannel channel, bool fullOn)
 {
 }