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

Pin API docs don't distinguish digital vs analog pin methods #66

Open
EvanSimpson opened this issue Feb 8, 2015 · 1 comment
Open
Labels

Comments

@EvanSimpson
Copy link
Member

The documentation lists methods like pin.input() without distinguishing that they only exist in digital pin objects and not analog pin objects.

For example, the following script

var tessel = require('tessel');

var gpio = tessel.port['GPIO'];

var pin = gpio.pin['A1'];

pin.input();

produces this error

/app/index.js:7: attempt to call method 'input' (a nil value)

Whereas

var tessel = require('tessel');

var gpio = tessel.port['GPIO'];

var pin = gpio.pin['G1'];

pin.input();

works as expected.

Quick check to see the differences in methods:

var tessel = require('tessel');

var gpio = tessel.port['GPIO'];

var pin1 = gpio.pin['G1'];
var pin2 = gpio.pin['A1'];

var getAllMethods = function(object) {
  return Object.getOwnPropertyNames(object).filter(function(property) {
      return typeof object[property] == 'function';
  });
}

console.log("Digital pin:", getAllMethods(pin1));
console.log("Analog pin:", getAllMethods(pin2));
Digital pin: [ input, rawWrite, readSync, read, pull, output, rawRead, high, once, writeSync, set, toggle, removeListener, pulse, removeAllListeners, mode, setOutput, rawDirection, low, write, pulseIn, readPulse, on, setInput, addListener, setMaxListeners, removeListener, removeAllListeners, on, once, listeners, emit ]
Analog pin: [ write, read, readSync ]
@EvanSimpson EvanSimpson changed the title Pin API doesn't distinguish digital vs analog pin methods Pin API docs don't distinguish digital vs analog pin methods Feb 8, 2015
@johnnyman727
Copy link
Contributor

@EvanSimpson what do you think is the ideal way to handle this? Simply more descriptive error messages?

@Frijol Frijol added the bug label Apr 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants