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); }
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); }