コード例 #1
0
ファイル: device.go プロジェクト: postfix/go-freenect
// GetAccelerometerState returns the axis-based gravity adjusted accelerometer
// state in the form of x-axis, y-axis, and z-axis states.
func (device *Device) GetAccelerometerState() (float64, float64, float64) {

	tiltState := C.freenect_get_tilt_state(device.device)

	var x, y, z C.double
	C.freenect_get_mks_accel(tiltState, &x, &y, &z)

	return float64(x), float64(y), float64(z)
}
コード例 #2
0
ファイル: freenect.go プロジェクト: buka/go-freenect
// Tells the device to update it's state data. If you're going to be reading values off the device,
// it's really necessary to be calling this function on a draw/game loop or go routine, otherwise the data will be stale.
func (tilt *Tilt) Refresh() {
	C.freenect_update_tilt_state(tilt.device.dev)
	state := C.freenect_get_tilt_state(tilt.device.dev)

	tilt.Angle = float32(C.freenect_get_tilt_degs(state))
	tilt.Status = int(C.freenect_get_tilt_status(state))
	var x, y, z C.double
	C.freenect_get_mks_accel(state, &x, &y, &z)
	tilt.AccelX = float32(x)
	tilt.AccelY = float32(y)
	tilt.AccelZ = float32(z)
}
コード例 #3
0
ファイル: freenect.go プロジェクト: krux02/freenect-go
//FREENECTAPI void freenect_get_mks_accel(freenect_raw_tilt_state *state, double* x, double* y, double* z);
func (this *RawTiltState) GetMksAccel() (x, y, z float64) {
	C.freenect_get_mks_accel(this.ptr(), (*C.double)(&x), (*C.double)(&y), (*C.double)(&z))
	return
}