Skip to content

Commit 213c39a

Browse files
committed
Allow freenect_set_tilt_degs to take a negative angle
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]>
1 parent 9b671cd commit 213c39a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/tilt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ int freenect_set_tilt_degs(freenect_device *dev, double angle)
239239
angle = (angle<MIN_TILT_ANGLE) ? MIN_TILT_ANGLE : ((angle>MAX_TILT_ANGLE) ? MAX_TILT_ANGLE : angle);
240240
angle = angle * 2;
241241

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

0 commit comments

Comments
 (0)