-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Hello, I am just having trouble converting the dx and dy values from readBurst to usable signed integers and wondering if I could get some assistance on that. I was using the code from mrjohnk to do two's convolution on the DX_L and DY_L registers readings, but it doesn't seem to work on the raw dx and dy values from your code. It seems your code is returning a 16 bit number instead of an 8 bit..? Not sure on how to translate that. I just want to be able to use decimal integer values for motion tracking in a robotics project. Thanks!
Here is the code that I have been using:
int convTwosComp(int b){
//Convert from 2's complement
if(b & 0x80){ // 0x80 (hex) = 10000000 (bin) = 128 (dec)
b = -1 * ((b ^ 0xff) + 1); // 0xff (hex) = 11111111 (bin) = 255 (dec)
}
return b;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels