Skip to content

Commit 01763c5

Browse files
committed
add(vectors): implement vector event methods in drvBase.h
1 parent ff93dda commit 01763c5

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

src/components/i2c/drivers/drvBase.h

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,68 @@ class drvBase {
449449
*/
450450
virtual bool getEventMagneticField(sensors_event_t *magneticEvent) { return false; }
451451

452+
/*!
453+
@brief Gets a sensor's gravity vector value.
454+
@param gravityEvent
455+
The gravity vector (x, y, z) in m/s^2.
456+
@returns True if the sensor value was obtained successfully, False
457+
otherwise.
458+
*/
459+
virtual bool getEventGravity(sensors_event_t *gravityEvent) { return false; }
460+
461+
/*!
462+
@brief Gets a sensor's linear acceleration vector value.
463+
@param linearAccelEvent
464+
The linear acceleration vector (x, y, z) in m/s^2.
465+
@returns True if the sensor value was obtained successfully, False
466+
otherwise.
467+
*/
468+
virtual bool getEventLinearAcceleration(sensors_event_t *linearAccelEvent) { return false; }
469+
470+
/*!
471+
@brief Gets a sensor's rotation vector value.
472+
@param rotationEvent
473+
The rotation vector (x, y, z, w) in radians.
474+
@returns True if the sensor value was obtained successfully, False
475+
otherwise.
476+
*/
477+
virtual bool getEventRotationVector(sensors_event_t *rotationEvent) { return false; }
478+
479+
/*!
480+
@brief Gets a sensor's gyroscope value.
481+
@param gyroEvent
482+
The gyroscope vector (x, y, z) in rad/s.
483+
@returns True if the sensor value was obtained successfully, False
484+
otherwise.
485+
*/
486+
virtual bool getEventGyroscope(sensors_event_t *gyroEvent) { return false; }
487+
/*!
488+
@brief Gets a sensor's accelerometer value.
489+
@param accelEvent
490+
The accelerometer vector (x, y, z) in m/s^2.
491+
@returns True if the sensor value was obtained successfully, False
492+
otherwise.
493+
*/
494+
virtual bool getEventAccelerometer(sensors_event_t *accelEvent) { return false; }
495+
496+
/*!
497+
@brief Gets a sensor's orientation value.
498+
@param orientationEvent
499+
The orientation vector (x, y, z) in degrees.
500+
@returns True if the sensor value was obtained successfully, False
501+
otherwise.
502+
*/
503+
virtual bool getEventOrientation(sensors_event_t *orientationEvent) { return false; }
504+
505+
/*!
506+
@brief Gets a sensor's rotation vector value.
507+
@param rotationEvent
508+
The rotation vector (x, y, z, w) in radians.
509+
@returns True if the sensor value was obtained successfully, False
510+
otherwise.
511+
*/
512+
virtual bool getEventRotationVector(sensors_event_t *rotationEvent) { return false; }
513+
452514
/*!
453515
@brief Gets a sensor's Raw value.
454516
@param rawEvent
@@ -678,7 +740,32 @@ class drvBase {
678740
{wippersnapper_sensor_SensorType_SENSOR_TYPE_MAGNETIC_FIELD,
679741
[this](sensors_event_t *event) -> bool {
680742
return this->getEventMagneticField(event);
681-
}}}; ///< SensorType to function call map
743+
}},
744+
{wippersnapper_sensor_SensorType_SENSOR_TYPE_ACCELEROMETER,
745+
[this](sensors_event_t *event) -> bool {
746+
return this->getEventAccelerometer(event);
747+
}},
748+
{wippersnapper_sensor_SensorType_SENSOR_TYPE_GYROSCOPE,
749+
[this](sensors_event_t *event) -> bool {
750+
return this->getEventGyroscope(event);
751+
}},
752+
{wippersnapper_sensor_SensorType_SENSOR_TYPE_ORIENTATION,
753+
[this](sensors_event_t *event) -> bool {
754+
return this->getEventOrientation(event);
755+
}},
756+
{wippersnapper_sensor_SensorType_SENSOR_TYPE_GRAVITY,
757+
[this](sensors_event_t *event) -> bool {
758+
return this->getEventGravity(event);
759+
}},
760+
{wippersnapper_sensor_SensorType_SENSOR_TYPE_LINEAR_ACCELERATION,
761+
[this](sensors_event_t *event) -> bool {
762+
return this->getEventLinearAcceleration(event);
763+
}},
764+
{wippersnapper_sensor_SensorType_SENSOR_TYPE_ROTATION_VECTOR,
765+
[this](sensors_event_t *event) -> bool {
766+
return this->getEventRotationVector(event);
767+
}}
768+
}; ///< SensorType to function call map
682769

683770
wippersnapper_sensor_SensorType
684771
_sensors[15]; ///< Sensors attached to the device.

0 commit comments

Comments
 (0)