예제 #1
0
        public void Dispose()
        {
            if (_gpioController != null)
            {
                _gpioController.Dispose();
                _gpioController = null;
            }

            if (_driver != null)
            {
                _driver.Dispose();
                _driver = null;
            }
        }
예제 #2
0
        public static async Task <Star> Create(IPEndPoint endpoint)
        {
            var driver = new Iot.Device.Pigpio.Driver(endpoint);

            await driver.ConnectAsync();

            // Line above doesn't current wait for connection so
            // delay here to give the socket time to get connected
            await Task.Delay(TimeSpan.FromSeconds(2));

            var gpioController = new System.Device.Gpio.GpioController(System.Device.Gpio.PinNumberingScheme.Logical, driver);

            foreach (int pin in PinMapping)
            {
                gpioController.OpenPin(pin);
                gpioController.SetPinMode(pin, System.Device.Gpio.PinMode.Output);
            }

            return(new Star(driver, gpioController));
        }
예제 #3
0
 private Star(Iot.Device.Pigpio.Driver driver, System.Device.Gpio.GpioController gpioController)
 {
     _driver         = driver;
     _gpioController = gpioController;
 }