RaspberryPi.Net
RaspberryPi.Net copied to clipboard
GPIOFile direction being ignored
Taking into consideration this code
_ButtonGPIO = new GPIOFile((GPIOPins)GPIOPin, GPIODirection.In);
When this code runs, doing less /sys/class/gpio/gpio10/direction
(10 because it's the value of the GPIOPin variable) returns Out
.
The problem here is that the constructor referred above calls the public GPIOFile(GPIOPins pin, GPIODirection direction, bool initialValue)
with false on the initialValue
parameter. This one calls the base with: our pin, GPIODirection.In, false. The code for setting the PinDirection is the following
PinDirection = direction;
Write(initialValue);
and the Write
method is (partially) defined as this:
PinDirection = GPIODirection.Out;```
This setting will ALWAYS override the direction set.
My suggestion is that there should be another constructor on the `public abstract class GPIO : IDisposable`
I can try and contribute for that, but for that I would like you to DM me so that I can understand the process :)