Skip to content

Conversation

@christopherwun
Copy link
Collaborator

@christopherwun christopherwun commented Aug 14, 2025

Merging in bno080 and bno080i2c modules to main, updated to work with circuitpython v9. Tested using the corresponding branch in cionic-circuitpython (https://github.com/cionicwear/cionic-circuitpython/tree/bno080-v9) using the same examples described there:

Testing:

  • Tested with footpod example, was able to get a smoother signal using just SPI bus IMU
  • Tested with a new footshankpod example that uses both a SPI and I2C bus IMU

ALSO: UPDATED CIONIC FORK TO PASS CHECKS:

  • Bypassed CI/scheduler's unique VID/PID checks with an unused VID/PID
  • Ran pre-commit to fix styling
  • Updated python docstrings in C files to appease CI
  • Moved cionic's custom digitalio updates into shared-bindings layer instead of nordic hal layer so other boards can build properly
  • Updated build config to match most recent adafruit version to pass checks
  • Commented deprecated function get_html_theme_path as suggested in adafruit version

@christopherwun christopherwun requested a review from Copilot August 14, 2025 00:40
@christopherwun christopherwun changed the title Chris/native bno v9 Native bno080 + bno080i2c implementation in circuitpython v9 Aug 14, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@christopherwun christopherwun requested a review from Copilot August 14, 2025 01:21

This comment was marked as outdated.

@christopherwun christopherwun requested a review from Copilot August 18, 2025 18:10

This comment was marked as outdated.

@christopherwun christopherwun marked this pull request as ready for review August 18, 2025 19:04
@christopherwun christopherwun changed the title Native bno080 + bno080i2c implementation in circuitpython v9 Native bno080 (spi) + bno080i2c implementation in circuitpython v9 Aug 18, 2025
@msmcionic
Copy link

FAILING CHECKS NOTES (do we need to address these?):

  • Build CI/scheduler checks fail because we don't use a unique VID/PID (instead, we copy the adafruit_led_glasses_nrf52840's USB VID/PID).

Note: You can try this below to make the CI happy, since this is for prototyping and we will not ship firmware without Adafruit explicitly assigning a PID to our product. The quick fix is just to unblock your PR.

First Pick a VID:PID that’s not used anywhere else in the repo:

git grep -n "USB_VID\s*=" ports | awk -F: '{print $1}' | xargs -I{} bash -c 'grep -H "USB_VID" "{}"; grep -H "USB_PID" "{}"' | paste - - | sed 's/.*USB_VID = (0x[0-9A-Fa-f]+).USB_PID = (0x[0-9A-Fa-f]+)./\1:\2/' | sort -u

Edit ports/nordic/boards/cionic_sense/mpconfigboard.mk

+# TEMP UNIQUE PAIR FOR CI
+USB_VID = 0x239A
+USB_PID = 0x84FE (Use any unused PID; 0x84FE is just an example)
USB_PRODUCT = "nRF52840 Cionic Sense"
USB_MANUFACTURER = "CIONIC Inc"

You should then be able to verify locally:

python3 -u -m tools.ci_check_duplicate_usb_vid_pid

For the second issue

pre-commit fails because of some files outside of our edited files which do not follow the pre-commit requirements. The Python checker also gets confused because we have Python-style docstrings within our bno080 and bno080i2c packages and cannot parse it properly because these are C files.

Your comments in some of your files currently contain unclosed/invalid text that becomes broken Python, so the script exits with error 123:

error: cannot format -: Cannot parse: 99:11: """Reset the ADS1x9x
shared-bindings/ads1x9x/ADS1x9x.c:0: Failed to process file
Command '['black', '--pyi', '-l95', '-q', '-']' returned non-zero exit status 123.
error: cannot format -: Cannot parse: 100:11: """Reset the BNO080
shared-bindings/bno080/BNO080.c:0: Failed to process file
Command '['black', '--pyi', '-l95', '-q', '-']' returned non-zero exit status 123.
error: cannot format -: Cannot parse: 118:11: """Reset the BNO080
shared-bindings/bno080i2c/BNO080I2C.c:0: Failed to process file
Command '['black', '--pyi', '-l95', '-q', '-']' returned non-zero exit status 123.
Traceback (most recent call last):

You can fix this by adding a period and end quotes:

//| def reset(self) -> None:
//| """Reset the ."""
//|

You can test locally after fixing the syntax issue:

python3 -m tools/codeformat

@christopherwun christopherwun requested a review from Copilot August 28, 2025 00:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR merges native BNO080 SPI and I2C interface modules to CircuitPython v9. The changes implement complete driver support for the BNO080 IMU sensor with both communication protocols and includes various codebase improvements for CI compatibility.

Key changes:

  • Added native bno080 module for SPI-based BNO080 communication
  • Added native bno080i2c module for I2C-based BNO080 communication
  • Updated build system to support new BNO080 modules with configuration flags
  • Various code style and documentation fixes across multiple modules

Reviewed Changes

Copilot reviewed 41 out of 49 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
shared-module/bno080*/ Complete BNO080 driver implementation for both SPI and I2C protocols
shared-bindings/bno080*/ Python bindings for BNO080 modules with proper API documentation
py/circuitpy_*.mk Build system updates to include new BNO080 modules
lib/cionic/ Orientation math library and utility functions for BNO080
ports/nordic/ Board-specific configuration for cionic_sense board
shared-bindings/digitalio/DigitalInOut.h Enhanced digital IO with IRQ support
Comments suppressed due to low confidence (2)

tools/stack-loc-to-pc.py:13

  • [nitpick] Adding an empty line at the end of a docstring is unnecessary and inconsistent with Python style conventions. Consider removing this empty line to maintain clean documentation formatting.
offset = re.compile(r"sp, #(\d+)")

shared-module/bno080i2c/BNO080I2C.c:90

  • Using 'bzero' is deprecated. Use 'memset(tx, 0, sizeof(tx))' instead for better portability and standards compliance.
        mp_printf(&mp_plat_print, "before write: %d\n", mp_hal_ticks_ms());

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@msmcionic msmcionic self-requested a review August 28, 2025 13:27
@christopherwun christopherwun merged commit a36b39e into main Sep 2, 2025
541 of 543 checks passed
@christopherwun christopherwun deleted the chris/native-bno-v9 branch September 2, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants