You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because Firmata only reports digital input values on change (via DIGITAL_MESSAGE), it is currently difficult to read a non-changing digital input. Currently there is only one way a non-changing digital pin value is reported and that is when a user enables reporting for a given port, the values of the pins on that port are reported even if they have not changed. However, depending on how a firmata host library and the user's code is structured, they may miss this value (for example a listener is declared after enabling port reporting). It is also not the most intuitive way to request a non-changing digital input.
There is a proposal open for a way to report digital pin values. That would enable a user to request a specific digital pin value at any time.
The tricky part would be in the Firmata host library implementations. Currently a lot of host libraries use the wiring syntax of digitalRead to report the existing DIGITAL_MESSAGE. This only reports digital input changes where as the PIN_VALUE_QUERY would enable a closer equivalent to the wiring digitalRead function (aside from the async vs sync issue). One way to update host apis is to use digitalReadOnce to issue a PIN_VALUE_QUERY (for a single digital pin). Generally however host libraries would benefit by using DIGITAL_MESSAGE since it is more efficient (reporting on port basis and only on change) when PIN_VALUE_QUERY would then be used only for fixed (non-changing) digital inputs as well as the general case of reporting board state after a reconnection event (which was the original intent for the pin value query proposal).
The text was updated successfully, but these errors were encountered:
@rwaldron this is something we will need to think about regarding firmata.js. The issue is if a user has some hard wired digital inputs (such as a collection of switches or fixed inputs used to identify some value on startup for example), it is currently easy to miss these values since Firmata only reports digital input changes.
Because Firmata only reports digital input values on change (via
DIGITAL_MESSAGE
), it is currently difficult to read a non-changing digital input. Currently there is only one way a non-changing digital pin value is reported and that is when a user enables reporting for a given port, the values of the pins on that port are reported even if they have not changed. However, depending on how a firmata host library and the user's code is structured, they may miss this value (for example a listener is declared after enabling port reporting). It is also not the most intuitive way to request a non-changing digital input.There is a proposal open for a way to report digital pin values. That would enable a user to request a specific digital pin value at any time.
The tricky part would be in the Firmata host library implementations. Currently a lot of host libraries use the wiring syntax of
digitalRead
to report the existingDIGITAL_MESSAGE
. This only reports digital input changes where as thePIN_VALUE_QUERY
would enable a closer equivalent to the wiringdigitalRead
function (aside from the async vs sync issue). One way to update host apis is to usedigitalReadOnce
to issue aPIN_VALUE_QUERY
(for a single digital pin). Generally however host libraries would benefit by usingDIGITAL_MESSAGE
since it is more efficient (reporting on port basis and only on change) whenPIN_VALUE_QUERY
would then be used only for fixed (non-changing) digital inputs as well as the general case of reporting board state after a reconnection event (which was the original intent for the pin value query proposal).The text was updated successfully, but these errors were encountered: