diff options
author | Justin Berger <j.david.berger@gmail.com> | 2018-04-10 23:47:11 -0600 |
---|---|---|
committer | Justin Berger <j.david.berger@gmail.com> | 2018-04-10 23:47:11 -0600 |
commit | e6b487cacfd57792b9cdcde30489faf19f2a4a77 (patch) | |
tree | 2435f0302849919aa5001961a95daff693a16a12 /src/survive_vive.c | |
parent | 30cfb87ec0d95e0cb8a671cf8f2327b4204927ed (diff) | |
parent | d7c88592a5450a65f5359e23d87122a04d019503 (diff) | |
download | libsurvive-e6b487cacfd57792b9cdcde30489faf19f2a4a77.tar.gz libsurvive-e6b487cacfd57792b9cdcde30489faf19f2a4a77.tar.bz2 |
Merge branch 'master' into simple_api
Diffstat (limited to 'src/survive_vive.c')
-rwxr-xr-x | src/survive_vive.c | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/src/survive_vive.c b/src/survive_vive.c index 1ffb737..0fae736 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -1233,31 +1233,15 @@ static void handle_watchman( SurviveObject * w, uint8_t * readdata ) if( ( ( type & 0xe8 ) == 0xe8 ) || doimu ) //Hmm, this looks kind of yucky... we can get e8's that are accelgyro's but, cleared by first propset. { propset |= 2; - //XXX XXX BIG TODO!!! Actually recal gyro data. - FLT agm[9] = { readdata[1], readdata[2], readdata[3], - readdata[4], readdata[5], readdata[6], - 0,0,0 }; - -// if (w->acc_scale) printf("%f %f %f\n",w->acc_scale[0],w->acc_scale[1],w->acc_scale[2]); + FLT agm[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + int j; + for (j = 0; j < 6; j++) + agm[j] = (int16_t)(readdata[j * 2 + 1] | (readdata[j * 2 + 2] << 8)); calibrate_acc(w, agm); - - //I don't understand where these numbers come from but the data from the WMD seems to max out at 255... - agm[0]*=(1.0f/255.0f); - agm[1]*=(1.0f/255.0f); - agm[2]*=(1.0f/255.0f); - calibrate_gyro(w, agm+3); - - //I don't understand where these numbers come from but the data from the WMD seems to max out at 255... - agm[3]*=(1.0f/255.0f); - agm[4]*=(1.0f/255.0f); - agm[5]*=(1.0f/255.0f); - w->ctx->imuproc( w, 3, agm, (time1<<24)|(time2<<16)|readdata[0], 0 ); - - int16_t * k = (int16_t *)readdata+1; - //printf( "Match8 %d %d %d %d %d %3d %3d\n", qty, k[0], k[1], k[2], k[3], k[4], k[5] ); readdata += 13; qty -= 13; + type &= ~0xe8; if( qty ) { @@ -1495,24 +1479,8 @@ void survive_data_cb( SurviveUSBInterface * si ) 0, 0}; - //1G for accelerometer, from MPU6500 datasheet - //this can change if the firmware changes the sensitivity. - // When coming off of USB, these values are in units of .5g -JB - agm[0] *= (float)(2. / 8192.0); - agm[1] *= (float)(2. / 8192.0); - agm[2] *= (float)(2. / 8192.0); calibrate_acc(obj, agm); - - // From datasheet, can be 250, 500, 1000, 2000 deg/s range over 16 bits - // FLT deg_per_sec = 250; - // FLT conv = (float)((1./deg_per_sec)*(3.14159/180.)) / 8192.; - FLT DEGREES_TO_RADS = 3.14159 / 180.; - FLT conv = 1. / 10. * DEGREES_TO_RADS; calibrate_gyro(obj, agm + 3); - agm[3] *= conv; - agm[4] *= conv; - agm[5] *= conv; - ctx->imuproc( obj, 3, agm, timecode, code ); } } |