The title should summarize the problem. I am using serial communication to read encoder values from the wheels of an iRobot Create 2. The desired sensor readings are 2 signed bytes. The sensor readings are read into an array of unsigned chars (communication is limited to sending/receiving 1 byte at a time).
I want to define my sensors to be signed 16 bit values. So that I don’t have to worry about manipulating the data, I have tried to use word(high_byte, low_byte); however, word() is unsigned, and does not work for what I need. Is there something similar to word() that will be treated as a signed value?
The important parts of my code are shown below. If you have any suggestions or easy solutions, I would gladly hear them!
unsigned char sensorbytes; #define left_encoder word(sensorbytes,sensorbytes) #define right_encoder word(sensorbytes,sensorbytes)