コード例 #1
0
        protected PwmController CreatePwmController()
        {
            PwmDriver pwmDriver = DriverFactory.CreateFromEnum <PwmDriver, PwmDriverType>(this.Driver);

            return(pwmDriver != null
                ? new PwmController(pwmDriver)
                : new PwmController());
        }
コード例 #2
0
 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());
 }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        public void Dispose()
        {
            if (PwmDriver != null)
            {
                LeftMotorStop();
                RightMotorStop();

                PwmDriver.Dispose();
                PwmDriver = null;
            }

            LeftMotorDir.Dispose();
            RightMotorDir.Dispose();
        }
コード例 #5
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;
        }
コード例 #6
0
ファイル: PinController.cs プロジェクト: BMI24/StairsLight
 public void SetBrightness(float percentage) => PwmDriver.SetDutyCylce(percentage);