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

ability to read non changing digital input #293

Open
soundanalogous opened this issue Jun 4, 2016 · 2 comments
Open

ability to read non changing digital input #293

soundanalogous opened this issue Jun 4, 2016 · 2 comments
Assignees
Milestone

Comments

@soundanalogous
Copy link
Member

soundanalogous commented Jun 4, 2016

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).

@soundanalogous
Copy link
Member Author

Related issue: firmata/firmata.js#125

@soundanalogous
Copy link
Member Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant