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

expose sampling interval #91

Merged
merged 3 commits into from
May 20, 2015
Merged

expose sampling interval #91

merged 3 commits into from
May 20, 2015

Conversation

iamdustan
Copy link
Contributor

Can be useful to query the state of the board and set timers based on the query interval. Potential use case would be to shim requestAnimationFrame to sync with the board query interval.

Board.prototype.getSamplingInterval = function(interval) {
return this.settings.samplingInterval;
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

Notes:

  • I'd rather not perpetuate the pattern of naming methods getFoo and setFoo. setSamplingInterval was added before I took on maintainership and it's an eye sore. I'm not sure what to do about it now, if anything. I probably have to just accept it.
  • If no samplingInterval is specified, this will return undefined until some code calls setSamplingInterval(...), but that's not correct, since the default is 19ms. Add samplingInterval: 19 to var defaults = { (line 377)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 to ditching the get and set style.

  1. Would it make sense to deprecate setSamplingInterval and add a fluent style samplingInterval?
  2. Done

*/

Board.prototype.getSamplingInterval = function(interval) {
return this.settings.samplingInterval;
Copy link
Member

Choose a reason for hiding this comment

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

I should probably add a way to query the sampling interval in Firmata. I'm not sure about J5 / node-firmata, but some Firmata client's enable multiple connections to a single board (more common when using networking transports rather than serial). In this case, one client could set the sampling interval but another client would not know it has changed.

firmata/arduino#198

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems good to me

rwaldron added a commit that referenced this pull request May 20, 2015
@rwaldron rwaldron merged commit a448356 into firmata:master May 20, 2015
@rwaldron
Copy link
Collaborator

Published to v0.5.2

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