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

Consolidate all the proximity/ranging devices #688

Merged
merged 35 commits into from
Apr 29, 2015

Conversation

derekwheee
Copy link
Collaborator

This isn't done yet, but I wanted to get some input on the device/controller stuff. The way I understand it a device is used to transform the raw data from the sensor, while a controller is used to actually retrieve that data from the sensor. Specifically here.

cc @rwaldron @dtex

@rwaldron
Copy link
Owner

rwaldron commented Apr 3, 2015

device is used to transform the raw data from the sensor, while a controller is used to actually retrieve that data from the sensor.

controller provides all facets of read/write to a component. A device is used for device-specific functionality to be layered in, eg. overwriting methods of the component class.

There isn't any clear need to use a device for these components. Temperature or Accelerometer are good examples to align with

var proximity = new five.Proximity({
pin: "A0",
controller: "OA41SK"
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation here

@derekwheee
Copy link
Collaborator Author

@rwaldron I added SRF10 but I'm not confident it works. If you have one you could test that would be great. I can't get sinon tests to run on it, so I'm guessing either there's an error or I'm terrible at tests (both are likely).

@rwaldron
Copy link
Owner

rwaldron commented Apr 8, 2015

I will test that for you today!

…five into frxnz-proximity-refactor

* 'proximity-refactor' of https://github.com/frxnz/johnny-five:
  Pesky double quotes
  Refactoring data collection, adding SRF10
  MB1003 added to Proximity class
  All sensors should be controllers, not devices
  Refactored analog sensors, updated tests
});

prox.on("motionend", function(err, timestamp) {
led.off();
proximity.on("data", function(err, data) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For events, we're trying to get rid of the err, data arguments. Update the class, tests, etc. to emit only a data object

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I thought that was the case, but I opened a couple files and they had err. I'll clean those up.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up only for your Proximity and Motion classes. I have a patch I'm maintaining for all the rest

@rwaldron
Copy link
Owner

rwaldron commented Apr 8, 2015

I can't get sinon tests to run on it,

I'll take a look at this next

@@ -0,0 +1,249 @@
var Board = require("../lib/board.js"),
events = require("events"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add:

  within = require("./mixins/within"),
  __ = require("./fn"),

@rwaldron
Copy link
Owner

rwaldron commented Apr 8, 2015

so I'm guessing either there's an error or I'm terrible at tests (both are likely).

Definitely bugs :(

@rwaldron
Copy link
Owner

rwaldron commented Apr 8, 2015

I branched from your branch and committed a patch to fix the tests. You can pull it into your branch directly with:

git pull https://github.com/rwaldron/johnny-five.git frxnz-proximity-refactor-fix-tests

@derekwheee
Copy link
Collaborator Author

@rwaldron I just updated the examples. If there are any changes let me know, otherwise I think this is ready to land. I'll open a separate PR for Ping.

@rwaldron
Copy link
Owner

rwaldron commented Apr 9, 2015

otherwise I think this is ready to land.

This does look beautiful

I'll open a separate PR for Ping.

Not sure I understand this—why?

Also, Ping is going to have two different controllers, so we need to coordinate with @ajfisher on naming.

@derekwheee
Copy link
Collaborator Author

Not sure I understand this—why?

If you're not in a hurry to land I can do it here, but I may not be able to get to Ping until Monday.

@rwaldron
Copy link
Owner

rwaldron commented Apr 9, 2015

I'm not in a hurry :)

@rwaldron
Copy link
Owner

Cool, that's helpful (good direction when I sit down to test)

@derekwheee
Copy link
Collaborator Author

@rwaldron Rebased, updated the docs, and did a little cleanup. I don't know if you've had a chance to look at them, but the change and within tests for HC-SR04 are still giving me trouble.

@rwaldron
Copy link
Owner

I haven't, but I will tomorrow. Thanks for all your works so far :)

@@ -0,0 +1,19 @@
var five = require("johnny-five.js"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"johnny-five.js" => "../" (this is automatically converted by the examples task)

@derekwheee
Copy link
Collaborator Author

Big thanks to @rwaldron and @Resseguie for helping me get the HC-SR04 tests working 🎉

derekwheee added a commit that referenced this pull request Apr 29, 2015
Consolidate all the proximity/ranging devices. Closes #688.
@derekwheee derekwheee merged commit 310cdd1 into rwaldron:master Apr 29, 2015
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

Successfully merging this pull request may close these issues.

3 participants