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

pulseIn #59

Open
brasilikum opened this issue Apr 12, 2015 · 3 comments
Open

pulseIn #59

brasilikum opened this issue Apr 12, 2015 · 3 comments

Comments

@brasilikum
Copy link

Would be nice if support for "pulseIn" could be added.

The example:

board.on("ready", function() {
  var ping = new five.Ping('D4');
  ping.on("change", function() {
    console.log("Object is " + this.in + " inches away");
  });
});

results in:

TypeError: Object #<Spark> has no method 'pulseIn'
    at Ping.<anonymous> (/home/georgzahlz/johnny/node_modules/johnny-five/lib/ping.js:45:13)
    at wrapper [as _onTimeout] (timers.js:261:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

@Resseguie
Copy link
Collaborator

Ping requires a special firmata be installed, even on plain ol' Arduino. Not sure what it'd require to implement something similar on the Spark.
See: https://github.com/rwaldron/johnny-five/wiki/Ping

@rwaldron
Copy link
Owner

Ping requires a special firmata be installed

To elaborate: pulseIn is not supported in the Firmata protocol, because it's a process blocking operation. Unfortunately, the version of Firmata we have to support Ping isn't a generalized implementation—it's specifically for a Ping sensor.

Incidentally, pulseIn doesn't appear to be provided in the Spark's environment: https://github.com/spark/firmware . There are a few forum discussions that offer some sound solutions, but I have serious concerns about adding an operation that requires process blocking on the Spark itself, where it already suffers from wifi latency.

@brasilikum
Copy link
Author

Ok, I understand that.
This solution really seems to be blocking:

// Wait for the pin to enter target state while keeping track of the timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants