GpioPin changes #50
Description
On the new library, the GPIO is controlled by a GpioController
instance (here's the class).
As far as I've understood, there should be only 1 controller "active" (1 instance at the time). For that reason, I've decided that it was a better approach to have the *-GpioPin to receive the controller, similar to what's being done with the I2C device. This avoids the overload of creating a controller per command execution, and allows us to keep context of the pins through the controller.
This also requires that we have a new cmdlet to create a Controller (Get-GpioController
?)
Another thing to keep in mind is that we should have a way do properly dispose the controller, if the user doesn't do so (see here).
Another breaking change is that this library does not use the PullMode
like we currently have. Instead, they have a PinMode
(here's the source). This is used when opening a pin/setting its mode
_controller.OpenPin(_echo, PinMode.Input);
_controller.OpenPin(_trigger, PinMode.Output);
(source)
As a final note, we now have to pay special attention to opening/closing pins while developing our cmdlets, in order to avoid potential bugs where pins are left open, or are wrongly closed :)
Here's a snippet with an example on how to get a pin info
$controller = Get-GpioController #if no scheme is specified, use the default one
$pin = Get-GpioPin -Controller $controller -Id 5 -PinMode Input