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

Reality Check: use Spark-IO with Johnny-Five to identify issues/bugs #9

Open
rwaldron opened this issue May 8, 2014 · 20 comments
Open

Comments

@rwaldron
Copy link
Owner

rwaldron commented May 8, 2014

Need to...

  • Reproduce Johnny-Five examples, but with Spark-IO + Spark Core device
  • Identify outstanding bugs
  • File those bugs as issues
  • Ideally fix them as well
@voodootikigod
Copy link
Contributor

I can rock on this! I have some time this week. Anyway to get some fritzing diagrams (will gladly help) for the breadboard layouts. Also will be a very awesome "getting started" guide for johnny-five in general.

@rwaldron
Copy link
Owner Author

@voodootikigod there are tons of them in Johnny-Five repo: https://github.com/rwaldron/johnny-five/tree/master/docs/breadboard

@voodootikigod
Copy link
Contributor

I had no idea this existed...!!!! omg happiness

Chris Williams

@voodootikigod http://twitter.com/voodootikigod |
GitHubhttp://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeeklyhttp://robotsweekly.com/

Help me end the negativity on the internet, share
thishttp://jsconf.eu/2011/an_end_to_negativity.html
.

On Sun, May 18, 2014 at 8:43 PM, Rick Waldron [email protected]:

@voodootikigod https://github.com/voodootikigod there are tons of them
in Johnny-Five repo:
https://github.com/rwaldron/johnny-five/tree/master/docs/breadboard


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-43458651
.

@Resseguie
Copy link
Collaborator

I can work on this too.

@Resseguie
Copy link
Collaborator

What's the best pattern for referencing J5 in these examples? Add it as a dependency (dev dependency?) or manually copy it to /lib?

var five = require("../lib/johnny-five.js"); // this ?
var five = require("johnny-five"); // or this?
// or something else?

Do you want J5 examples mixed in with vanilla spark-io ones? Or separate subdirectory under /eg?

Use same file names as J5 examples (eg. board.js)? Or prefix them somehow such as j5-board.js?

@Resseguie
Copy link
Collaborator

So before I go too far, is this what you had in mind for the original request? I basically just copied over files from the J5 eg/ folder and modified them to use spark-io (and tweaked to take advantage of things like the D7 LED).

https://github.com/Resseguie/spark-io/tree/j5-examples/eg

These are completely untested as of yet, but wanted to make sure I was on the right track before doing too many. I can also rename and reorganize per my previous comment before doing a pull request.

@rwaldron
Copy link
Owner Author

This is what example files that are local to the repo look like:

var five = require("../lib/johnny-five.js"); // this ?

This is what is used when you've installed Johnny-Five via npm install johnny-five:

var five = require("johnny-five"); // or this?

@rwaldron
Copy link
Owner Author

Do you want J5 examples mixed in with vanilla spark-io ones? Or separate subdirectory under /eg?

Mixed is fine

@rwaldron
Copy link
Owner Author

So before I go too far, is this what you had in mind for the original request? I basically just copied over files from the J5 eg/ folder and modified them to use spark-io

That's what I would've done

@Resseguie
Copy link
Collaborator

As far as referencing J5, I just wasn't sure if you wanted to check in a snapshot of johnny-five.js under lib/ or depend on using npm to install (my personal preference but don't feel strongly either way). And if we go the npm route, should it be listed under devDependencies?

@rwaldron
Copy link
Owner Author

In this case devDependencies would be fine

@Resseguie
Copy link
Collaborator

In converting a few of the examples for J5, I'm getting a similar error to what's described in this gist:
https://gist.github.com/Resseguie/21d83c60511789f51a23
(Gist is a direct copy of J5's led.js but using the spark-io plugin for creating the board.)

Basically, it's assuming pin is a string, but it's still a number at spark.js:276 and thus replace() isn't defined.

pinInt = (pin.replace(/A|D/, "") | 0) + offset; 

TypeError: Object 13 has no method 'replace'

Been spinning my tires a bit trying to figure out what's going on. Have a quick pointer to keep me rolling?

@rwaldron
Copy link
Owner Author

You'll need to change the pins from the numeric pins of an Arduino to the string pins of a Spark. The gist errors because 13 is an invalid pin for Spark, valid pins are: "D0-D7" and "A0-A7".

Change this:

var led = new five.Led(process.argv[2] || 13);

to this:

var led = new five.Led(process.argv[2] || "D7");

And it will be fine

@Resseguie
Copy link
Collaborator

Shoot, I copied over an old version by mistake in that gist. (It's been updated.)

Yes, the following works (using digital pin):

var led = new five.Led(process.argv[2] || "D7");

but not if you specify an analog one. The "A" gets stripped somewhere:

var led = new five.Led(process.argv[2] || "A1");
$ node led.js "A1"
1400642280013 Device(s) spark-io 
1400642280386 Connected spark-io 
1400642280387 Repl Initialized 
>> 
/Users/Resseguie/Dropbox/work/spark-io/lib/spark.js:276
  pinInt = (pin.replace(/A|D/, "") | 0) + offset;
                ^
TypeError: Object 1 has no method 'replace'
    at Spark.pinMode (/Users/Resseguie/Dropbox/work/spark-io/lib/spark.js:276:17)
    at Led.Object.defineProperties.mode.set (/Users/Resseguie/Dropbox/work/spark-io/node_modules/johnny-five/lib/led.js:83:19)
    at new Led (/Users/Resseguie/Dropbox/work/spark-io/node_modules/johnny-five/lib/led.js:94:15)
    at Board.<anonymous> (/Users/Resseguie/Dropbox/work/spark-io/eg/led.js:13:13)
    at Board.EventEmitter.emit (events.js:95:17)
    at Board.broadcast (/Users/Resseguie/Dropbox/work/spark-io/node_modules/johnny-five/lib/board.js:384:8)
    at Board.<anonymous> (/Users/Resseguie/Dropbox/work/spark-io/node_modules/johnny-five/lib/board.js:298:23)
    at Spark.g (events.js:180:16)
    at Spark.EventEmitter.emit (events.js:92:17)
    at Socket.<anonymous> (/Users/Resseguie/Dropbox/work/spark-io/lib/spark.js:183:13)

@rwaldron
Copy link
Owner Author

but not if you specify an analog one. The "A" gets stripped somewhere:

That's an awesome bug you found—great work!

@rwaldron
Copy link
Owner Author

#17

@Resseguie
Copy link
Collaborator

Not ready to do a PR until I've better tested all these, but if anyone is interested in tracking progress of the examples I've added so far, you can see them in this branch off my fork:
https://github.com/Resseguie/spark-io/tree/j5-examples/eg

@voodootikigod
Copy link
Contributor

Awesome work!!!

I disappear for two days and you two rock the heck out of it!!! Thank you!

Chris Williams

@voodootikigod http://twitter.com/voodootikigod |
GitHubhttp://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeeklyhttp://robotsweekly.com/

Help me end the negativity on the internet, share
thishttp://jsconf.eu/2011/an_end_to_negativity.html
.

On Wed, May 21, 2014 at 11:32 PM, David Resseguie
[email protected]:

Not ready to do a PR until I've better tested all these, but if anyone is
interested in tracking progress of the examples I've added so far, you can
see them in this branch off my fork:
https://github.com/Resseguie/spark-io/tree/j5-examples/eg


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-43845328
.

@Resseguie
Copy link
Collaborator

Question: In Johnny-Five examples, we have pairs like button.js and button-options.js that are basically identical but the second demonstrates passing multiple options to constructor. Do we really need both those when refactoring for spark-io, or can I just include a comment in button.js that demonstrates the other options? Feels redundant to have both almost identical examples.

@rwaldron
Copy link
Owner Author

rwaldron commented Jun 4, 2014

can I just include a comment in button.js that demonstrates the other options?

That sounds good to me :)

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