Exemple #1
0
        private void ClosePin()
        {
            var relayPin      = Convert.ToInt32(_configuration["RelayPin"]);
            var gpioContoller = new System.Device.Gpio.GpioController();

            gpioContoller.OpenPin(relayPin, System.Device.Gpio.PinMode.Output);
            gpioContoller.Write(relayPin, System.Device.Gpio.PinValue.Low);
        }
Exemple #2
0
        public void Dispose()
        {
            if (_gpioController != null)
            {
                _gpioController.Dispose();
                _gpioController = null;
            }

            if (_driver != null)
            {
                _driver.Dispose();
                _driver = null;
            }
        }
Exemple #3
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));
        }
Exemple #4
0
 private Star(Iot.Device.Pigpio.Driver driver, System.Device.Gpio.GpioController gpioController)
 {
     _driver         = driver;
     _gpioController = gpioController;
 }