Skip to content

Commit 0294968

Browse files
authored
Merge pull request #58 from RenMurakami/main
Update: Flexible setting sample rate
2 parents 2722274 + 865c222 commit 0294968

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ Usage Example
6666
from adafruit_bno08x.i2c import BNO08X_I2C
6767
from adafruit_bno08x import BNO_REPORT_ACCELEROMETER
6868
69+
REPORT_INTERVAL = const(100000) # 100 Hz
6970
i2c = busio.I2C(board.SCL, board.SDA)
7071
bno = BNO08X_I2C(i2c)
71-
bno.enable_feature(BNO_REPORT_ACCELEROMETER)
72+
bno.enable_feature(BNO_REPORT_ACCELEROMETER, REPORT_INTERVAL)
7273
7374
while True:
7475
accel_x, accel_y, accel_z = bno.acceleration

adafruit_bno08x/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ def _process_report(self, report_id: int, report_bytes: bytearray) -> None:
933933
@staticmethod
934934
def _get_feature_enable_report(
935935
feature_id: int,
936-
report_interval: int = _DEFAULT_REPORT_INTERVAL,
936+
report_interval: int,
937937
sensor_specific_config: int = 0,
938938
) -> bytearray:
939939
set_feature_report = bytearray(17)
@@ -947,16 +947,20 @@ def _get_feature_enable_report(
947947
# TODO: add docs for available features
948948
# TODO2: I think this should call an fn that imports all the bits for the given feature
949949
# so we're not carrying around stuff for extra features
950-
def enable_feature(self, feature_id: int) -> None:
950+
def enable_feature(
951+
self,
952+
feature_id: int,
953+
report_interval: int = _DEFAULT_REPORT_INTERVAL,
954+
) -> None:
951955
"""Used to enable a given feature of the BNO08x"""
952956
self._dbg("\n********** Enabling feature id:", feature_id, "**********")
953957

954958
if feature_id == BNO_REPORT_ACTIVITY_CLASSIFIER:
955959
set_feature_report = self._get_feature_enable_report(
956-
feature_id, sensor_specific_config=_ENABLED_ACTIVITIES
960+
feature_id, report_interval, _ENABLED_ACTIVITIES
957961
)
958962
else:
959-
set_feature_report = self._get_feature_enable_report(feature_id)
963+
set_feature_report = self._get_feature_enable_report(feature_id, report_interval)
960964

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

0 commit comments

Comments
 (0)