#define GEOMAGNETIC_RV_ENABLED 5
#define ORIENTATION_ENABLED 7
#define ROTATION_VECTOR_ENABLED 7
+#define UNCAL_GYRO_ENABLED 7
#define INITIAL_VALUE -1
if (sensor_base::is_supported(FUSION_ORIENTATION_ENABLED) ||
sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED) ||
- sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED)) {
+ sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED) ||
+ sensor_base::is_supported(FUSION_UNCAL_GYRO_ENABLED)) {
if (event.event_type == GEOMAGNETIC_RAW_DATA_EVENT) {
diff_time = event.data.timestamp - m_time;
if (sensor_base::is_supported(FUSION_ORIENTATION_ENABLED) ||
sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED) ||
- sensor_base::is_supported(FUSION_GAMING_ROTATION_VECTOR_ENABLED)) {
+ sensor_base::is_supported(FUSION_GAMING_ROTATION_VECTOR_ENABLED) ||
+ sensor_base::is_supported(FUSION_UNCAL_GYRO_ENABLED)) {
if (event.event_type == GYROSCOPE_RAW_DATA_EVENT) {
diff_time = event.data.timestamp - m_time;
(m_enable_fusion == ORIENTATION_ENABLED && sensor_base::is_supported(FUSION_ORIENTATION_ENABLED)) ||
(m_enable_fusion == ROTATION_VECTOR_ENABLED && sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED)) ||
(m_enable_fusion == GAMING_RV_ENABLED && sensor_base::is_supported(FUSION_GAMING_ROTATION_VECTOR_ENABLED)) ||
- (m_enable_fusion == GEOMAGNETIC_RV_ENABLED && sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED))) {
+ (m_enable_fusion == GEOMAGNETIC_RV_ENABLED && sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED)) ||
+ (m_enable_fusion == UNCAL_GYRO_ENABLED && sensor_base::is_supported(FUSION_UNCAL_GYRO_ENABLED))) {
sensor_event_t fusion_event;
- m_enable_fusion = 0;
m_orientation_filter.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
m_orientation_filter.get_device_orientation(m_accel_ptr, m_gyro_ptr, m_magnetic_ptr);
- m_time = get_timestamp();
- fusion_event.sensor_id = get_id();
- fusion_event.event_type = FUSION_EVENT;
- fusion_event.data.accuracy = SENSOR_ACCURACY_GOOD;
- fusion_event.data.timestamp = m_time;
- fusion_event.data.value_count = 4;
- fusion_event.data.values[0] = m_orientation_filter.m_quaternion.m_quat.m_vec[0];
- fusion_event.data.values[1] = m_orientation_filter.m_quaternion.m_quat.m_vec[1];
- fusion_event.data.values[2] = m_orientation_filter.m_quaternion.m_quat.m_vec[2];
- fusion_event.data.values[3] = m_orientation_filter.m_quaternion.m_quat.m_vec[3];
- m_accel_ptr = m_gyro_ptr = m_magnetic_ptr = NULL;
- push(fusion_event);
+ if (m_enable_fusion == UNCAL_GYRO_ENABLED && sensor_base::is_supported(FUSION_UNCAL_GYRO_ENABLED)) {
+ m_time = get_timestamp();
+ fusion_event.sensor_id = get_id();
+ fusion_event.data.timestamp = m_time;
+ fusion_event.data.accuracy = SENSOR_ACCURACY_GOOD;
+ fusion_event.event_type = FUSION_UNCAL_GYRO_EVENT;
+ fusion_event.data.value_count = 3;
+ fusion_event.data.values[0] = m_orientation_filter.m_gyro_bias.m_vec[0];
+ fusion_event.data.values[1] = m_orientation_filter.m_gyro_bias.m_vec[1];
+ fusion_event.data.values[2] = m_orientation_filter.m_gyro_bias.m_vec[2];
+
+ push(fusion_event);
+ }
+
+ if ((m_enable_fusion == TILT_ENABLED && sensor_base::is_supported(FUSION_TILT_ENABLED)) ||
+ (m_enable_fusion == ORIENTATION_ENABLED && sensor_base::is_supported(FUSION_ORIENTATION_ENABLED)) ||
+ (m_enable_fusion == ROTATION_VECTOR_ENABLED && sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED)) ||
+ (m_enable_fusion == GAMING_RV_ENABLED && sensor_base::is_supported(FUSION_GAMING_ROTATION_VECTOR_ENABLED)) ||
+ (m_enable_fusion == GEOMAGNETIC_RV_ENABLED && sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED))) {
+ m_time = get_timestamp();
+ fusion_event.sensor_id = get_id();
+ fusion_event.data.timestamp = m_time;
+ fusion_event.data.accuracy = SENSOR_ACCURACY_GOOD;
+ fusion_event.event_type = FUSION_EVENT;
+ fusion_event.data.value_count = 4;
+ fusion_event.data.values[0] = m_orientation_filter.m_quaternion.m_quat.m_vec[0];
+ fusion_event.data.values[1] = m_orientation_filter.m_quaternion.m_quat.m_vec[1];
+ fusion_event.data.values[2] = m_orientation_filter.m_quaternion.m_quat.m_vec[2];
+ fusion_event.data.values[3] = m_orientation_filter.m_quaternion.m_quat.m_vec[3];
+
+ push(fusion_event);
+ }
+
+ m_enable_fusion = 0;
+
+ m_accel_ptr = m_gyro_ptr = m_magnetic_ptr = NULL;
}
return;
if (event_type != FUSION_ORIENTATION_ENABLED ||
event_type != FUSION_ROTATION_VECTOR_ENABLED ||
event_type != FUSION_GAMING_ROTATION_VECTOR_ENABLED ||
- event_type != FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED)
+ event_type != FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED ||
+ event_type != FUSION_UNCAL_GYRO_ENABLED)
return -1;
m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data);
if (event_type == FUSION_ORIENTATION_ENABLED ||
event_type == FUSION_ROTATION_VECTOR_ENABLED ||
- event_type == FUSION_GAMING_ROTATION_VECTOR_ENABLED)
+ event_type == FUSION_GAMING_ROTATION_VECTOR_ENABLED ||
+ event_type == FUSION_UNCAL_GYRO_ENABLED)
{
m_gyro_sensor->get_sensor_data(GYROSCOPE_RAW_DATA_EVENT, gyro_data);
pre_process_data(gyro, gyro_data.values, m_gyro_static_bias, m_gyro_rotation_direction_compensation, m_gyro_scale);
if (event_type == FUSION_ORIENTATION_ENABLED ||
event_type == FUSION_ROTATION_VECTOR_ENABLED ||
- event_type == FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED)
+ event_type == FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED ||
+ event_type == FUSION_UNCAL_GYRO_ENABLED)
{
m_magnetic_sensor->get_sensor_data(GEOMAGNETIC_RAW_DATA_EVENT, magnetic_data);
pre_process_data(magnetic, magnetic_data.values, m_geomagnetic_static_bias, m_geomagnetic_rotation_direction_compensation, m_geomagnetic_scale);
m_orientation_filter_poll.m_magnetic_alignment_factor = m_magnetic_alignment_factor;
- if (event_type == FUSION_ORIENTATION_ENABLED || event_type == FUSION_ROTATION_VECTOR_ENABLED)
+ if (event_type == FUSION_ORIENTATION_ENABLED ||
+ event_type == FUSION_ROTATION_VECTOR_ENABLED ||
+ event_type == FUSION_UNCAL_GYRO_ENABLED)
m_orientation_filter_poll.get_device_orientation(&accel, &gyro, &magnetic);
else if (event_type == FUSION_GAMING_ROTATION_VECTOR_ENABLED)
m_orientation_filter_poll.get_device_orientation(&accel, &gyro, NULL);
else if (event_type == FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED)
m_orientation_filter_poll.get_device_orientation(&accel, NULL, &magnetic);
- data.accuracy = SENSOR_ACCURACY_GOOD;
- data.timestamp = get_timestamp();
- data.value_count = 4;
- data.values[0] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[0];
- data.values[1] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[1];
- data.values[2] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[2];
- data.values[3] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[3];
+ if (event_type == FUSION_UNCAL_GYRO_ENABLED) {
+ data.accuracy = SENSOR_ACCURACY_GOOD;
+ data.timestamp = get_timestamp();
+ data.value_count = 3;
+ data.values[0] = m_orientation_filter_poll.m_gyro_bias.m_vec[0];
+ data.values[1] = m_orientation_filter_poll.m_gyro_bias.m_vec[1];
+ data.values[2] = m_orientation_filter_poll.m_gyro_bias.m_vec[2];
+ }
+ else if (event_type != FUSION_ORIENTATION_ENABLED ||
+ event_type != FUSION_ROTATION_VECTOR_ENABLED ||
+ event_type != FUSION_GAMING_ROTATION_VECTOR_ENABLED ||
+ event_type != FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED) {
+ data.accuracy = SENSOR_ACCURACY_GOOD;
+ data.timestamp = get_timestamp();
+ data.value_count = 4;
+ data.values[0] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[0];
+ data.values[1] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[1];
+ data.values[2] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[2];
+ data.values[3] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[3];
+ }
return 0;
}