protected PwmController CreatePwmController() { PwmDriver pwmDriver = DriverFactory.CreateFromEnum <PwmDriver, PwmDriverType>(this.Driver); return(pwmDriver != null ? new PwmController(pwmDriver) : new PwmController()); }
public Task Buzz(float frequency, uint durationMs) { return(ThreadPool.RunAsync(async(s) => { PwmDriver.SetChannelDutyCycle(Config.BuzzerPwmChannel, 0.5f); await Task.Delay((int)durationMs); PwmDriver.SetChannelDutyCycle(Config.BuzzerPwmChannel, 0.0f); }).AsTask()); }
private async void Test(object sender, RoutedEventArgs e) { _driver = await PwmDriver.Init(); while (true) { if (_driver.IsDevicedInited) { _driver.DrivePercentage(0, 0); System.Threading.Tasks.Task.Delay(2000).Wait(); _driver.DrivePercentage(0, 100); } } }
public void Dispose() { if (PwmDriver != null) { LeftMotorStop(); RightMotorStop(); PwmDriver.Dispose(); PwmDriver = null; } LeftMotorDir.Dispose(); RightMotorDir.Dispose(); }
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; }
public void SetBrightness(float percentage) => PwmDriver.SetDutyCylce(percentage);