Exemplo n.º 1
0
        public static async Task <OutputPort> Create(int pin, IGpioDriver driver = null)
        {
            var port = new OutputPort(pin, driver ?? new FileDriver());

            // If port already exists delete and recreate it
            if (Directory.Exists(GpioPath.Path(pin)))
            {
                await port.UnAssignPin();
            }
            await port.AssignPin();

            await port.SetDirection(GpioDirection.Out);

            return(port);
        }
Exemplo n.º 2
0
        public static async Task <InputPort> Create(int pin, GpioEdge edge, IGpioDriver driver = null)
        {
            var port = new InputPort(pin, driver ?? new FileDriver());

            // If port already exists delete and recreate it
            if (Directory.Exists(GpioPath.Path(pin)))
            {
                await port.UnAssignPin();
            }
            await port.AssignPin();

            await port.SetDirection();

            await port.SetEdge(edge);

            port.SetupInterrupt();

            return(port);
        }