Skip to content

Allow uart to go ~100Hz versus 10Hz #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
17 changes: 13 additions & 4 deletions adafruit_bno055.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,26 @@ def _write_register(self, register, data): # pylint: disable=arguments-differ
if not isinstance(data, bytes):
data = bytes([data])
self._uart.write(bytes([0xAA, 0x00, register, len(data)]) + data)
time.sleep(0.1)
now = time.monotonic()
while self._uart.in_waiting < 2 and time.monotonic() - now < 0.25:
pass
resp = self._uart.read(self._uart.in_waiting)
if len(resp) < 2:
raise OSError("UART access error.")
if resp[0] != 0xEE or resp[1] != 0x01:
raise RuntimeError("UART write error: {}".format(resp[1]))

def _read_register(self, register, length=1): # pylint: disable=arguments-differ
self._uart.write(bytes([0xAA, 0x01, register, length]))
time.sleep(0.1)
resp = self._uart.read(self._uart.in_waiting)
i = 0
while i < 3:
self._uart.write(bytes([0xAA, 0x01, register, length]))
now = time.monotonic()
while self._uart.in_waiting < length + 2 and time.monotonic() - now < 0.1:
pass
resp = self._uart.read(self._uart.in_waiting)
if len(resp) >= 2 and resp[0] == 0xBB:
i = 3
i += 1
if len(resp) < 2:
raise OSError("UART access error.")
if resp[0] != 0xBB:
Expand Down
10 changes: 3 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.viewcode"]

# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
Expand Down Expand Up @@ -144,7 +140,7 @@
"Adafruit BNO055 Library Documentation",
"Radomir Dopieralski",
"manual",
),
)
]

# -- Options for manual page output ---------------------------------------
Expand Down Expand Up @@ -175,5 +171,5 @@
"AdafruitBNO055Library",
"One line description of project.",
"Miscellaneous",
),
)
]
1 change: 0 additions & 1 deletion examples/bno055_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# sensor = adafruit_bno055.BNO055_UART(uart)

while True:
print("Temperature: {} degrees C".format(sensor.temperature))
print("Accelerometer (m/s^2): {}".format(sensor.acceleration))
print("Magnetometer (microteslas): {}".format(sensor.magnetic))
print("Gyroscope (rad/sec): {}".format(sensor.gyro))
Expand Down