Exemplo n.º 1
0
        /// <summary>
        /// 制御開始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void clickStart(object sender, RoutedEventArgs e)
        {
            try {
                string aqs = I2cDevice.GetDeviceSelector();                     /* Get a selector string that will return all I2C controllers on the system */
                var    dis = await DeviceInformation.FindAllAsync(aqs);         /* Find the I2C bus controller device with our selector string           */

                var settings = new I2cConnectionSettings(PWM_I2C_ADDR);
                settings.BusSpeed = I2cBusSpeed.StandardMode;
                I2CPwm            = await I2cDevice.FromIdAsync(dis[0].Id, settings); /* Create an I2cDevice with our selected bus controller and I2C settings */

                pwm1 = new PwmServo(I2CPwm, 0);
                pwm2 = new PwmServo(I2CPwm, 1);
                pwm3 = new PwmServo(I2CPwm, 2);
                pwm4 = new PwmServo(I2CPwm, 3);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return;
            }

            // 一つだけ設定する
            pwm1.Begin();
            pwm1.SetPWMFreq(60); // 60Hz
        }
Exemplo n.º 2
0
        /// <summary>
        /// 制御開始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void clickStart(object sender, RoutedEventArgs e)
        {
            try {
                string aqs = I2cDevice.GetDeviceSelector();                     /* Get a selector string that will return all I2C controllers on the system */
                var dis = await DeviceInformation.FindAllAsync(aqs);            /* Find the I2C bus controller device with our selector string           */
                var settings = new I2cConnectionSettings(PWM_I2C_ADDR);
                settings.BusSpeed = I2cBusSpeed.StandardMode;
                I2CPwm = await I2cDevice.FromIdAsync(dis[0].Id, settings);    /* Create an I2cDevice with our selected bus controller and I2C settings */
                pwm1 = new PwmServo(I2CPwm, 0);
                pwm2 = new PwmServo(I2CPwm, 1);
                pwm3 = new PwmServo(I2CPwm, 2);
                pwm4 = new PwmServo(I2CPwm, 3);
            }
            catch ( Exception ex )
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return;
            }

            // 一つだけ設定する
            pwm1.Begin();
            pwm1.SetPWMFreq(60); // 60Hz 
        }