-
Notifications
You must be signed in to change notification settings - Fork 146
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
firmataAccelStepper #179
firmataAccelStepper #179
Conversation
examples/stepper-accel.js
Outdated
board.accelStepperAcceleration(0, 100); | ||
board.accelStepperStep(0, 2000); | ||
|
||
board.on("stepper-done-0", function(position) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the callback example instead:
board.accelStepperStep(0, 2000, function(position) {
console.log("Current position: " + position);
});
Generally I don't think the typical user should ever have to know about the event "stepper-done-0".
examples/stepper-multi.js
Outdated
board.accelStepperReportPosition(1); | ||
}); | ||
|
||
board.on("stepper-position-0", function(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the callback example instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for "multi-stepper-done-0" above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And "stepper-position-1" below
readme.md
Outdated
// Arduino is ready to communicate | ||
}); | ||
``` | ||
|
||
#### With an Etherport object: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you had a bad rebase here. This section should not have been removed.
lib/firmata.js
Outdated
* @param {number} deviceNum Device number for the stepper (range 0-9) | ||
*/ | ||
|
||
Board.prototype.accelStepperReportPosition = function(deviceNum) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an optional callback to this method so the user doesn't have to worry about listening for "stepper-position-N".
* @param {number} deviceNum Device number for the stepper (range 0-9) | ||
*/ | ||
|
||
Board.prototype.accelStepperStop = function(deviceNum) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an optional callback for this method since it reports the current position.
examples/stepper-driver.js
Outdated
board.accelStepperEnable(0, true); | ||
board.accelStepperStep(0, 200); | ||
|
||
board.on("stepper-done-0", function(position) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use callback example instead.
examples/stepper-three-wire.js
Outdated
board.accelStepperSpeed(0, 100); | ||
board.accelStepperStep(0, 1000); | ||
|
||
board.on("stepper-done-0", function(position) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use callback instead
7328521
to
d8dec42
Compare
1 similar comment
|
||
this.transport.write(new Buffer(data)); | ||
|
||
if (callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this callback. I was wrong in requesting it be added to accelStepperStop
. This results in the callback being called twice (once because it's registered when a step sequence starts and a second time when it stops).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell if this was addressed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was resolved. The request was to remove the callback from accelStepperStop (which has been removed). It looks like I had added this comment to the wrong method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for clarifying
this.transport.write(new Buffer(data)); | ||
|
||
if (callback) { | ||
this.once("multi-stepper-done-" + groupNum, callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dtex If the user calls multiStepperStop
, this callback will never be handled. I'm not sure of the details of Node's EventEmitter once
method and if it cleans up unhandled events (if the next call to once
would deallocate memory from the previous unhandled event) or if we risk a memory leak here. One potential work around is to call reportGroupComplete in the firmware when a multiStepperStop message is received (see comment I left in ConfigurableFirmata).
Curious if @rwaldron has any insight into this as well since it's probably come up when implementing J5 modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added call to reportGroupComplete in the firmware.
fad02ab
to
e850d4f
Compare
Sorry, I forgot about this PR. I've updated the tests to accommodate the last change, so we should be good to go now. |
lib/firmata.js
Outdated
@@ -919,7 +948,7 @@ Board.prototype.pinMode = function(pin, mode) { | |||
/** | |||
* Asks the arduino to write a value to a digital pin | |||
* @param {number} pin The pin you want to write a value to. | |||
* @param {number} value The value you want to write. Must be board.HIGH or board.LOW | |||
* @param {value} value The value you want to write. Must be board.HIGH or board.LOW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should still be {number}
lib/firmata.js
Outdated
@@ -1148,13 +1177,13 @@ Board.prototype.sendI2CWriteRequest = function(slaveAddress, bytes) { | |||
* Write data to a register | |||
* | |||
* @param {number} address The address of the I2C device. | |||
* @param {Array} cmdRegOrData An array of bytes | |||
* @param {array} cmdRegOrData An array of bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought there was some weird bug (maybe in jshint or jscs?) that required {Array} instead of {array}. Perhaps it's been fixed though. If you're not seeing any lint errors then I'm sure {array} is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither of these changes were intentional. Let me hop back into my commit and make sure I'm not submitting anything else I didn't mean to.
2 similar comments
Ya, I improperly rebased at some point. I'll get it cleaned up later today. |
0a52738
to
848b289
Compare
First commit
It is cleaned up now. The |
Sounds like the lower case 'a' in {array} causes a syntax highlighting error in Webstorm: #174 |
I think this is ready to merge. @rwaldron sound good to you? |
|
||
Board.prototype.accelStepperConfig = function(opts) { | ||
|
||
var interface, pinsToInvert = 0x00; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface
is a reserved keyword in strict mode code. Ideally we want this code to be strict mode safe and es module safe (which is implicit strict mode). Since I've taken so long to review, I will make the fixes for you
FOUR_WIRE: 4, | ||
}, | ||
STEPTYPE: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name might be confusing with the unrelated TYPE
property? Can we call it STEP_SIZE
?
🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 Landed! |
Yay!!! |
Sorry for taking so damn long to review this, everyone's patience is truly appreciated <3 |
I've asked @dtex if we can wait until Monday to release |
Implementation of firmataAccelStepper
Works with this PR in ConfigurableFirmata
Was #176 but that fork got deleted by... uhm... Ninjas or something.