SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
SensorBMA423 Class Reference

#include <SensorBMA423.hpp>

Inheritance diagram for SensorBMA423:
[legend]

Classes

struct  EventCallbacks
 Event callbacks for the sensor. More...
 

Public Types

enum class  Platform { SMARTPHONE , WRISTBAND }
 Select the platform for the sensor. More...
 
- Public Types inherited from SensorBMA4XX
enum  BMA4XXModel { BMA422 = 0x12 , BMA423 = 0x13 , BMA456 = 0x16 , BMA456_AN_SEC = 0x1A }
 Enumeration of BMA4XX models. More...
 
using bma4_dev_t = bma4_dev
 typedef for BMA4 device structure
 

Public Member Functions

 SensorBMA423 ()
 Constructor for the SensorBMA423 class.
 
 ~SensorBMA423 ()=default
 Destructor for the SensorBMA423 class.
 
BMA4XXCapability::Capability getCapabilities () const override
 Get supported capabilities.
 
void setOnTapCallback (std::function< void(TapType)> cb)
 Set the callback for tap events.
 
void setOnStepDetectedCallback (std::function< void()> cb)
 Set the callback for step detection events.
 
void setOnStepCountCallback (std::function< void(uint32_t)> cb)
 Set the callback for step count events.
 
void setOnActivityCallback (std::function< void(ActivityType)> cb)
 Set the callback for activity events.
 
void setOnAnyMotionCallback (std::function< void(void)> cb)
 Set the any-motion callback for motion events.
 
void setOnNoMotionCallback (std::function< void(void)> cb)
 Set the callback for no-motion events.
 
void setOnDataReadyCallback (std::function< void(AccelerometerData)> cb)
 Set the callback for data ready events.
 
void setOnTiltDetectedCallback (std::function< void(void)> cb)
 Set the callback for tilt detection events.
 
void setCallbacks (const EventCallbacks &cbs)
 Set all callbacks at once.
 
EventCallbacksgetCallbacks ()
 Get the current callbacks.
 
const EventCallbacksgetCallbacks () const
 Get the current callbacks (const version)
 
bool enableFeature (uint16_t feature, bool enable)
 Enable or disable a specific feature.
 
bool enableDataReady (bool enable=true, InterruptPinMap pin_map=InterruptPinMap::PIN1) override
 Enable data ready interrupt.
 
bool enableStepCounter (bool enable, uint16_t step_counter_wm=1, bool reset_counter=false) override
 Enable or disable step counter.
 
bool getStepCounterWatermark (uint16_t &step_counter_wm) const
 Get the current step counter watermark.
 
bool enableStepDetector (bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1) override
 Enable or disable step detector.
 
bool enableTiltDetector (bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1) override
 Enable or disable tilt detection.
 
bool selectPlatform (Platform platform)
 Select the platform for the sensor.
 
bool enableTapDetector (bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1) override
 Enable or disable tap detection.
 
bool selectTapType (TapType tap)
 Select tap detection tap type.
 
bool enableActivityRecognition (bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1) override
 Enable or disable activity recognition.
 
bool enableAnyMotionDetection (const MotionAxesConfig &cfg, bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1) override
 Enable or disable any-motion detection.
 
bool enableNoMotionDetection (const MotionAxesConfig &cfg, bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1) override
 Enable or disable no-motion detection.
 
bool configNoMotion (uint16_t threshold, uint16_t duration) override
 Configure no-motion detection using raw register values.
 
bool configAnyMotion (uint16_t threshold, uint16_t duration) override
 Configure any-motion detection using raw register values.
 
bool configMotion (bool any_motion, uint16_t threshold, uint16_t duration) override
 Configure motion detection parameters using raw register values.
 
bool getMotionConfig (uint16_t &threshold, uint16_t &duration, bool &no_motion)
 Get current no-motion/any-motion detection configuration for BMA423.
 
uint32_t getStepCount ()
 Get the current step count.
 
bool resetStepCounter ()
 Reset the step counter.
 
ActivityType getActivityType ()
 Get the current activity type.
 
uint8_t getEnabledMotionFeature () const
 Get which motion detection feature is currently enabled.
 
bool isAnyMotionEnabled () const
 Check if any-motion detection is enabled.
 
bool isNoMotionEnabled () const
 Check if no-motion detection is enabled.
 
void update () override
 Update sensor state and process interrupts.
 
- Public Member Functions inherited from SensorBMA4XX
bool readData (AccelerometerData &data) override
 Get the accelerometer data.
 
bool isDataReady () override
 Check if new accelerometer data is available.
 
bool reset () override
 Reset the sensor.
 
bool selfTest () override
 Perform a self-test on the sensor.
 
bool setFullScaleRange (AccelFullScaleRange range) override
 Set the full-scale range of the accelerometer.
 
bool setOutputDataRate (float data_rate_hz) override
 Set the output data rate of the accelerometer.
 
bool setBandwidth (AccelBandwidth bandwidth)
 Set the bandwidth of the accelerometer.
 
bool setPerformanceMode (AccelPerfMode mode)
 Set the performance mode of the accelerometer.
 
bool setOperationMode (OperationMode mode) override
 Set the operation mode of the accelerometer.
 
bool configAccelerometer (OperationMode mode, AccelFullScaleRange range, float data_rate_hz, AccelBandwidth bandwidth, AccelPerfMode perf_mode)
 Configure the accelerometer.
 
float getTemperature () const
 Get the temperature reading from the sensor.
 
uint16_t getInterruptStatus ()
 Get the current interrupt status flags.
 
bool isInterruptActive (uint16_t interrupt_mask)
 Check if a specific interrupt is active.
 
bool setInterruptPinConfig (InterruptPinMap pin_map, bool edge_trigger=false, bool active_low=true, bool output_en=true, bool input_en=false)
 Configure the electrical properties of an interrupt pin.
 
bool enableInterrupt (InterruptPinMap pin_map, uint16_t interrupt_sources, bool enable)
 Enable or disable specific interrupt sources on a pin.
 
virtual bool setRemapAxes (SensorRemap remap)
 Set the remapping of axes for the BMA4XX sensor.
 
const char * getModelName () const
 Get the model name of the BMA4XX sensor.
 
bma4_dev_tgetDev ()
 Get the device structure for the BMA4XX sensor.
 
uint32_t getTimeSampleMs () const
 Get the current sensor time in milliseconds.
 
virtual bool configAnyMotionInPhysicalUnits (float threshold_mg, float duration_ms)
 Configure any-motion using physical units (default: not supported)
 
virtual bool configNoMotionInPhysicalUnits (float threshold_mg, float duration_ms)
 Configure no-motion using physical units (default: not supported)
 
- Public Member Functions inherited from AccelerometerBase
virtual float getFullScaleRange () const
 Get current full-scale range setting.
 
virtual float getOutputDataRate () const
 Get current output data rate setting.
 
virtual OperationMode getOperationMode () const
 Get current operation mode setting.
 
- Public Member Functions inherited from SensorBase< AccelerometerData >
 SensorBase (const SensorBase &)=delete
 
SensorBaseoperator= (const SensorBase &)=delete
 
void setOffset (int16_t x, int16_t y, int16_t z)
 Set sensor calibration offsets.
 
float getSensitivity () const
 Get sensor sensitivity.
 
SensorInfo getSensorInfo () const
 Get sensor information.
 
virtual SensorConfig getConfig () const
 Get current sensor configuration.
 
- Public Member Functions inherited from ComplexStaticDeviceWithHal
bool begin (CommInterface interface, SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr=0)
 Initialize the sensor using custom callback interface.
 
- Public Member Functions inherited from DeviceBeginCommon
virtual ~DeviceBeginCommon ()
 
uint8_t getAddress () const
 
uint8_t getInterface () const
 
- Public Member Functions inherited from SensorCommWrapper
 SensorCommWrapper ()=default
 
int readReg (uint8_t reg) const
 
int readRegBuff (uint8_t reg, uint8_t *buf, size_t len) const
 
int readBuff (uint8_t *buf, size_t len) const
 
int writeReg (uint8_t reg, uint8_t val)
 
int writeRegBuff (uint8_t reg, uint8_t *buf, size_t len)
 
int writeBuff (uint8_t *buf, size_t len)
 
int writeThenRead (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len)
 
bool setRegBit (uint8_t reg, uint8_t bit)
 
bool clrRegBit (uint8_t reg, uint8_t bit)
 
bool getRegBit (uint8_t reg, uint8_t bit)
 
int updateBits (uint8_t reg, uint8_t mask, uint8_t value_shifted)
 
void setAddress (uint8_t address)
 
void setAck (bool enable)
 
- Public Member Functions inherited from SensorCommInterface
virtual ~SensorCommInterface ()=default
 

Protected Attributes

EventCallbacks callbacks
 
uint16_t _status
 
MotionCfg _mon_cfg
 
BMA423_TapType _tapType
 
- Protected Attributes inherited from SensorBMA4XX
std::unique_ptr< struct bma4_dev > dev
 
struct bma4_accel_config _accel_conf
 
uint8_t _remap_reg_offset
 
float _half_scale
 
- Protected Attributes inherited from SensorBase< AccelerometerData >
SensorConfig _config
 Current configuration.
 
SensorInfo _info
 Sensor information.
 
int16_t _x_offset
 
int16_t _y_offset
 
int16_t _z_offset
 
float _sensitivity
 
- Protected Attributes inherited from DeviceBeginCommon
std::unique_ptr< SensorCommBasecomm
 
std::unique_ptr< SensorHalhal
 
std::unique_ptr< SensorCommStaticstaticComm
 
uint8_t _addr = 0
 
uint8_t _iface = COMM_CUSTOM
 

Additional Inherited Members

- Protected Member Functions inherited from SensorBMA4XX
 SensorBMA4XX ()
 Constructor for the SensorBMA4XX class.
 
 ~SensorBMA4XX ()=default
 Destructor for the SensorBMA4XX class.
 
- Protected Member Functions inherited from AccelerometerBase
 AccelerometerBase ()
 Construct a new AccelerometerBase object.
 
virtual ~AccelerometerBase ()=default
 Destroy the AccelerometerBase object.
 
 AccelerometerBase (const AccelerometerBase &)=delete
 
AccelerometerBaseoperator= (const AccelerometerBase &)=delete
 
- Protected Member Functions inherited from SensorBase< AccelerometerData >
 SensorBase (SensorType sensor_type=SensorType::UNKNOWN)
 Construct a new SensorBase object.
 
virtual ~SensorBase ()=default
 Virtual destructor for proper polymorphic cleanup.
 
- Protected Member Functions inherited from ComplexStaticDeviceWithHal
bool ensureValid () const override
 Ensure the communication interface is valid.
 
- Protected Member Functions inherited from DeviceBeginCommon
 DeviceBeginCommon ()=default
 
virtual SensorCommBasegetComm () const override
 
virtual void beforeBegin ()
 
virtual void afterCommReady ()
 
virtual void afterInitSuccess (uint8_t param)
 
virtual void onBeginFail ()
 
bool fail ()
 
void clearCommState ()
 
template<typename CreateComm >
bool beginLifecycle (uint8_t addr, uint8_t iface, uint8_t initParam, CreateComm createComm)
 

Detailed Description

Definition at line 94 of file sensor/accelerometer/bma/SensorBMA423.hpp.

Member Enumeration Documentation

◆ Platform

enum class SensorBMA423::Platform
strong

Select the platform for the sensor.

Note
This setting affects tilt detection.
Enumerator
SMARTPHONE 
WRISTBAND 

Definition at line 118 of file sensor/accelerometer/bma/SensorBMA423.hpp.

Constructor & Destructor Documentation

◆ SensorBMA423()

SensorBMA423::SensorBMA423 ( )
inline

Constructor for the SensorBMA423 class.

Note
Initializes the sensor with default settings and sets the remap offset for BMA423 specific features.

Definition at line 145 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg, SensorBMA4XX::_remap_reg_offset, and _tapType.

◆ ~SensorBMA423()

SensorBMA423::~SensorBMA423 ( )
default

Destructor for the SensorBMA423 class.

Note
Cleans up the sensor resources (default implementation).

Member Function Documentation

◆ configAnyMotion()

bool SensorBMA423::configAnyMotion ( uint16_t  threshold,
uint16_t  duration 
)
inlineoverridevirtual

Configure any-motion detection using raw register values.

Sets the threshold and duration for any-motion detection. Threshold: 5.11g format (16-bit) Duration: 50Hz samples (20ms per sample)

Parameters
thresholdSlope threshold in 5.11g format (0-2047 = 0-~1g) Default: 0x00AA = 170 / 2048 ≈ 0.083g = 83mg
durationNumber of consecutive 50Hz samples (20ms each) required Range: 0-8191 (0-163.82 seconds) Default: 0x0005 = 5 samples = 100ms
Returns
This method is compatible with other classes and will always return true.

Reimplemented from SensorBMA4XX.

Definition at line 616 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg.

Referenced by setup().

◆ configMotion()

bool SensorBMA423::configMotion ( bool  any_motion,
uint16_t  threshold,
uint16_t  duration 
)
inlineoverridevirtual

Configure motion detection parameters using raw register values.

This function sets the threshold and duration directly using register values. For physical units, use configMotion() instead.

Parameters
any_motiontrue for any-motion detection, false for no-motion detection
thresholdSlope threshold in 5.11g format (0-2047 = 0-~1g) Default: 0x00AA = 170 / 2048 ≈ 0.083g = 83mg
durationNumber of consecutive 50Hz samples (20ms each) required Range: 0-8191 (0-163.82 seconds) Default: 0x0005 = 5 samples = 100ms
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 637 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg, SensorBMA4XX::dev, and SENSORLIB_LOG_D.

Referenced by enableAnyMotionDetection(), and enableNoMotionDetection().

◆ configNoMotion()

bool SensorBMA423::configNoMotion ( uint16_t  threshold,
uint16_t  duration 
)
inlineoverridevirtual

Configure no-motion detection using raw register values.

Sets the threshold and duration for no-motion detection. Threshold: 5.11g format (16-bit) Duration: 50Hz samples (20ms per sample)

Parameters
thresholdSlope threshold in 5.11g format (0-2047 = 0-~1g) Default: 0x00AA = 170 / 2048 ≈ 0.083g = 83mg
durationNumber of consecutive 50Hz samples (20ms each) required Range: 0-8191 (0-163.82 seconds) Default: 0x0005 = 5 samples = 100ms
Returns
This method is compatible with other classes and will always return true.

Reimplemented from SensorBMA4XX.

Definition at line 595 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg.

Referenced by setup().

◆ enableActivityRecognition()

bool SensorBMA423::enableActivityRecognition ( bool  enable,
bool  interrupt_enable = false,
InterruptPinMap  pin_map = InterruptPinMap::PIN1 
)
inlineoverridevirtual

Enable or disable activity recognition.

Note
Activity recognition can detect stationary, walking, running, etc.
Parameters
enabletrue to enable, false to disable
interrupt_enableEnable/disable interrupt generation
pin_mapInterrupt pin to use (PIN1 or PIN2)
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 490 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References enableFeature(), and SensorBMA4XX::enableInterrupt().

Referenced by setup().

◆ enableAnyMotionDetection()

bool SensorBMA423::enableAnyMotionDetection ( const MotionAxesConfig cfg,
bool  enable,
bool  interrupt_enable = false,
InterruptPinMap  pin_map = InterruptPinMap::PIN1 
)
inlineoverridevirtual

Enable or disable any-motion detection.

Note
Configures motion any-motion detection on selected axes
Warning
Any-Motion and No-Motion is mutually exclusive
Parameters
&cfgConfiguration for which axes to monitor
enabletrue to enable, false to disable
interrupt_enableEnable/disable interrupt generation
pin_mapInterrupt pin to use (PIN1 or PIN2)
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 509 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg, configMotion(), SensorBMA4XX::dev, enableFeature(), SensorBMA4XX::enableInterrupt(), SENSORLIB_LOG_E, SensorBMA4XX::MotionAxesConfig::x_axis, SensorBMA4XX::MotionAxesConfig::y_axis, and SensorBMA4XX::MotionAxesConfig::z_axis.

Referenced by setup().

◆ enableDataReady()

bool SensorBMA423::enableDataReady ( bool  enable = true,
InterruptPinMap  pin_map = InterruptPinMap::PIN1 
)
inlineoverridevirtual

Enable data ready interrupt.

Note
Configures the interrupt for accelerometer data ready events
Parameters
enableEnable/disable the data ready feature
pin_mapInterrupt pin to use (PIN1 or PIN2)
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 349 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::enableInterrupt().

Referenced by setup().

◆ enableFeature()

bool SensorBMA423::enableFeature ( uint16_t  feature,
bool  enable 
)
inline

Enable or disable a specific feature.

Note
Enables/disables sensor features using bitmask. For step counter, also enables the step detector if needed.
Warning
Ensure that only one of any-motion or no-motion is enabled at a time.
Parameters
featureBitmask of features to enable/disable (BMA423_*_EN constants)
enabletrue to enable, false to disable
Returns
true if successful, false on error

Definition at line 293 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg, SensorBMA4XX::dev, SENSORLIB_LOG_D, and SENSORLIB_LOG_E.

Referenced by enableActivityRecognition(), enableAnyMotionDetection(), enableNoMotionDetection(), enableStepCounter(), enableStepDetector(), enableTapDetector(), and enableTiltDetector().

◆ enableNoMotionDetection()

bool SensorBMA423::enableNoMotionDetection ( const MotionAxesConfig cfg,
bool  enable,
bool  interrupt_enable = false,
InterruptPinMap  pin_map = InterruptPinMap::PIN1 
)
inlineoverridevirtual

Enable or disable no-motion detection.

Note
Configures motion no-motion detection on selected axes
Warning
Any-Motion and No-Motion is mutually exclusive
Parameters
&cfgConfiguration for which axes to monitor
enabletrue to enable, false to disable
interrupt_enableEnable/disable interrupt generation
pin_mapInterrupt pin to use (PIN1 or PIN2)
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 550 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg, configMotion(), SensorBMA4XX::dev, enableFeature(), SensorBMA4XX::enableInterrupt(), SENSORLIB_LOG_E, SensorBMA4XX::MotionAxesConfig::x_axis, SensorBMA4XX::MotionAxesConfig::y_axis, and SensorBMA4XX::MotionAxesConfig::z_axis.

Referenced by setup().

◆ enableStepCounter()

bool SensorBMA423::enableStepCounter ( bool  enable,
uint16_t  step_counter_wm = 1,
bool  reset_counter = false 
)
inlineoverridevirtual

Enable or disable step counter.

Note
Step counter counts total steps since last reset. Step detector must be enabled separately for step-by-step detection.
Parameters
enabletrue to enable, false to disable
step_counter_wmWatermark level for step counter interrupt (default: 1) Setting watermark level 1, the output step resolution is 20 steps. Eg: 1 means, 1 * 20 = 20. Every 20 steps once output triggers
reset_countertrue to reset counter to zero
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 365 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::dev, enableFeature(), and SENSORLIB_LOG_E.

Referenced by setup().

◆ enableStepDetector()

bool SensorBMA423::enableStepDetector ( bool  enable,
bool  interrupt_enable = false,
InterruptPinMap  pin_map = InterruptPinMap::PIN1 
)
inlineoverridevirtual

Enable or disable step detector.

Note
Step detector generates interrupt for each step detected. Use for real-time step detection rather than total count.
Parameters
enabletrue to enable, false to disable
interrupt_enableEnable/disable interrupt generation
pin_mapInterrupt pin to use (PIN1 or PIN2)
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 402 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References enableFeature(), and SensorBMA4XX::enableInterrupt().

Referenced by setup().

◆ enableTapDetector()

bool SensorBMA423::enableTapDetector ( bool  enable,
bool  interrupt_enable = false,
InterruptPinMap  pin_map = InterruptPinMap::PIN1 
)
inlineoverridevirtual

Enable or disable tap detection.

Note
Enables double tap detection simultaneously.
Parameters
enabletrue to enable, false to disable
interrupt_enableEnable/disable interrupt generation
pin_mapInterrupt pin to use (PIN1 or PIN2)
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 450 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References enableFeature(), and SensorBMA4XX::enableInterrupt().

Referenced by setup().

◆ enableTiltDetector()

bool SensorBMA423::enableTiltDetector ( bool  enable,
bool  interrupt_enable = false,
InterruptPinMap  pin_map = InterruptPinMap::PIN1 
)
inlineoverridevirtual

Enable or disable tilt detection.

Note
Enables double tap detection simultaneously.
Parameters
enabletrue to enable, false to disable
interrupt_enableEnable/disable interrupt generation
pin_mapInterrupt pin to use (PIN1 or PIN2)
Returns
true if successful, false on error

Reimplemented from SensorBMA4XX.

Definition at line 419 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References enableFeature(), and SensorBMA4XX::enableInterrupt().

Referenced by setup().

◆ getActivityType()

ActivityType SensorBMA423::getActivityType ( )
inline

Get the current activity type.

Note
Reads the current activity classification from the sensor. Activity recognition must be enabled first.
Returns
ActivityType enum value, or UNKNOWN on error

Definition at line 717 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::dev, SENSORLIB_LOG_E, and UNKNOWN.

Referenced by update().

◆ getCallbacks() [1/2]

EventCallbacks & SensorBMA423::getCallbacks ( )
inline

Get the current callbacks.

Returns
Reference to the EventCallbacks structure
Note
Use this to modify callbacks directly or check current settings

Definition at line 270 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks.

◆ getCallbacks() [2/2]

const EventCallbacks & SensorBMA423::getCallbacks ( ) const
inline

Get the current callbacks (const version)

Returns
Const reference to the EventCallbacks structure

Definition at line 279 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks.

◆ getCapabilities()

◆ getEnabledMotionFeature()

uint8_t SensorBMA423::getEnabledMotionFeature ( ) const
inline

Get which motion detection feature is currently enabled.

Returns
0 = none, BMA423_ANY_MOTION = any-motion, BMA423_NO_MOTION = no-motion

Definition at line 731 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg.

◆ getMotionConfig()

bool SensorBMA423::getMotionConfig ( uint16_t &  threshold,
uint16_t &  duration,
bool &  no_motion 
)
inline

Get current no-motion/any-motion detection configuration for BMA423.

Note
Returns parameters in user-friendly units
Parameters
[out]thresholdSlope threshold in 5.11g format (0-2047 = 0-~1g) Default: 0x00AA = 170 / 2048 ≈ 0.083g = 83mg
[out]durationNumber of consecutive 50Hz samples (20ms each) required Range: 0-8191 (0-163.82 seconds) Default: 0x0005 = 5 samples = 100ms
[out]no_motiontrue is no-motion,false is any-motion
Returns
true if successful, false on error

Definition at line 671 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::dev, and SENSORLIB_LOG_E.

◆ getStepCount()

uint32_t SensorBMA423::getStepCount ( )
inline

Get the current step count.

Note
Reads the accumulated step count from the sensor. Step counter must be enabled first.
Returns
Current step count, or 0 on error

Definition at line 691 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::dev, and SENSORLIB_LOG_E.

Referenced by update().

◆ getStepCounterWatermark()

bool SensorBMA423::getStepCounterWatermark ( uint16_t &  step_counter_wm) const
inline

Get the current step counter watermark.

Note
This function retrieves the current watermark level for the step counter.
Parameters
&step_counter_wmReference to the variable to store the watermark level
Return values
trueif successful, false on error

Definition at line 388 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::dev.

◆ isAnyMotionEnabled()

bool SensorBMA423::isAnyMotionEnabled ( ) const
inline

Check if any-motion detection is enabled.

Definition at line 739 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg.

◆ isNoMotionEnabled()

bool SensorBMA423::isNoMotionEnabled ( ) const
inline

Check if no-motion detection is enabled.

Definition at line 747 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg.

◆ resetStepCounter()

bool SensorBMA423::resetStepCounter ( )
inline

Reset the step counter.

Note
This function resets the internal step counter to zero.
Return values
trueif successful, false on error

Definition at line 706 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::dev.

◆ selectPlatform()

bool SensorBMA423::selectPlatform ( Platform  platform)
inline

Select the platform for the sensor.

Note
This function configures the sensor for the specified platform. @warranty This setting affects tilt detection.
Parameters
platformThe platform to select, allowed values are:
  • SMARTPHONE
  • WRISTBAND
Return values
None

Definition at line 437 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References SensorBMA4XX::dev.

Referenced by setup().

◆ selectTapType()

bool SensorBMA423::selectTapType ( TapType  tap)
inline

Select tap detection tap type.

Note
This function selects the tap detection tap type.
Parameters
tapThe tap type to select, allowed values are:
  • DOUBLE_TAP
  • SINGLE_TAP
Return values
trueif successful, false on error

Definition at line 467 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _tapType, SensorBMA4XX::dev, DOUBLE_TAP, and SINGLE_TAP.

Referenced by setup().

◆ setCallbacks()

void SensorBMA423::setCallbacks ( const EventCallbacks cbs)
inline

Set all callbacks at once.

Note
This function copies the entire EventCallbacks structure.
Parameters
cbsReference to EventCallbacks structure containing all callbacks

Definition at line 260 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks.

◆ setOnActivityCallback()

void SensorBMA423::setOnActivityCallback ( std::function< void(ActivityType)>  cb)
inline

Set the callback for activity events.

Note
The callback will be invoked when activity type changes (e.g., walking to running).
Parameters
cbCallback function that accepts ActivityType as parameter

Definition at line 210 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onActivity.

Referenced by setup(), and setupActivityCallback().

◆ setOnAnyMotionCallback()

void SensorBMA423::setOnAnyMotionCallback ( std::function< void(void)>  cb)
inline

Set the any-motion callback for motion events.

Note
The callback will be invoked when motion state changes.
Parameters
cbCallback function that accepts void

Definition at line 220 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onAnyMotion.

Referenced by setup().

◆ setOnDataReadyCallback()

void SensorBMA423::setOnDataReadyCallback ( std::function< void(AccelerometerData)>  cb)
inline

Set the callback for data ready events.

Note
The callback will be invoked when new accelerometer data is available.
Parameters
cbCallback function that accepts AccelerometerData reference

Definition at line 240 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onDataReady.

Referenced by setup(), and setupDataReadyCallback().

◆ setOnNoMotionCallback()

void SensorBMA423::setOnNoMotionCallback ( std::function< void(void)>  cb)
inline

Set the callback for no-motion events.

Note
The callback will be invoked when no motion is detected.
Parameters
cbCallback function that accepts void

Definition at line 230 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onNoMotion.

Referenced by setup().

◆ setOnStepCountCallback()

void SensorBMA423::setOnStepCountCallback ( std::function< void(uint32_t)>  cb)
inline

Set the callback for step count events.

Note
The callback will be invoked when step count is updated (provides total step count).
Parameters
cbCallback function that accepts uint32_t step count as parameter

Definition at line 200 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onStepCount.

Referenced by setup(), and setupStepCallbacks().

◆ setOnStepDetectedCallback()

void SensorBMA423::setOnStepDetectedCallback ( std::function< void()>  cb)
inline

Set the callback for step detection events.

Note
The callback will be invoked when a step is detected (each step).

Definition at line 190 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onStepDetected.

Referenced by setup(), and setupStepCallbacks().

◆ setOnTapCallback()

void SensorBMA423::setOnTapCallback ( std::function< void(TapType)>  cb)
inline

Set the callback for tap events.

Note
The callback will be invoked when a tap (single/double/triple) is detected.
Parameters
cbCallback function that accepts TapType as parameter

Definition at line 181 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onTap.

Referenced by setup(), and setupTapCallback().

◆ setOnTiltDetectedCallback()

void SensorBMA423::setOnTiltDetectedCallback ( std::function< void(void)>  cb)
inline

Set the callback for tilt detection events.

Note
The callback will be invoked when a tilt is detected.
Parameters
cbCallback function that accepts void

Definition at line 250 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References callbacks, and SensorBMA423::EventCallbacks::onTiltDetected.

Referenced by setup(), and setupTiltCallback().

◆ update()

void SensorBMA423::update ( )
inlineoverridevirtual

Update sensor state and process interrupts.

Note
This method should be called periodically (e.g., in main loop) to check for and process sensor interrupts. It reads the interrupt status register and invokes the appropriate callbacks.
Returns
void

Implements SensorBMA4XX.

Definition at line 759 of file sensor/accelerometer/bma/SensorBMA423.hpp.

References _mon_cfg, _status, _tapType, callbacks, SensorBMA4XX::dev, DOUBLE_TAP, getActivityType(), getStepCount(), SensorBMA423::EventCallbacks::onActivity, SensorBMA423::EventCallbacks::onAnyMotion, SensorBMA423::EventCallbacks::onDataReady, SensorBMA423::EventCallbacks::onNoMotion, SensorBMA423::EventCallbacks::onStepCount, SensorBMA423::EventCallbacks::onStepDetected, SensorBMA423::EventCallbacks::onTap, SensorBMA423::EventCallbacks::onTiltDetected, SensorBMA4XX::readData(), SENSORLIB_LOG_E, and SINGLE_TAP.

Referenced by loop().

Member Data Documentation

◆ _mon_cfg

◆ _status

uint16_t SensorBMA423::_status
protected

Definition at line 832 of file sensor/accelerometer/bma/SensorBMA423.hpp.

Referenced by update().

◆ _tapType

BMA423_TapType SensorBMA423::_tapType
protected

Definition at line 834 of file sensor/accelerometer/bma/SensorBMA423.hpp.

Referenced by selectTapType(), SensorBMA423(), and update().

◆ callbacks


The documentation for this class was generated from the following file: