Beispiel #1
0
        public static async Task <PWMDevice> CreatePWMDeviceAsync(string deviceName, int pinNumber)
        {
            Log.WriteLine("finding device {0}", deviceName != null ? deviceName : "(default)");

            Windows.Devices.Enumeration.DeviceInformation info = null;
            if (deviceName != null)
            {
                info = await FindAsync(PwmController.GetDeviceSelector(deviceName));
            }
            else
            {
                info = await FindAsync(PwmController.GetDeviceSelector());
            }
            Log.WriteLine("PWM device info {0} null", info == null ? "is" : "is not");

            var d = new PWMDevice();

            d.Device = await AsAsync(PwmController.FromIdAsync(info.Id));

            if (d.Device != null)
            {
                Log.WriteLine("Pin Count {0}", d.Device.PinCount);
            }
            d.Pin = d.Device.OpenPin(pinNumber);
            return(d);
        }