A helper class for the FEZ Utility.
Inheritance: IDisposable
		private async void Setup() {
			this.utility = await GIS.FEZUtility.CreateAsync();
			this.utility.SetDigitalDriveMode(GIS.FEZUtility.DigitalPin.V00, GpioPinDriveMode.Output);

			this.timer = new DispatcherTimer();
			this.timer.Interval = TimeSpan.FromMilliseconds(100);
			this.timer.Tick += this.OnTick;
			this.timer.Start();
		}
        private async void Setup()
        {
            this.utility = await GIS.FEZUtility.CreateAsync();

            this.utility.SetDigitalDriveMode(GIS.FEZUtility.DigitalPin.V00, GpioPinDriveMode.Output);

            this.timer          = new DispatcherTimer();
            this.timer.Interval = TimeSpan.FromMilliseconds(100);
            this.timer.Tick    += this.OnTick;
            this.timer.Start();
        }
		/// <summary>
		/// Creates a new instance of the FEZ Utility.
		/// </summary>
		/// <returns>The new instance.</returns>
		public static async Task<FEZUtility> CreateAsync() {
			var gpioController = GpioController.GetDefault();
			var i2cController = (await DeviceInformation.FindAllAsync(I2cDevice.GetDeviceSelector("I2C1")))[0];
			var hat = new FEZUtility();

			hat.analog = new ADS7830(await I2cDevice.FromIdAsync(i2cController.Id, new I2cConnectionSettings(ADS7830.GetAddress(false, false))));
			hat.pwm = new PCA9685(await I2cDevice.FromIdAsync(i2cController.Id, new I2cConnectionSettings(PCA9685.GetAddress(true, true, true, true, true, true))));
			hat.gpio = new PCA9535(await I2cDevice.FromIdAsync(i2cController.Id, new I2cConnectionSettings(PCA9535.GetAddress(true, true, false))), gpioController.OpenPin(22));

			hat.gpio.Write((int)Led.Led1, false);
			hat.gpio.Write((int)Led.Led2, false);
			hat.gpio.SetDriveMode((int)Led.Led1, GpioPinDriveMode.Output);
			hat.gpio.SetDriveMode((int)Led.Led2, GpioPinDriveMode.Output);

			return hat;
		}
Exemple #4
0
        /// <summary>
        /// Creates a new instance of the FEZ Utility.
        /// </summary>
        /// <returns>The new instance.</returns>
        public static async Task <FEZUtility> CreateAsync()
        {
            var gpioController = GpioController.GetDefault();
            var i2cController  = (await DeviceInformation.FindAllAsync(I2cDevice.GetDeviceSelector("I2C1")))[0];
            var hat            = new FEZUtility();

            hat.analog = new ADS7830(await I2cDevice.FromIdAsync(i2cController.Id, new I2cConnectionSettings(ADS7830.GetAddress(false, false))));
            hat.pwm    = new PCA9685(await I2cDevice.FromIdAsync(i2cController.Id, new I2cConnectionSettings(PCA9685.GetAddress(true, true, true, true, true, true))));
            hat.gpio   = new PCA9535(await I2cDevice.FromIdAsync(i2cController.Id, new I2cConnectionSettings(PCA9535.GetAddress(true, true, false))), gpioController.OpenPin(22));

            hat.gpio.Write((int)Led.Led1, false);
            hat.gpio.Write((int)Led.Led2, false);
            hat.gpio.SetDriveMode((int)Led.Led1, GpioPinDriveMode.Output);
            hat.gpio.SetDriveMode((int)Led.Led2, GpioPinDriveMode.Output);

            return(hat);
        }