Skip to content

Commit 6a4dcd9

Browse files
committed
Add API to set the sensor range
1 parent e4eb63c commit 6a4dcd9

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/BoschSensortec.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ void BoschSensortec::configureSensor(SensorConfigurationPacket& config)
116116
}
117117
}
118118

119+
int BoschSensortec::configureSensorRange(uint8_t id, uint16_t range)
120+
{
121+
auto ret = bhy2_set_virt_sensor_range(id, range, &_bhy2);
122+
if (ret == BHY2_OK) {
123+
return 1;
124+
}
125+
return 0;
126+
}
127+
119128
void BoschSensortec::getSensorConfiguration(uint8_t id, SensorConfig& virt_sensor_conf)
120129
{
121130
bhy2_get_virt_sensor_cfg(id, &virt_sensor_conf, &_bhy2);

src/BoschSensortec.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class BoschSensortec {
3535
bool begin();
3636
void update();
3737
void configureSensor(SensorConfigurationPacket& config);
38+
int configureSensorRange(uint8_t id, uint16_t range);
3839
void getSensorConfiguration(uint8_t id, SensorConfig& virt_sensor_conf);
3940

4041
void printSensors();

src/sensors/SensorClass.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ void SensorClass::configure(float rate, uint32_t latency)
4949

5050
}
5151

52+
int SensorClass::setRange(uint16_t range)
53+
{
54+
return sensortec.configureSensorRange(_id, range);
55+
}
56+
5257
const SensorConfig SensorClass::getConfiguration()
5358
{
5459
SensorConfig config;

src/sensors/SensorClass.h

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class SensorClass {
2121
*/
2222
bool begin(float rate = 1000, uint32_t latency = 1);
2323
void configure(float rate, uint32_t latency);
24+
int setRange(uint16_t range);
2425
const SensorConfig getConfiguration();
2526
void end();
2627

0 commit comments

Comments
 (0)