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

firmataAccelStepper #179

Closed
wants to merge 1 commit into from
Closed

firmataAccelStepper #179

wants to merge 1 commit into from

Conversation

dtex
Copy link
Contributor

@dtex dtex commented Aug 27, 2017

Implementation of firmataAccelStepper

Works with this PR in ConfigurableFirmata

Was #176 but that fork got deleted by... uhm... Ninjas or something.

@dtex dtex mentioned this pull request Aug 27, 2017
@coveralls
Copy link

coveralls commented Aug 27, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 750c07c on dtex:accelStepper into 0523f58 on firmata:master.

board.accelStepperAcceleration(0, 100);
board.accelStepperStep(0, 2000);

board.on("stepper-done-0", function(position) {
Copy link
Member

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".

board.accelStepperReportPosition(1);
});

board.on("stepper-position-0", function(value) {
Copy link
Member

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

Copy link
Member

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

Copy link
Member

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:
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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.

board.accelStepperEnable(0, true);
board.accelStepperStep(0, 200);

board.on("stepper-done-0", function(position) {
Copy link
Member

Choose a reason for hiding this comment

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

Use callback example instead.

board.accelStepperSpeed(0, 100);
board.accelStepperStep(0, 1000);

board.on("stepper-done-0", function(position) {
Copy link
Member

Choose a reason for hiding this comment

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

Use callback instead

@coveralls
Copy link

coveralls commented Aug 28, 2017

Coverage Status

Coverage decreased (-0.2%) to 99.765% when pulling 3dd52b7 on dtex:accelStepper into 0523f58 on firmata:master.

@dtex dtex force-pushed the accelStepper branch 2 times, most recently from 7328521 to d8dec42 Compare August 30, 2017 20:41
@coveralls
Copy link

coveralls commented Aug 30, 2017

Coverage Status

Coverage decreased (-0.2%) to 99.765% when pulling 7328521 on dtex:accelStepper into 0523f58 on firmata:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.765% when pulling 7328521 on dtex:accelStepper into 0523f58 on firmata:master.

@coveralls
Copy link

coveralls commented Aug 30, 2017

Coverage Status

Coverage decreased (-0.2%) to 99.765% when pulling d8dec42 on dtex:accelStepper into 0523f58 on firmata:master.

@coveralls
Copy link

coveralls commented Aug 31, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling b487e77 on dtex:accelStepper into 0523f58 on firmata:master.


this.transport.write(new Buffer(data));

if (callback) {
Copy link
Member

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).

Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Collaborator

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);
Copy link
Member

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.

Copy link
Contributor Author

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.

@coveralls
Copy link

coveralls commented Oct 20, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling fad02ab on dtex:accelStepper into 0523f58 on firmata:master.

@coveralls
Copy link

coveralls commented Oct 20, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling e850d4f on dtex:accelStepper into 0523f58 on firmata:master.

@dtex
Copy link
Contributor Author

dtex commented Oct 20, 2017

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
Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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.

@coveralls
Copy link

coveralls commented Oct 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling f4c6f7c on dtex:accelStepper into 0523f58 on firmata:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling f4c6f7c on dtex:accelStepper into 0523f58 on firmata:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling f4c6f7c on dtex:accelStepper into 0523f58 on firmata:master.

@dtex
Copy link
Contributor Author

dtex commented Oct 21, 2017

Ya, I improperly rebased at some point. I'll get it cleaned up later today.

@coveralls
Copy link

coveralls commented Oct 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling fe99622 on dtex:accelStepper into 0523f58 on firmata:master.

@dtex dtex force-pushed the accelStepper branch 2 times, most recently from 0a52738 to 848b289 Compare October 21, 2017 15:36
@coveralls
Copy link

coveralls commented Oct 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 0a52738 on dtex:accelStepper into 0523f58 on firmata:master.

First commit
@coveralls
Copy link

coveralls commented Oct 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 848b289 on dtex:accelStepper into 0523f58 on firmata:master.

@coveralls
Copy link

coveralls commented Oct 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 79d8059 on dtex:accelStepper into 0523f58 on firmata:master.

@coveralls
Copy link

coveralls commented Oct 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 79d8059 on dtex:accelStepper into 0523f58 on firmata:master.

@dtex
Copy link
Contributor Author

dtex commented Oct 21, 2017

It is cleaned up now. The array->Array changes came from @rumata28 so they might have more info about that jsdoc/jshint bug you mention.

@soundanalogous
Copy link
Member

Sounds like the lower case 'a' in {array} causes a syntax highlighting error in Webstorm: #174

@soundanalogous
Copy link
Member

I think this is ready to merge. @rwaldron sound good to you?


Board.prototype.accelStepperConfig = function(opts) {

var interface, pinsToInvert = 0x00;
Copy link
Collaborator

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: {
Copy link
Collaborator

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?

@rwaldron
Copy link
Collaborator

rwaldron commented Jan 5, 2018

🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉

Landed!

@rwaldron rwaldron closed this Jan 5, 2018
@soundanalogous
Copy link
Member

Yay!!!

@rwaldron
Copy link
Collaborator

rwaldron commented Jan 5, 2018

Sorry for taking so damn long to review this, everyone's patience is truly appreciated <3

@rwaldron
Copy link
Collaborator

rwaldron commented Jan 5, 2018

I've asked @dtex if we can wait until Monday to release

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.

None yet

4 participants