diff options
-rw-r--r-- | libsensors/MPLSensor.cpp | 54 | ||||
-rw-r--r-- | libsensors/MPLSensor.h | 4 | ||||
-rw-r--r-- | libsensors/sensor_params.h | 21 |
3 files changed, 33 insertions, 46 deletions
diff --git a/libsensors/MPLSensor.cpp b/libsensors/MPLSensor.cpp index ca08ad5..23c67c7 100644 --- a/libsensors/MPLSensor.cpp +++ b/libsensors/MPLSensor.cpp @@ -1070,16 +1070,24 @@ int MPLSensor::populateSensorList(struct sensor_t *list, size_t len) numsensors = 7; /* all sensors will be added to the list */ /* fill in orientation values */ - fillOrientation(list); + list[Orientation].maxRange = NINEAXIS_ORIENTATION_RANGE; + list[Orientation].resolution = NINEAXIS_ORIENTATION_RESOLUTION; + list[Orientation].power = NINEAXIS_ORIENTATION_POWER; /* fill in rotation vector values */ - fillRV(list); + list[RotationVector].maxRange = NINEAXIS_ROTATION_VECTOR_RANGE; + list[RotationVector].resolution = NINEAXIS_ROTATION_VECTOR_RESOLUTION; + list[RotationVector].power = NINEAXIS_ROTATION_VECTOR_POWER; /* fill in gravity values */ - fillGravity(list); + list[Gravity].maxRange = NINEAXIS_GRAVITY_RANGE; + list[Gravity].resolution = NINEAXIS_GRAVITY_RESOLUTION; + list[Gravity].power = NINEAXIS_GRAVITY_POWER; /* fill in Linear accel values */ - fillLinearAccel(list); + list[LinearAccel].maxRange = NINEAXIS_LINEAR_ACCEL_RANGE; + list[LinearAccel].resolution = NINEAXIS_LINEAR_ACCEL_RESOLUTION; + list[LinearAccel].power = NINEAXIS_LINEAR_ACCEL_POWER; } else { /* no 9-axis sensors, zero fill that part of the list */ numsensors = 3; @@ -1088,41 +1096,3 @@ int MPLSensor::populateSensorList(struct sensor_t *list, size_t len) return numsensors; } - -/* fillRV depends on values of accel and compass in the list */ -void MPLSensor::fillRV(struct sensor_t *list) -{ - /* compute power on the fly */ - list[RotationVector].power = list[Gyro].power + list[Accelerometer].power - + list[MagneticField].power; - list[RotationVector].resolution = .00001; - list[RotationVector].maxRange = 1.0; - return; -} - -void MPLSensor::fillOrientation(struct sensor_t *list) -{ - list[Orientation].power = list[Gyro].power + list[Accelerometer].power - + list[MagneticField].power; - list[Orientation].resolution = .00001; - list[Orientation].maxRange = 360.0; - return; -} - -void MPLSensor::fillGravity( struct sensor_t *list) -{ - list[Gravity].power = list[Gyro].power + list[Accelerometer].power - + list[MagneticField].power; - list[Gravity].resolution = .00001; - list[Gravity].maxRange = 9.81; - return; -} - -void MPLSensor::fillLinearAccel(struct sensor_t *list) -{ - list[Gravity].power = list[Gyro].power + list[Accelerometer].power - + list[MagneticField].power; - list[Gravity].resolution = list[Accelerometer].resolution; - list[Gravity].maxRange = list[Accelerometer].maxRange; - return; -} diff --git a/libsensors/MPLSensor.h b/libsensors/MPLSensor.h index ea72c72..eba750a 100644 --- a/libsensors/MPLSensor.h +++ b/libsensors/MPLSensor.h @@ -120,10 +120,6 @@ private: /* added for dynamic get sensor list */ bool mNineAxisEnabled; - void fillRV(struct sensor_t *list); - void fillOrientation(struct sensor_t *list); - void fillGravity(struct sensor_t *list); - void fillLinearAccel(struct sensor_t *list); }; void setCallbackObject(MPLSensor*); diff --git a/libsensors/sensor_params.h b/libsensors/sensor_params.h index 056e587..db7f2a4 100644 --- a/libsensors/sensor_params.h +++ b/libsensors/sensor_params.h @@ -41,6 +41,27 @@ #define GYRO_MPU3050_RANGE (2000.0f*RAD_P_DEG) #define GYRO_MPU3050_RESOLUTION (32.8f*RAD_P_DEG) #define GYRO_MPU3050_POWER (6.1f) +/******************************************/ +//NINEAXIS +#define NINEAXIS_POWER (COMPASS_YAS530_POWER + \ + ACCEL_BMA250_POWER + \ + GYRO_MPU3050_POWER) + +#define NINEAXIS_ORIENTATION_RANGE (360.0f) +#define NINEAXIS_ORIENTATION_RESOLUTION (0.00001f) +#define NINEAXIS_ORIENTATION_POWER (NINEAXIS_POWER) + +#define NINEAXIS_ROTATION_VECTOR_RANGE (1.0f) +#define NINEAXIS_ROTATION_VECTOR_RESOLUTION (0.00001f) +#define NINEAXIS_ROTATION_VECTOR_POWER (NINEAXIS_POWER) + +#define NINEAXIS_GRAVITY_RANGE (9.81f) +#define NINEAXIS_GRAVITY_RESOLUTION (0.00001f) +#define NINEAXIS_GRAVITY_POWER (NINEAXIS_POWER) + +#define NINEAXIS_LINEAR_ACCEL_RANGE (ACCEL_BMA250_RANGE) +#define NINEAXIS_LINEAR_ACCEL_RESOLUTION (ACCEL_BMA250_RESOLUTION) +#define NINEAXIS_LINEAR_ACCEL_POWER (NINEAXIS_POWER) #endif |