@@ -37,8 +37,8 @@ bool drvLsm9ds1::begin() {
3737 }
3838
3939 // Mirror the configuration used by the reference example
40- _lsm->setupAccel (_lsm->LSM9DS1_ACCELRANGE_2G ,
41- _lsm->LSM9DS1_ACCELDATARATE_10HZ );
40+ _lsm->setupAccel (_lsm->LSM9DS1_ACCELRANGE_4G ,
41+ _lsm->LSM9DS1_ACCELDATARATE_119HZ );
4242 _lsm->setupMag (_lsm->LSM9DS1_MAGGAIN_4GAUSS );
4343 _lsm->setupGyro (_lsm->LSM9DS1_GYROSCALE_245DPS );
4444
@@ -50,6 +50,7 @@ bool drvLsm9ds1::readAllEvents(sensors_event_t *accel, sensors_event_t *mag,
5050 if (!_lsm) {
5151 return false ;
5252 }
53+
5354 return _lsm->getEvent (accel, mag, gyro, temp);
5455}
5556
@@ -81,47 +82,35 @@ bool drvLsm9ds1::getEventRaw(sensors_event_t *rawEvent) {
8182
8283/* *****************************************************************************/
8384/* !
84- @brief Gets the LSM9DS1's boolean sensor event.
85- @param booleanEvent
86- Pointer to the sensor event.
85+ @brief Gets the LSM9DS1's accelerometer sensor event (x,y,z in m/s^2) .
86+ @param accelEvent
87+ Pointer to the accelerometer sensor event.
8788 @returns True if the sensor event was obtained successfully, False
8889 otherwise.
8990*/
9091/* *****************************************************************************/
91- bool drvLsm9ds1::getEventBoolean (sensors_event_t *booleanEvent ) {
92- WS_DEBUG_PRINTLN (" [drvLsm9ds1] Checking for tap event..." );
93- sensors_event_t accel, mag, gyro, temp;
94- if (!readAllEvents (&accel , &mag, &gyro, &temp)) {
92+ bool drvLsm9ds1::getEventAccelerometer (sensors_event_t *accelEvent ) {
93+ WS_DEBUG_PRINTLN (" [drvLsm9ds1] Getting accelerometer event..." );
94+ sensors_event_t mag, gyro, temp;
95+ if (!readAllEvents (accelEvent , &mag, &gyro, &temp)) {
9596 return false ;
9697 }
97-
98- float mag_accel = sqrtf (accel.acceleration .x * accel.acceleration .x +
99- accel.acceleration .y * accel.acceleration .y +
100- accel.acceleration .z * accel.acceleration .z );
101-
102- bool tap_detected = (mag_accel > LSM9DS1_TAP_THRESHOLD_MSS);
103- booleanEvent->data [0 ] = tap_detected ? 1 .0f : 0 .0f ;
104-
105- if (tap_detected) {
106- WS_DEBUG_PRINTLN (" [drvLsm9ds1] Tap event detected!" );
107- }
108-
10998 return true ;
11099}
111100
112101/* *****************************************************************************/
113102/* !
114- @brief Gets the LSM9DS1's accelerometer sensor event (x,y,z in m/s^2 ).
115- @param accelEvent
116- Pointer to the accelerometer sensor event.
103+ @brief Gets the LSM9DS1's temperature sensor event (not necessarily *C ).
104+ @param tempEvent
105+ Pointer to the temperature sensor event.
117106 @returns True if the sensor event was obtained successfully, False
118107 otherwise.
119108*/
120109/* *****************************************************************************/
121- bool drvLsm9ds1::getEventAccelerometer (sensors_event_t *accelEvent ) {
122- WS_DEBUG_PRINTLN (" [drvLsm9ds1] Getting accelerometer event..." );
123- sensors_event_t mag, gyro, temp ;
124- if (!readAllEvents (accelEvent , &mag, &gyro, &temp )) {
110+ bool drvLsm9ds1::getEventAmbientTemp (sensors_event_t *tempEvent ) {
111+ WS_DEBUG_PRINTLN (" [drvLsm9ds1] Getting temperature event..." );
112+ sensors_event_t accel, mag, gyro ;
113+ if (!readAllEvents (&accel , &mag, &gyro, tempEvent )) {
125114 return false ;
126115 }
127116 return true ;
@@ -164,7 +153,13 @@ bool drvLsm9ds1::getEventMagneticField(sensors_event_t *magEvent) {
164153}
165154
166155void drvLsm9ds1::ConfigureDefaultSensorTypes () {
167- _default_sensor_types_count = 1 ;
156+ _default_sensor_types_count = 4 ;
168157 _default_sensor_types[0 ] =
169158 wippersnapper_sensor_SensorType_SENSOR_TYPE_ACCELEROMETER;
159+ _default_sensor_types[1 ] =
160+ wippersnapper_sensor_SensorType_SENSOR_TYPE_MAGNETIC_FIELD;
161+ _default_sensor_types[2 ] =
162+ wippersnapper_sensor_SensorType_SENSOR_TYPE_GYROSCOPE;
163+ _default_sensor_types[3 ] =
164+ wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
170165}
0 commit comments