I'm really confused of how digitalRead/analogRead work.
In fact these two turn pin reporting on. In case of analogRead it floods host app with data.
On the other hand, digitalRead's callback is only called on value change. In Arduino *Read() means "single read". May be names are confusing.
One would expect simple flow:
digitalRead > sendPaketToArduino > digitalRead(port) /Arduino side/ > sendDigitalResponse > invokeCallback
The same applies to analogRead.
Now digitalRead is just: "reportDigitalPortChanges" and analogRead is: "turnOnAnalogPinReporting". This makes NodeJs app's flow much more complicated. For example - a trivial task - how can we read single port value?
Also, digitalWrite/analogWrite should execute callback so there is feedback from the write requests. Now it is like "fire and forget". Current implementations assume digitalWrite/analogWrite will succeed. But that's not always the case - for example communication failure.
Following NodeJs recommendations, at the end every function should start a callback with an error var as first parameter.
I'm really confused of how digitalRead/analogRead work.
In fact these two turn pin reporting on. In case of analogRead it floods host app with data.
On the other hand, digitalRead's callback is only called on value change. In Arduino *Read() means "single read". May be names are confusing.
One would expect simple flow:
digitalRead > sendPaketToArduino > digitalRead(port) /Arduino side/ > sendDigitalResponse > invokeCallback
The same applies to analogRead.
Now digitalRead is just: "reportDigitalPortChanges" and analogRead is: "turnOnAnalogPinReporting". This makes NodeJs app's flow much more complicated. For example - a trivial task - how can we read single port value?
Also, digitalWrite/analogWrite should execute callback so there is feedback from the write requests. Now it is like "fire and forget". Current implementations assume digitalWrite/analogWrite will succeed. But that's not always the case - for example communication failure.
Following NodeJs recommendations, at the end every function should start a callback with an error var as first parameter.