@@ -388,35 +388,35 @@ LSM6DS3::LSM6DS3( uint8_t busType, uint8_t inputArg ) : LSM6DS3Core( busType, in
388
388
// "myIMU.settings.accelEnabled = 1;" to configure before calling .begin();
389
389
//
390
390
// ****************************************************************************//
391
- status_t LSM6DS3::begin (SensorSettings* pActualSettings )
391
+ status_t LSM6DS3::begin (SensorSettings* pSettingsYouWanted )
392
392
{
393
393
// Check the settings structure values to determine how to setup the device
394
394
uint8_t dataToWrite = 0 ; // Temporary variable
395
395
396
396
// Begin the inherited core. This gets the physical wires connected
397
397
status_t returnError = beginCore ();
398
398
399
- // Copy the values from the user's settings into the output 'pActualSettings '
400
- // that will reflect if any default choices had to be made
401
- if (pActualSettings != NULL ){
402
- pActualSettings ->gyroEnabled = settings.gyroEnabled ;
403
- pActualSettings ->gyroRange = settings.gyroRange ;
404
- pActualSettings ->gyroSampleRate = settings.gyroSampleRate ;
405
- pActualSettings ->gyroBandWidth = settings.gyroBandWidth ;
406
- pActualSettings ->gyroFifoEnabled = settings.gyroFifoEnabled ;
407
- pActualSettings ->gyroFifoDecimation = settings.gyroFifoDecimation ;
408
- pActualSettings ->accelEnabled = settings.accelEnabled ;
409
- pActualSettings ->accelODROff = settings.accelODROff ;
410
- pActualSettings ->accelRange = settings.accelRange ;
411
- pActualSettings ->accelSampleRate = settings.accelSampleRate ;
412
- pActualSettings ->accelBandWidth = settings.accelBandWidth ;
413
- pActualSettings ->accelFifoEnabled = settings.accelFifoEnabled ;
414
- pActualSettings ->accelFifoDecimation = settings.accelFifoDecimation ;
415
- pActualSettings ->tempEnabled = settings.tempEnabled ;
416
- pActualSettings ->commMode = settings.commMode ;
417
- pActualSettings ->fifoThreshold = settings.fifoThreshold ;
418
- pActualSettings ->fifoSampleRate = settings.fifoSampleRate ;
419
- pActualSettings ->fifoModeWord = settings.fifoModeWord ;
399
+ // Copy the values from the user's settings into the output 'pSettingsYouWanted '
400
+ // compare settings with 'pSettingsYouWanted' after 'begin' to see if anything changed
401
+ if (pSettingsYouWanted != NULL ){
402
+ pSettingsYouWanted ->gyroEnabled = settings.gyroEnabled ;
403
+ pSettingsYouWanted ->gyroRange = settings.gyroRange ;
404
+ pSettingsYouWanted ->gyroSampleRate = settings.gyroSampleRate ;
405
+ pSettingsYouWanted ->gyroBandWidth = settings.gyroBandWidth ;
406
+ pSettingsYouWanted ->gyroFifoEnabled = settings.gyroFifoEnabled ;
407
+ pSettingsYouWanted ->gyroFifoDecimation = settings.gyroFifoDecimation ;
408
+ pSettingsYouWanted ->accelEnabled = settings.accelEnabled ;
409
+ pSettingsYouWanted ->accelODROff = settings.accelODROff ;
410
+ pSettingsYouWanted ->accelRange = settings.accelRange ;
411
+ pSettingsYouWanted ->accelSampleRate = settings.accelSampleRate ;
412
+ pSettingsYouWanted ->accelBandWidth = settings.accelBandWidth ;
413
+ pSettingsYouWanted ->accelFifoEnabled = settings.accelFifoEnabled ;
414
+ pSettingsYouWanted ->accelFifoDecimation = settings.accelFifoDecimation ;
415
+ pSettingsYouWanted ->tempEnabled = settings.tempEnabled ;
416
+ pSettingsYouWanted ->commMode = settings.commMode ;
417
+ pSettingsYouWanted ->fifoThreshold = settings.fifoThreshold ;
418
+ pSettingsYouWanted ->fifoSampleRate = settings.fifoSampleRate ;
419
+ pSettingsYouWanted ->fifoModeWord = settings.fifoModeWord ;
420
420
}
421
421
422
422
// Setup the accelerometer******************************
@@ -435,7 +435,7 @@ status_t LSM6DS3::begin(SensorSettings* pActualSettings)
435
435
dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_200Hz;
436
436
break ;
437
437
default : // set default case to max passthrough
438
- if (pActualSettings != NULL ){ pActualSettings-> accelBandWidth = 400 ; }
438
+ settings. accelEnabled = 400 ;
439
439
case 400 :
440
440
dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_400Hz;
441
441
break ;
@@ -452,7 +452,7 @@ status_t LSM6DS3::begin(SensorSettings* pActualSettings)
452
452
dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_8g;
453
453
break ;
454
454
default : // set default case to 16(max)
455
- if (pActualSettings != NULL ){ pActualSettings-> accelRange = 16 ; }
455
+ settings. accelRange = 16 ;
456
456
case 16 :
457
457
dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_16g;
458
458
break ;
@@ -469,7 +469,7 @@ status_t LSM6DS3::begin(SensorSettings* pActualSettings)
469
469
dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_52Hz;
470
470
break ;
471
471
default : // Set default to 104
472
- if (pActualSettings != NULL ){ pActualSettings-> accelSampleRate = 104 ; }
472
+ settings. accelSampleRate = 104 ;
473
473
case 104 :
474
474
dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_104Hz;
475
475
break ;
@@ -531,7 +531,7 @@ status_t LSM6DS3::begin(SensorSettings* pActualSettings)
531
531
dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_1000dps;
532
532
break ;
533
533
default : // Default to full 2000DPS range
534
- if (pActualSettings != NULL ){ pActualSettings-> gyroRange = 2000 ; }
534
+ settings. gyroRange = 2000 ;
535
535
case 2000 :
536
536
dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_2000dps;
537
537
break ;
@@ -548,7 +548,7 @@ status_t LSM6DS3::begin(SensorSettings* pActualSettings)
548
548
dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_52Hz;
549
549
break ;
550
550
default : // Set default to 104
551
- if (pActualSettings != NULL ){ pActualSettings-> gyroSampleRate = gyroSampleRate; }
551
+ settings. gyroSampleRate = 104 ;
552
552
case 104 :
553
553
dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_104Hz;
554
554
break ;
0 commit comments