Skip to content

Commit 7f99761

Browse files
committed
feat: add wrapper functions for advanced power-saving config
1 parent 48e639b commit 7f99761

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/BMI270.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ void BoschSensorClass::oneShotMode() {
142142
continuousMode.end();
143143
}
144144

145+
// default value is 1 (aps_on). power saving may prevent high odr setting to work properly
146+
bool BoschSensorClass::setAdvPowerSaveMode(uint8_t enable)
147+
{
148+
int8_t rslt = bmi2_set_adv_power_save(enable ? BMI2_ENABLE : BMI2_DISABLE, &bmi2);
149+
return (rslt == BMI2_OK);
150+
}
151+
152+
uint8_t BoschSensorClass::getAdvPowerSaveMode()
153+
{
154+
uint8_t status = 0;
155+
if(bmi2_get_adv_power_save(&status, &bmi2) == BMI2_OK) {
156+
return status;
157+
}
158+
return 0;
159+
}
145160
// default range is +-4G, so conversion factor is (((1 << 15)/4.0f))
146161
#define INT16_to_G (8192.0f)
147162

src/BoschSensorClass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ class BoschSensorClass {
135135

136136
void setContinuousMode();
137137
void oneShotMode();
138-
138+
bool setAdvPowerSaveMode(uint8_t enable);
139+
uint8_t getAdvPowerSaveMode();
139140
int begin(CfgBoshSensor_t cfg = BOSCH_ACCEL_AND_MAGN);
140141
void end();
141142

0 commit comments

Comments
 (0)