Skip to content

Commit

Permalink
Allow freenect_set_tilt_degs to take a negative angle
Browse files Browse the repository at this point in the history
I can't set a negative angle using gcc 4.8.2 for ARM since negative double values get clamped to 0x0 when casted to uint16_t, as one would expect. Oddly it works on a x86_64 build.

Fix the issue by casting the double to int16_t instead.

Signed-off-by: Jocelyn Turcotte <[email protected]>
  • Loading branch information
jturcotte committed Jun 25, 2014
1 parent 9b671cd commit 213c39a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tilt.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int freenect_set_tilt_degs(freenect_device *dev, double angle)
angle = (angle<MIN_TILT_ANGLE) ? MIN_TILT_ANGLE : ((angle>MAX_TILT_ANGLE) ? MAX_TILT_ANGLE : angle);
angle = angle * 2;

ret = fnusb_control(&dev->usb_motor, 0x40, 0x31, (uint16_t)angle, 0x0, empty, 0x0);
ret = fnusb_control(&dev->usb_motor, 0x40, 0x31, (int16_t)angle, 0x0, empty, 0x0);
return ret;
}

Expand Down

0 comments on commit 213c39a

Please sign in to comment.