37 #define MAX_TILT_ANGLE 31 38 #define MIN_TILT_ANGLE (-31) 40 #define GRAVITY 9.80665 61 unsigned char buffer[512];
62 memset(buffer, 0, 512);
67 FN_ERROR(
"get_reply(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred);
68 }
else if (transferred != 12) {
69 FN_ERROR(
"get_reply(): weird - got %d bytes (expected 12)\n", transferred);
72 memcpy(&reply, buffer,
sizeof(reply));
73 if (reply.
magic != 0x0a6fe000) {
74 FN_ERROR(
"Bad magic: %08X (expected 0A6FE000\n", reply.
magic);
85 FN_ERROR(
"reply status != 0: failure?\n");
111 unsigned char buffer[256];
112 memcpy(buffer, &cmd, 16);
137 memcpy(&accel_and_tilt, buffer + 16,
sizeof(accel_and_tilt));
170 FN_ERROR(
"Error in accelerometer reading, libusb_control_transfer returned %d\n", ret);
171 return ret < 0 ? ret : -1;
174 ux = ((
uint16_t)buf[2] << 8) | buf[3];
175 uy = ((
uint16_t)buf[4] << 8) | buf[5];
176 uz = ((
uint16_t)buf[6] << 8) | buf[7];
191 if (tilt_degrees > 31 || tilt_degrees < -31) {
192 FN_WARNING(
"set_tilt(): degrees %d out of safe range [-31, 31]\n", tilt_degrees);
204 unsigned char buffer[20];
205 memcpy(buffer, &cmd, 20);
209 FN_ERROR(
"freenect_set_tilt_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred);
243 LED_ALT_BLINK_GREEN = 2,
244 LED_ALT_SOLID_GREEN = 3,
245 LED_ALT_SOLID_RED = 4,
273 unsigned char buffer[20];
274 memcpy(buffer, &cmd, 20);
278 FN_WARNING(
"fnusb_set_led_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred);
freenect_device_flags enabled_subdevices
int get_reply(libusb_device_handle *dev, freenect_context *ctx)
freenect_context * parent
FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle *dev, freenect_context *ctx, freenect_led_options state)
freenect_tilt_status_code tilt_status
freenect_tilt_status_code freenect_get_tilt_status(freenect_raw_tilt_state *state)
double freenect_get_tilt_degs(freenect_raw_tilt_state *state)
int freenect_set_led(freenect_device *dev, freenect_led_options option)
#define FREENECT_COUNTS_PER_G
int freenect_update_tilt_state(freenect_device *dev)
void freenect_get_mks_accel(freenect_raw_tilt_state *state, double *x, double *y, double *z)
int motor_control_with_audio_enabled
libusb_device_handle * dev
freenect_raw_tilt_state raw_state
FN_INTERNAL int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength)
int update_tilt_state_alt(freenect_device *dev)
static freenect_context * ctx
int freenect_set_tilt_degs(freenect_device *dev, double angle)
Data from the tilt motor and accelerometer.
int freenect_set_tilt_degs_alt(freenect_device *dev, int tilt_degrees)
int libusb_bulk_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)
freenect_raw_tilt_state * freenect_get_tilt_state(freenect_device *dev)
int freenect_set_led_alt(freenect_device *dev, freenect_led_options state)
freenect_tilt_status_code
Enumeration of tilt motor status.