algorithm/osp/osp.c
static void ResultReadyCB(struct Results *res, int sensor)
{
	union {
		Android_TriAxisPreciseData_t calresult;
		Android_TriAxisExtendedData_t calmag;
		Android_UncalibratedTriAxisPreciseData_t uncalresult;
		Android_UncalibratedTriAxisExtendedData_t uncalmag;
		Android_BooleanResultData_t sigmot;
		Android_OrientationResultData_t orient;
		Android_RotationVectorResultData_t rotvec;
	} r;

	if (!resHandles[sensor])
		return;
	switch(sensor) {
	case SENSOR_ACCELEROMETER:
		r.calresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.calresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.calresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.calresult.TimeStamp = res->time;
		break;
	case SENSOR_MAGNETIC_FIELD_UNCALIBRATED:
		r.uncalmag.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.uncalmag.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.uncalmag.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.uncalmag.TimeStamp = res->time;
		break;
	case SENSOR_MAGNETIC_FIELD:
		r.calmag.X = Q15_to_NTEXTENDED(res->ResType.result.x);
		r.calmag.Y = Q15_to_NTEXTENDED(res->ResType.result.y);
		r.calmag.Z = Q15_to_NTEXTENDED(res->ResType.result.z);
		r.calmag.TimeStamp = res->time;
		break;
	case SENSOR_GYROSCOPE_UNCALIBRATED:
		r.uncalresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.uncalresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.uncalresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.uncalresult.TimeStamp = res->time;
		break;
	case SENSOR_GYROSCOPE:
		r.calresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.calresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.calresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.calresult.TimeStamp = res->time;
		break;
	case SENSOR_ORIENTATION:
		r.orient.Pitch = Q15_to_NTEXTENDED(res->ResType.euler.pitch);
		r.orient.Roll = Q15_to_NTEXTENDED(res->ResType.euler.roll);
		r.orient.Yaw = Q15_to_NTEXTENDED(res->ResType.euler.yaw);
		r.orient.TimeStamp = res->time;
		break;
	case SENSOR_PRESSURE:
		return;
	case SENSOR_GRAVITY:
	case SENSOR_LINEAR_ACCELERATION:
		r.calresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.calresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.calresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.calresult.TimeStamp = res->time;
		break;

	case SENSOR_ROTATION_VECTOR:
		r.rotvec.X = Q15_to_NTPRECISE(res->ResType.quat.x);
		r.rotvec.Y = Q15_to_NTPRECISE(res->ResType.quat.y);
		r.rotvec.Z = Q15_to_NTPRECISE(res->ResType.quat.z);
		r.rotvec.W = Q15_to_NTPRECISE(res->ResType.quat.w);
		r.rotvec.TimeStamp = res->time;
		break;
	case SENSOR_SIGNIFICANT_MOTION:
	case SENSOR_TILT_DETECTOR:
		r.sigmot.data = true;
		r.sigmot.TimeStamp = res->time;
		break;
	default:
		return;
	}
	if (resHandles[sensor]->pResultReadyCallback) {
		printf("Calling: %i\n", sensor);
		resHandles[sensor]->pResultReadyCallback(resHandles[sensor],
			&r);
	}
}
/* Dispatch data in the different esoteric structure */
Dispatch data in the different esoteric structure
Dispatch data in the different esoteric structure
static void ResultReadyCB(struct Results *res, int sensor)
{
	union {
		Android_TriAxisPreciseData_t calresult;
		Android_TriAxisExtendedData_t calmag;
		Android_UncalibratedTriAxisPreciseData_t uncalresult;
		Android_UncalibratedTriAxisExtendedData_t uncalmag;
		Android_BooleanResultData_t sigmot;
		Android_OrientationResultData_t orient;
		Android_RotationVectorResultData_t rotvec;
	} r;
	if (!resHandles[sensor])
		return;
	switch(sensor) {
	case SENSOR_ACCELEROMETER:
		r.calresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.calresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.calresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.calresult.TimeStamp = res->time;
		break;
	case SENSOR_MAGNETIC_FIELD_UNCALIBRATED:
		r.uncalmag.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.uncalmag.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.uncalmag.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.uncalmag.TimeStamp = res->time;
		break;
	case SENSOR_MAGNETIC_FIELD:
		r.calmag.X = Q15_to_NTEXTENDED(res->ResType.result.x);
		r.calmag.Y = Q15_to_NTEXTENDED(res->ResType.result.y);
		r.calmag.Z = Q15_to_NTEXTENDED(res->ResType.result.z);
		r.calmag.TimeStamp = res->time;
		break;
	case SENSOR_GYROSCOPE_UNCALIBRATED:
		r.uncalresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.uncalresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.uncalresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.uncalresult.TimeStamp = res->time;
		break;
	case SENSOR_GYROSCOPE:
		r.calresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.calresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.calresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.calresult.TimeStamp = res->time;
		break;
	case SENSOR_ORIENTATION:
		r.orient.Pitch = Q15_to_NTEXTENDED(res->ResType.euler.pitch);
		r.orient.Roll = Q15_to_NTEXTENDED(res->ResType.euler.roll);
		r.orient.Yaw = Q15_to_NTEXTENDED(res->ResType.euler.yaw);
		r.orient.TimeStamp = res->time;
		break;
	case SENSOR_PRESSURE:
		return;
	case SENSOR_GRAVITY:
	case SENSOR_LINEAR_ACCELERATION:
		r.calresult.X = Q15_to_NTPRECISE(res->ResType.result.x);
		r.calresult.Y = Q15_to_NTPRECISE(res->ResType.result.y);
		r.calresult.Z = Q15_to_NTPRECISE(res->ResType.result.z);
		r.calresult.TimeStamp = res->time;
		break;
	case SENSOR_ROTATION_VECTOR:
		r.rotvec.X = Q15_to_NTPRECISE(res->ResType.quat.x);
		r.rotvec.Y = Q15_to_NTPRECISE(res->ResType.quat.y);
		r.rotvec.Z = Q15_to_NTPRECISE(res->ResType.quat.z);
		r.rotvec.W = Q15_to_NTPRECISE(res->ResType.quat.w);
		r.rotvec.TimeStamp = res->time;
		break;
	case SENSOR_SIGNIFICANT_MOTION:
	case SENSOR_TILT_DETECTOR:
		r.sigmot.data = true;
		r.sigmot.TimeStamp = res->time;
		break;
	default:
		return;
	}
	if (resHandles[sensor]->pResultReadyCallback) {
		printf("Calling: %i\n", sensor);
		resHandles[sensor]->pResultReadyCallback(resHandles[sensor],
			&r);
	}
}
static void ResultReadyCB ( struct Results * res , int sensor ) { union { Android_TriAxisPreciseData_t calresult ; Android_TriAxisExtendedData_t calmag ; Android_UncalibratedTriAxisPreciseData_t uncalresult ; Android_UncalibratedTriAxisExtendedData_t uncalmag ; Android_BooleanResultData_t sigmot ; Android_OrientationResultData_t orient ; Android_RotationVectorResultData_t rotvec ; } r ; if ( ! resHandles [ sensor ] ) return ; switch ( sensor ) { case SENSOR_ACCELEROMETER : r . calresult . X = Q15_to_NTPRECISE ( res -> ResType . result . x ) ; r . calresult . Y = Q15_to_NTPRECISE ( res -> ResType . result . y ) ; r . calresult . Z = Q15_to_NTPRECISE ( res -> ResType . result . z ) ; r . calresult . TimeStamp = res -> time ; break ; case SENSOR_MAGNETIC_FIELD_UNCALIBRATED : r . uncalmag . X = Q15_to_NTPRECISE ( res -> ResType . result . x ) ; r . uncalmag . Y = Q15_to_NTPRECISE ( res -> ResType . result . y ) ; r . uncalmag . Z = Q15_to_NTPRECISE ( res -> ResType . result . z ) ; r . uncalmag . TimeStamp = res -> time ; break ; case SENSOR_MAGNETIC_FIELD : r . calmag . X = Q15_to_NTEXTENDED ( res -> ResType . result . x ) ; r . calmag . Y = Q15_to_NTEXTENDED ( res -> ResType . result . y ) ; r . calmag . Z = Q15_to_NTEXTENDED ( res -> ResType . result . z ) ; r . calmag . TimeStamp = res -> time ; break ; case SENSOR_GYROSCOPE_UNCALIBRATED : r . uncalresult . X = Q15_to_NTPRECISE ( res -> ResType . result . x ) ; r . uncalresult . Y = Q15_to_NTPRECISE ( res -> ResType . result . y ) ; r . uncalresult . Z = Q15_to_NTPRECISE ( res -> ResType . result . z ) ; r . uncalresult . TimeStamp = res -> time ; break ; case SENSOR_GYROSCOPE : r . calresult . X = Q15_to_NTPRECISE ( res -> ResType . result . x ) ; r . calresult . Y = Q15_to_NTPRECISE ( res -> ResType . result . y ) ; r . calresult . Z = Q15_to_NTPRECISE ( res -> ResType . result . z ) ; r . calresult . TimeStamp = res -> time ; break ; case SENSOR_ORIENTATION : r . orient . Pitch = Q15_to_NTEXTENDED ( res -> ResType . euler . pitch ) ; r . orient . Roll = Q15_to_NTEXTENDED ( res -> ResType . euler . roll ) ; r . orient . Yaw = Q15_to_NTEXTENDED ( res -> ResType . euler . yaw ) ; r . orient . TimeStamp = res -> time ; break ; case SENSOR_PRESSURE : return ; case SENSOR_GRAVITY : case SENSOR_LINEAR_ACCELERATION : r . calresult . X = Q15_to_NTPRECISE ( res -> ResType . result . x ) ; r . calresult . Y = Q15_to_NTPRECISE ( res -> ResType . result . y ) ; r . calresult . Z = Q15_to_NTPRECISE ( res -> ResType . result . z ) ; r . calresult . TimeStamp = res -> time ; break ; case SENSOR_ROTATION_VECTOR : r . rotvec . X = Q15_to_NTPRECISE ( res -> ResType . quat . x ) ; r . rotvec . Y = Q15_to_NTPRECISE ( res -> ResType . quat . y ) ; r . rotvec . Z = Q15_to_NTPRECISE ( res -> ResType . quat . z ) ; r . rotvec . W = Q15_to_NTPRECISE ( res -> ResType . quat . w ) ; r . rotvec . TimeStamp = res -> time ; break ; case SENSOR_SIGNIFICANT_MOTION : case SENSOR_TILT_DETECTOR : r . sigmot . data = true ; r . sigmot . TimeStamp = res -> time ; break ; default : return ; } if ( resHandles [ sensor ] -> pResultReadyCallback ) { printf ( " \n " , sensor ) ; resHandles [ sensor ] -> pResultReadyCallback ( resHandles [ sensor ] , & r ) ; } }
Dispatch data in the different esoteric structure
Dispatch data in the different esoteric structure