-
Notifications
You must be signed in to change notification settings - Fork 31
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
Comments
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. |
@voodootikigod there are tons of them in Johnny-Five repo: https://github.com/rwaldron/johnny-five/tree/master/docs/breadboard |
I had no idea this existed...!!!! omg happiness Chris Williams @voodootikigod http://twitter.com/voodootikigod | The things I make that you should check out: Help me end the negativity on the internet, share On Sun, May 18, 2014 at 8:43 PM, Rick Waldron [email protected]:
|
I can work on this too. |
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? |
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. |
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 var five = require("johnny-five"); // or this? |
Mixed is fine |
That's what I would've done |
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? |
In this case devDependencies would be fine |
In converting a few of the examples for J5, I'm getting a similar error to what's described in this gist: 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? |
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 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 |
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) |
That's an awesome bug you found—great work! |
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: |
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 | The things I make that you should check out: Help me end the negativity on the internet, share On Wed, May 21, 2014 at 11:32 PM, David Resseguie
|
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. |
That sounds good to me :) |
Need to...
The text was updated successfully, but these errors were encountered: