@@ -466,9 +466,12 @@ void GaleaV4::read_thread ()
466466 // aux, 5 times smaller sampling rate
467467 if (((int )b[0 + offset]) % 5 == 0 )
468468 {
469- double accel_scale = (double )(0.002 / (pow (2 , 4 )));
470- double gyro_scale = (double )(0.002 / (pow (2 , 4 ))); // to be confirmed
471- double magnetometer_scale = (double )(0.002 / (pow (2 , 4 ))); // to be confirmed
469+ double accel_scale = (double )(8.0 / static_cast <double > (pow (2 , 16 ) - 1 ));
470+ double gyro_scale = (double )(1000.0 / static_cast <double > (pow (2 , 16 ) - 1 ));
471+ double magnetometer_scale_xy =
472+ (double )(2.6 / static_cast <double > (pow (2 , 13 ) - 1 ));
473+ double magnetometer_scale_z =
474+ (double )(5.0 / static_cast <double > (pow (2 , 15 ) - 1 ));
472475 aux_package[board_descr[" auxiliary" ][" package_num_channel" ].get <int > ()] =
473476 (double )b[0 + offset];
474477 uint16_t temperature = 0 ;
@@ -501,25 +504,28 @@ void GaleaV4::read_thread ()
501504 timestamp_device;
502505 // accel
503506 aux_package[board_descr[" auxiliary" ][" accel_channels" ][0 ].get <int > ()] =
504- accel_scale * cast_16bit_to_int32 (b + 96 + offset);
507+ accel_scale * ( double ) cast_16bit_to_int32_swap_order (b + 96 + offset);
505508 aux_package[board_descr[" auxiliary" ][" accel_channels" ][1 ].get <int > ()] =
506- accel_scale * cast_16bit_to_int32 (b + 98 + offset);
509+ accel_scale * ( double ) cast_16bit_to_int32_swap_order (b + 98 + offset);
507510 aux_package[board_descr[" auxiliary" ][" accel_channels" ][2 ].get <int > ()] =
508- accel_scale * cast_16bit_to_int32 (b + 100 + offset);
511+ accel_scale * ( double ) cast_16bit_to_int32_swap_order (b + 100 + offset);
509512 // gyro
510513 aux_package[board_descr[" auxiliary" ][" gyro_channels" ][0 ].get <int > ()] =
511- gyro_scale * cast_16bit_to_int32 (b + 102 + offset);
514+ gyro_scale * ( double ) cast_16bit_to_int32_swap_order (b + 102 + offset);
512515 aux_package[board_descr[" auxiliary" ][" gyro_channels" ][1 ].get <int > ()] =
513- gyro_scale * cast_16bit_to_int32 (b + 104 + offset);
516+ gyro_scale * ( double ) cast_16bit_to_int32_swap_order (b + 104 + offset);
514517 aux_package[board_descr[" auxiliary" ][" gyro_channels" ][2 ].get <int > ()] =
515- gyro_scale * cast_16bit_to_int32 (b + 106 + offset);
518+ gyro_scale * ( double ) cast_16bit_to_int32_swap_order (b + 106 + offset);
516519 // magnetometer
517520 aux_package[board_descr[" auxiliary" ][" magnetometer_channels" ][0 ].get <int > ()] =
518- magnetometer_scale * cast_16bit_to_int32 (b + 108 + offset);
521+ magnetometer_scale_xy *
522+ (double )cast_13bit_to_int32_swap_order (b + 108 + offset);
519523 aux_package[board_descr[" auxiliary" ][" magnetometer_channels" ][1 ].get <int > ()] =
520- magnetometer_scale * cast_16bit_to_int32 (b + 110 + offset);
524+ magnetometer_scale_xy *
525+ (double )cast_13bit_to_int32_swap_order (b + 110 + offset);
521526 aux_package[board_descr[" auxiliary" ][" magnetometer_channels" ][2 ].get <int > ()] =
522- magnetometer_scale * cast_16bit_to_int32 (b + 112 + offset);
527+ magnetometer_scale_z *
528+ (double )cast_15bit_to_int32_swap_order (b + 112 + offset);
523529
524530 push_package (aux_package, (int )BrainFlowPresets::AUXILIARY_PRESET);
525531 }
0 commit comments