public void Dispose() { if (PwmDriver != null) { LeftMotorStop(); RightMotorStop(); PwmDriver.Dispose(); PwmDriver = null; } LeftMotorDir.Dispose(); RightMotorDir.Dispose(); }
public void SetLeftMotorPower(ZumoMotorDirection dir, float power) { Debug.WriteLine("LeftMotor: {0} {1}", dir, power * 100.0f); if (dir == ZumoMotorDirection.Forward) { LeftMotorDir.Write(GpioPinValue.Low); } else { LeftMotorDir.Write(GpioPinValue.High); } PwmDriver.SetChannelDutyCycle(Config.LeftPwmChannel, power); leftMotorPower = power; leftDir = dir; }
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(); }