コード例 #1
0
        public void Dispose()
        {
            if (PwmDriver != null)
            {
                LeftMotorStop();
                RightMotorStop();

                PwmDriver.Dispose();
                PwmDriver = null;
            }

            LeftMotorDir.Dispose();
            RightMotorDir.Dispose();
        }
コード例 #2
0
        public void SetRightMotorPower(ZumoMotorDirection dir, float power)
        {
            Debug.WriteLine("RightMotor: {0} {1}", dir, power * 100.0f);

            if (dir == ZumoMotorDirection.Forward)
            {
                RightMotorDir.Write(GpioPinValue.Low);
            }
            else
            {
                RightMotorDir.Write(GpioPinValue.High);
            }

            PwmDriver.SetChannelDutyCycle(Config.RightPwmChannel, power);

            rightMotorPower = power;
            rightDir        = dir;
        }
コード例 #3
0
        public async Task Init()
        {
            Debug.WriteLine("Initializing ZumoMotorShield");

            Debug.WriteLine(Config.ToString());

            var gpioCtrlr = GpioController.GetDefault();

            LeftMotorDir = gpioCtrlr.OpenPin(Config.LeftMotorDirPin);
            Debug.Assert(LeftMotorDir != null);

            RightMotorDir = gpioCtrlr.OpenPin(Config.RightMotorDirPin);
            Debug.Assert(RightMotorDir != null);

            LeftMotorDir.SetDriveMode(GpioPinDriveMode.Output);
            RightMotorDir.SetDriveMode(GpioPinDriveMode.Output);

            PwmDriver = new PCA9685(Config.PwmDriverSlaveAddress);

            await PwmDriver.Init();
        }