From 556721e2e5d71be776c3afa891f995554ca9671e Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 3 Jul 2025 18:42:37 -0400 Subject: [PATCH 1/3] Option set report interval manually --- adafruit_bno08x/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/adafruit_bno08x/__init__.py b/adafruit_bno08x/__init__.py index fb909f7..88d4f26 100644 --- a/adafruit_bno08x/__init__.py +++ b/adafruit_bno08x/__init__.py @@ -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) @@ -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 From 0ec3b32df63043203d78b8634ab1ded4b429b2cb Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 3 Jul 2025 18:45:27 -0400 Subject: [PATCH 2/3] Fix readme to apply the change --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index dcb42c7..ba85739 100644 --- a/README.rst +++ b/README.rst @@ -66,9 +66,11 @@ 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 From 865c2220c8a98353b215babcd2c1b679b4fab058 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 3 Jul 2025 19:04:08 -0400 Subject: [PATCH 3/3] Fix white space issue --- README.rst | 1 - adafruit_bno08x/__init__.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ba85739..847d7e8 100644 --- a/README.rst +++ b/README.rst @@ -67,7 +67,6 @@ Usage Example 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, REPORT_INTERVAL) diff --git a/adafruit_bno08x/__init__.py b/adafruit_bno08x/__init__.py index 88d4f26..77ed577 100644 --- a/adafruit_bno08x/__init__.py +++ b/adafruit_bno08x/__init__.py @@ -948,7 +948,7 @@ def _get_feature_enable_report( # 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, + self, feature_id: int, report_interval: int = _DEFAULT_REPORT_INTERVAL, ) -> None: