Skip to content
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

Rollup optional pull specification into getDigitalValue #156

Open
cefn opened this issue Jun 3, 2016 · 3 comments
Open

Rollup optional pull specification into getDigitalValue #156

cefn opened this issue Jun 3, 2016 · 3 comments

Comments

@cefn
Copy link

cefn commented Jun 3, 2016

This is a change request following some consensus on medium-term workarounds for the surprising pull-down defaults of digitalWrite (surprising for experienced makers anyway, although that doesn't mean wrong).

This originates in the downstream discussion at... bbcmicrobit/micropython#288 and also relates to the discussion of pull defaults

The request is to provide a signature for getDigitalValue which promotes visibility of software-controllable pull behaviour and makes the existing default pull-setting visible and more accessible, as well as seamlessly allowing getDigitalValue calls to be opinionated about pull, and encouraging the downstream languages to extend their own mappings of the getDigitalValue call to include pull specification.

THE PROPOSAL

Pull should be set by...

  • calling getDigitalValue with an explicit pull argument (this is the extra requested signature, of which the below is a special case of resorting to a default value for this argument)
  • calling getDigitalValue with no explicit pull at which point they are implicitly set to e.g. MICROBIT_PULL_DEFAULT which is currently pull-down, though there should is a separate discussion about this. If previously set, getDigitalValue without an explicit pull will not overwrite the value.
  • explicitly pulling a pin (but not as part of a getDigitalValue call).

An alternative to avoid the potential for getDigitalValue() to be mistakenly substituted for setDigitalValue() which would end up with the same argument signature and a single character difference, is to provide getPulledValue() but this does not have the benefit of encouraging downstream languages to track an existing API they are bound to, and they may remain oblivious to the need to expose this key operation.

@finneyj
Copy link
Contributor

finneyj commented Jun 3, 2016

Thanks @cefn. Agree with all that, except the last point. getDigitalValue() is the known name - I think we should stick with it.

I'll draft up a pull request (pun intended!) for review.

finneyj added a commit that referenced this issue Jun 3, 2016
 - Introduced an overload to MicroBitIOPin::getDigitalValue() to permit the
setting of a specific pull mode at the time of reading.

 - Bugfix of MicroBitIOPin::setPull() to persist preferred pull settings

 - Added configuration options to allow the default PullMode to be set via
   compile time option through MicroBitConfig.h or YOTTA_CONFIG
@finneyj
Copy link
Contributor

finneyj commented Jun 3, 2016

#158

@finneyj
Copy link
Contributor

finneyj commented Jun 3, 2016

@cefn @dpgeorge @pelikhan

FYI, as requested. #158

finneyj added a commit that referenced this issue Jun 3, 2016
…ePullOverload

microbit: Added getDigitalValue overload for PullMode #156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants