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

Maybe a mistake in DigitalInputFirmata.kt, inside DigitalMessage #3

Open
Alfrederson opened this issue Nov 3, 2019 · 0 comments
Open

Comments

@Alfrederson
Copy link

The way it is now:
val values = (data[1].toInt() ushr 7) or data[2].toInt()
Throws away all the data bits in the first digital message data byte
It should be
val values = data[1].toInt() or (data[2].toInt() shl 7)
Which keeps the 7 bits, and then the LSB of data[2] becomes the MSB of the result

Also:
val port = data[0].toInt() and 0x7F
Will result in the port value being 16 higher than what is should be. Since the port number is just the second nibble of the 0x9_ command, the correct way is
val port = data[0].toInt() and 0x0F

Otherwise the port number and pin states can't be obtained from the data sent by the board.

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

No branches or pull requests

1 participant