Closed illpro closed 7 years ago
???
Thanks for going to the effort of submitting this patch and I'm sorry it has taken so long to get back to you.
I'm keen to merge, but is it possible please to add some extra test coverage just so that we can see the module working with these new options? There are some existing tests for direction and I think they can just be copied.
Also is there any chance you could update the readme to provide some info for the extra options?
Cheers.
I found that when using 'gpio.DIR_IN', channel 7 is the only one that defaults to high, the rest (11, 12, 13, 15, 16, 18, 22) defaulted to low. I also found that the proposed fix does not work for me.
I used it like this:
gpio.setup(7, gpio.DIR_LOW, gpio.EDGE_BOTH);
Hey guys, sorry I haven't been watching this thread lately.
Anyways, I'm happy to add some test coverage and explain in the read me what I am trying to achieve with this pull request.
More coming soon...
@karlstulik, I did not notice the EDGE_**** options when originally using this fix. My code skips the edge option altogether and just has a callback function. Perhaps not using a callback function is contributing to it not working for you? Mine works like this:
function startServer() {
/*
code that starts an http server and listens for requests to turn
the pin on and off. the pin starts "hot" because I used HIGH as
the direction.
*/
}
gpio.setup(7, gpio.DIR_HIGH, startServer);
I don't have a good setup to test right at the moment, but if memory serves me correctly, using DIR_HIGH was necessary for me, and made the pin start "hot", which I remember it wasn't doing originally.
... Just realized if you are using gpio.EDGE_BOTH then you are most likely trying to read the pin (direction IN), HIGH AND LOW are for write pins (direction OUT).
@JamesBarwell, I've added the requested tests and added some documentation to the read me. the tests passed on my Pi running NodeJS 4.4.0. I did not run or edit the integration test since the Pi is not wired properly for it.
Let me know if you need me to do anything else. Thanks again. Cheers! 🍺
Zach
Apologies for the delay, but I wanted to give it a proper test myself. I've been testing the patch this morning on my Model B running node 6.2.1 and I'm happy with it. I'll update in a bit with new module version details. Much appreciated, cheers.
Published as rpi-gpio@0.8.0
Tested this in my library on raspberry pi 1 model b, works great! Huge thanks
This pull request is a proposed fix for issue #25 by allowing the developer to choose which state the gpio pin should be initially set to. This is especially helpful for dealing with certain hardware setups that operate in reverse logic (0 is hot, 1 is cold).
Thanks!