-
Notifications
You must be signed in to change notification settings - Fork 147
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
Conversation
Board.prototype.getSamplingInterval = function(interval) { | ||
return this.settings.samplingInterval; | ||
}; | ||
|
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.
Notes:
- I'd rather not perpetuate the pattern of naming methods
getFoo
andsetFoo
.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 returnundefined
until some code callssetSamplingInterval(...)
, but that's not correct, since the default is 19ms. AddsamplingInterval: 19
tovar defaults = {
(line 377)
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.
+1 to ditching the get and set style.
- Would it make sense to deprecate
setSamplingInterval
and add a fluent stylesamplingInterval
? - Done
*/ | ||
|
||
Board.prototype.getSamplingInterval = function(interval) { | ||
return this.settings.samplingInterval; |
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 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.
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.
Seems good to me
Published to v0.5.2 |
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.