Replies: 3 comments
-
Thanks @mores, actually a very good question, but can't answer it directly... |
Beta Was this translation helpful? Give feedback.
-
Hi @mores I usually write the values as hex, e.g. 0xff as you do, then case to byte, so this would be a one liner for me:
I understand it can be cumbersome, but then i usually use constants for special values and then don't need to think about it anymore. If you want such utility functions then you can send a PR for it, but i personally don't want to add another dependency to the pi4j project for just a few simple helper functions. |
Beta Was this translation helpful? Give feedback.
-
Hi, I blogged about this, and created a video: This helper method in Java can be very handy: |
Beta Was this translation helpful? Give feedback.
-
Is there a pi4j standard or recommendation how to deal with javas lack of an unsigned byte ?
create variables as short then cast them to byte ?
short myValue = 0xff;
byte[] data = new byte[1];
data[0] = (byte)myValue;
Or utilize a third part library like: https://github.com/jOOQ/jOOU
Or is there a Utility class somewhere in pi4j that could be used ?
Beta Was this translation helpful? Give feedback.
All reactions