firmata / firmata.js

JavaScript implementation of the Firmata protocol
711 stars 147 forks source link

enable digitalRead to return cached pin value if no callback is specified #167

Open soundanalogous opened 7 years ago

soundanalogous commented 7 years ago

Since digital values are reported on change for any port that is enabled, we could make the callback param for digitalRead optional. However this would require some changes. One change is to enable pin reporting when a pin mode is set to board.modes.INPUT (currently it's enabled upon a call to digitalRead). Then if no callback is specified, immediately return the cached value for the specified pin.