New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for pull-down resistor on pin #72
Conversation
Mirrors the activation of the pull-up resistor in that writing LOW to a pin will enable the built-in pull-down resistor. This does no checking to see if the pin actually has the required resistor. The limitation of this API is that once set, there's no way to set the pin back to the no-resistor state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! The code looks good, but I have an ecosystem question for you.
@@ -422,6 +422,8 @@ class Raspi extends EventEmitter { | |||
const pinInstance = this[getPinInstance](this.normalize(pin)); | |||
if (pinInstance.mode === INPUT_MODE && value === HIGH) { | |||
this[pinMode]({ pin, mode: INPUT_MODE, pullResistor: PULL_UP }); | |||
} else if (pinInstance.mode === INPUT_MODE && value === LOW) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this behavior landed in Johnny-Five yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just opened an issue and pull-request to add this behaviour to Johnny-Five and start a discussion. 👇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! We can leave this PR open for now, but I want to wait to land it until the discussion for Johnny-Five is resolved.
Just an FYI, this module is specifically designed to be a shim between Johnny-Five and Raspi.js. So from a design perspective, it doesn't make sense to add anything here that Johnny-Five specifically isn't requesting.
If you want to use raspi-io w/o Johnny-Five, I would recommend using Raspi.js as it's a little easier to use IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nebrius I'm ok with the minor change in Johnny-Five, since it's really just making a way to explicitly do something that is the default behavior of StandardFirmata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just waiting on tests (or response of any kind) rwaldron/johnny-five#1243
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nebrius Ah, sorry if I've done things the wrong way round. Johnny-Five + Raspi-IO is my go-to for doing physical computing on the Pi so thanks for that!
This PR (and the soft PWM one) mean that I can use the built-in Johnny-Five components like Button
and RGB LED
s with more of the Pi's GPIO pins without needing extra resistors.
@nebrius the corresponding patch landed in J5. I will do a release shortly.
<3 |
Yay! :)
Sweet! This looks good to me then. I'm working on a few other fixes to roll into a new release, but nonetheless this should be published sometime in the next few days. Thanks again for the help! |
btw, since you've landed a few commits, I went ahead and added you as a collaborator @andrewn, feel free to take a look around! |
Thanks both, I'm just happy to be able to contribute something back to these projects. |
Mirrors the activation of the pull-up resistor in that writing
LOW
to a pin will enable the built-in pull-down resistor. This does no checking to see if the pin actually has the required resistor.The limitation of this API is that once set, there's no way to set the pin back to the no-resistor state.
Fixes #71.