Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ Usage Example
from adafruit_bno08x.i2c import BNO08X_I2C
from adafruit_bno08x import BNO_REPORT_ACCELEROMETER

REPORT_INTERVAL = const(100000) # 100 Hz
i2c = busio.I2C(board.SCL, board.SDA)
bno = BNO08X_I2C(i2c)
bno.enable_feature(BNO_REPORT_ACCELEROMETER)
bno.enable_feature(BNO_REPORT_ACCELEROMETER, REPORT_INTERVAL)

while True:
accel_x, accel_y, accel_z = bno.acceleration
Expand Down
12 changes: 8 additions & 4 deletions adafruit_bno08x/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ def _process_report(self, report_id: int, report_bytes: bytearray) -> None:
@staticmethod
def _get_feature_enable_report(
feature_id: int,
report_interval: int = _DEFAULT_REPORT_INTERVAL,
report_interval: int,
sensor_specific_config: int = 0,
) -> bytearray:
set_feature_report = bytearray(17)
Expand All @@ -947,16 +947,20 @@ def _get_feature_enable_report(
# TODO: add docs for available features
# TODO2: I think this should call an fn that imports all the bits for the given feature
# so we're not carrying around stuff for extra features
def enable_feature(self, feature_id: int) -> None:
def enable_feature(
self,
feature_id: int,
report_interval: int = _DEFAULT_REPORT_INTERVAL,
) -> None:
"""Used to enable a given feature of the BNO08x"""
self._dbg("\n********** Enabling feature id:", feature_id, "**********")

if feature_id == BNO_REPORT_ACTIVITY_CLASSIFIER:
set_feature_report = self._get_feature_enable_report(
feature_id, sensor_specific_config=_ENABLED_ACTIVITIES
feature_id, report_interval, _ENABLED_ACTIVITIES
)
else:
set_feature_report = self._get_feature_enable_report(feature_id)
set_feature_report = self._get_feature_enable_report(feature_id, report_interval)

feature_dependency = _RAW_REPORTS.get(feature_id, None)
# if the feature was enabled it will have a key in the readings dict
Expand Down