83 Serial.println(
"[probe] Detected BMA422");
90 Serial.println(
"[probe] Detected BMA423");
97 Serial.println(
"[probe] Detected BMA456H");
116 Serial.println(
" [callback] SINGLE TAP");
break;
118 Serial.println(
" [callback] DOUBLE TAP");
break;
127 Serial.println(
" [callback] SINGLE TAP");
break;
129 Serial.println(
" [callback] DOUBLE TAP");
break;
131 Serial.println(
" [callback] TRIPLE TAP");
break;
146 Serial.println(
" [callback] STEP DETECTED");
149 Serial.print(
" [callback] STEP COUNT: ");
150 Serial.println(count);
155 Serial.println(
" [callback] STEP DETECTED");
158 Serial.print(
" [callback] STEP COUNT: ");
159 Serial.println(count);
170 Serial.print(
" [callback] ACTIVITY: ");
175 default: Serial.println(
"Unknown");
break;
195 Serial.println(
" [callback] TILT DETECTED");
203 Serial.print(
" [callback] DataReady: ");
204 Serial.print(data.mps2.x, 2); Serial.print(
", ");
205 Serial.print(data.mps2.y, 2); Serial.print(
", ");
206 Serial.println(data.mps2.z, 2);
232 Serial.print(
"Chip: ");
234 Serial.print(
", Capabilities: 0x");
235 Serial.println(
static_cast<uint32_t
>(caps), HEX);
238 Serial.println(
" + enableDataReady");
243 Serial.println(
" + enableAnyMotion");
250 Serial.println(
" + setRemapAxes");
255 Serial.println(
" + enableTapDetector");
261 Serial.println(
" + enableStepDetector");
268 Serial.println(
" + enableActivityRecognition");
274 Serial.println(
" + enableTiltDetector");
283 Serial.begin(115200);
294 Serial.println(
"No BMA4XX sensor detected!");
299 Serial.print(
"Using: ");
309 Serial.println(
"Failed to configure accelerometer");
329 Serial.println(
"=== System ready. Waiting for events... ===");
340 static unsigned long lastPoll = 0;
341 if (millis() - lastPoll > 5000) {
343 Serial.print(
"[poll] Temperature: ");
345 Serial.println(
" C");
void setupActivityCallback()
DetectedModel detectedModel
volatile bool isInterruptTriggered
void setupDataReadyCallback()
void setupStepCallbacks()
bool begin(CommInterface interface, SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr=0)
Initialize the sensor using custom callback interface.
void setOnDataReadyCallback(std::function< void(AccelerometerData)> cb)
Set the callback for data ready events.
void setOnStepDetectedCallback(std::function< void()> cb)
Set the callback for step detection events.
void setOnDataReadyCallback(std::function< void(AccelerometerData)> cb)
Set the callback for data ready events.
void setOnTapCallback(std::function< void(TapType)> cb)
Set the callback for tap events.
void setOnActivityCallback(std::function< void(ActivityType)> cb)
Set the callback for activity events.
void setOnStepCountCallback(std::function< void(uint32_t)> cb)
Set the callback for step count events.
void setOnTiltDetectedCallback(std::function< void(void)> cb)
Set the callback for tilt detection events.
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 setOnActivityCallback(std::function< void(ActivityType)> cb)
Set the callback for activity events.
void setOnDataReadyCallback(std::function< void(AccelerometerData)> cb)
Set the callback for data ready events.
void setOnStepCountCallback(std::function< void(uint32_t)> cb)
Set the callback for step count events.
virtual bool enableStepCounter(bool enable, uint16_t step_counter_wm=1, bool reset_counter=false)
Enable or disable step counter (default: not supported)
virtual void update()=0
Update the sensor data, this method is implemented by a subclass.
virtual bool setRemapAxes(SensorRemap remap)
Set the remapping of axes for the BMA4XX sensor.
virtual bool enableStepDetector(bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1)
Enable or disable step detector (default: not supported)
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.
virtual bool enableAnyMotionDetection(const MotionAxesConfig &cfg, bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1)
Enable or disable any-motion detection (default: not supported)
virtual bool enableTapDetector(bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1)
Enable or disable tap detection (default: not supported)
virtual bool enableTiltDetector(bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1)
Enable or disable tilt detection (default: not supported)
virtual bool enableActivityRecognition(bool enable, bool interrupt_enable=false, InterruptPinMap pin_map=InterruptPinMap::PIN1)
Enable or disable activity recognition (default: not supported)
const char * getModelName() const
Get the model name of the BMA4XX sensor.
float getTemperature() const
Get the temperature reading from the sensor.
virtual BMA4XXCapability::Capability getCapabilities() const =0
Get supported capabilities.
virtual bool enableDataReady(bool enable=true, InterruptPinMap pin_map=InterruptPinMap::PIN1)
Enable data ready interrupt (default: not supported)
bool configAccelerometer(OperationMode mode, AccelFullScaleRange range, float data_rate_hz, AccelBandwidth bandwidth, AccelPerfMode perf_mode)
Configure the accelerometer.
@ OSR2_AVG2
OSR2 mode with 2 samples averaged.
ActivityType
Activity detection type.
TapType
Tap detection type.
@ CIC_AVG_MODE
Averaging filter mode: samples are averaged based on configured bandwidth and ODR.
Structure representing accelerometer data.
Motion axes configuration.