processing: convert int to byte
- by inspectorG4dget
Hello SO,
I'm trying to convert an int into a byte in Processing 1.0.9.
This is the snippet of code that I have been working with:
byte xByte = byte(mouseX);
byte yByte = byte(mouseY);
byte setFirst = byte(128);
byte resetFirst = byte(127);
xByte = xByte | setFirst;
yByte = yByte >> 1;
port.write(xByte);
port.write(yByte);
According to the Processing API, this should work, but I keep getting an error at xByte = xByte | setFirst; that says:
cannot convert from int to byte
I have tried converting 128 and 127 to they respective hex values (0x80 and 0x7F), but that didn't work either. I have tried everything mentioned in the API as well as some other blogs, but I feel like I'm missing something very trivial.
I would appreciate any help.
Thank you.