PiPHP / GPIO

A PHP library for accessing the GPIO pins on a Raspberry Pi.
MIT License
431 stars 42 forks source link

Should pins auto export? #7

Closed AndrewCarterUK closed 8 years ago

AndrewCarterUK commented 8 years ago

For

Interested to hear any other thoughts

colinodell commented 8 years ago

I really like this idea. You could essentially run that export as part of the constructor.

Possibly hidden side affect

None come to mind.

Could be messy to disable Might want to export and unexport multiple times during lifetime of app so need the methods anyway

I'm having trouble coming up with a use case for disabling a GPIO pin at any time other than garbage collection (nothing references the pin any more so why not) or program termination (resetting it back to an unused state).

If I wanted to change the pin mode from input to output (probably rare, but still possible) couldn't I just grab a new pin from the factory? That'll result in a second export() but I don't think that's harmful (should be easy enough to test whether that's a problem via bash).

If that's the case, then disabling a pin probably isn't necessary. If I no longer want my LED to glow, I can just write a 0 to it and forget about the pin.