Skip to content

Add support for ICM45605 and ICM45686 #4432

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented Apr 17, 2025

# status
MCU STM32H743 (Rev.V) Clock=480MHz, Vref=3.36V, Core temp=50degC
Stack size: 2048, Stack address: 0x2001fff8
Configuration: CONFIGURED, size: 4223, max available: 131072
Devices detected: SPI:2, I2C:1
Gyros detected: gyro 1, gyro 2 locked shared
GYRO=ICM45686, ACC=ICM45686, BARO=DPS310
OSD: MAX7456 (30 x 13)
BUILD KEY: 9ef07befda3fdfa1ca1727017239163b (4.6.0-dev)
System Uptime: 701 seconds, Current Time: 2025-04-18T20:23:46.088+00:00
CPU:18%, cycle time: 156, GYRO rate: 6410, RX rate: 0, System rate: 9
Voltage: 0 * 0.01V (0S battery - NOT PRESENT)
I2C Errors: 9
FLASH: JEDEC ID=0x00efaa21 128M
GPS: NOT ENABLED
Arming disable flags: RXLOSS CLI MSP

image

This pull request updates the sensorTypes function in src/js/sensor_types.js to enhance the handling of array modifications by replacing single-element additions with multi-element additions. It also updates the utility function used for this purpose.

Updates to array modification logic:

  • Replaced addArrayElementAfter with addArrayElementsAfter to allow adding multiple elements at once in the gyroElements and accElements arrays. This simplifies the code and improves extensibility.

Utility function update:

  • Updated the import statement to use addArrayElementsAfter from utils/array instead of addArrayElementAfter, reflecting the new multi-element addition approach.

Summary by CodeRabbit

  • New Features

    • Added support for additional sensor types in the sensor selection options.
  • Bug Fixes

    • Improved the handling of sensor type insertion for API version 1.47 and above.

Copy link

netlify bot commented Apr 17, 2025

Deploy Preview for origin-betaflight-app ready!

Name Link
🔨 Latest commit cc2aa51
🔍 Latest deploy log https://app.netlify.com/sites/origin-betaflight-app/deploys/6808c6ab9e92d70008c3753f
😎 Deploy Preview https://deploy-preview-4432.app.betaflight.com
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@nerdCopter nerdCopter left a comment

Choose a reason for hiding this comment

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

  • pre-approving; dependent on firmware merge.

Copy link
Member

@VitroidFPV VitroidFPV left a comment

Choose a reason for hiding this comment

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

Approving to be read for firmware merge

@haslinghuis haslinghuis changed the title Add support for ICM45686 and ICM45605 Add support for ICM45605 and ICM45686 Apr 23, 2025
Copy link

coderabbitai bot commented May 2, 2025

Walkthrough

The changes update how new sensor types are inserted into sensor arrays based on the API version. The utility function used for array insertion is switched to allow adding multiple elements at once. Specifically, three new sensor types are now inserted simultaneously after a specific existing sensor type, instead of adding just one. Other logic for removing deprecated sensors and adding virtual sensors remains unchanged.

Changes

File(s) Change Summary
src/js/sensor_types.js Replaced single-element insertion with multi-element insertion for new sensor types in arrays; updated import statement for the new utility function.

Poem

In the garden of code where sensors bloom,
Three new friends join, dispelling the gloom.
With arrays that stretch and helpers anew,
The rabbit hops on, with much to do!
Sensors abound, the list grows wide,
In every burrow, new features to hide. 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e64befd and 61ead58.

📒 Files selected for processing (1)
  • src/js/sensor_types.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/js/sensor_types.js
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented May 2, 2025

Preview URL: https://ca6433c8.betaflight-configurator.pages.dev

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe72268 and f63f901.

📒 Files selected for processing (1)
  • src/js/sensor_types.js (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/js/sensor_types.js (1)
src/js/utils/array.js (2)
  • addArrayElementsAfter (35-43)
  • removeArrayElement (7-12)
🔇 Additional comments (3)
src/js/sensor_types.js (3)

4-4: Import updated appropriately.

The import statement has been correctly updated to include the new addArrayElementsAfter utility function while retaining the necessary removeArrayElement and addArrayElement functions.


114-114: Improved code maintainability for gyro sensors.

The change consolidates what would have been multiple single-element additions into one function call, making the code more maintainable and easier to extend in the future when additional sensors need to be added.


120-120: Improved code maintainability for accelerometer sensors.

Similar to the gyro sensors change, this consolidates multiple operations into a single function call, improving code consistency and maintainability.

Comment on lines 114 to 120
addArrayElementsAfter(gyroElements, "LSM6DSV16X", ["IIM42653", "ICM45686", "ICM45605"]);

removeArrayElement(accElements, "ADXL345");
removeArrayElement(accElements, "MMA8452");
removeArrayElement(accElements, "BMA280");
removeArrayElement(accElements, "LSM303DLHC");
addArrayElementAfter(accElements, "LSM6DSV16X", "IIM42653");
addArrayElementsAfter(accElements, "LSM6DSV16X", ["IIM42653", "ICM45686", "ICM45605"]);
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify sensor detection works correctly.

The addition of the new sensor types (ICM45686 and ICM45605) alongside IIM42653 should be verified to ensure proper sensor detection in the actual application.


🏁 Script executed:

#!/bin/bash
# Search for any regression tests that might verify these sensor type integrations
fd -t f -e js test | xargs grep -l "ICM45686\|ICM45605" || echo "No test files found containing the new sensor types"

# Look for implementation files that might be using these new sensor types
fd -t f -e js src | xargs grep -l "ICM45686\|ICM45605" | grep -v sensor_types.js || echo "No additional implementation files found using these sensor types"

Length of output: 394


Add regression tests for ICM45686 and ICM45605

No existing tests reference the newly added sensor types. Please add unit or integration tests to verify that both gyroElements and accElements include “IIM42653”, “ICM45686”, and “ICM45605” immediately after “LSM6DSV16X”.

• Location to cover:

  • src/js/sensor_types.js (around lines 114–120)
    • What to test:
  • That addArrayElementsAfter correctly injects the three new sensors in the proper order for both gyroElements and accElements.
    • Example snippet for a new test file (e.g. test/sensor_types.test.js):
import { gyroElements, accElements } from '../src/js/sensor_types';

describe('sensor_types array augmentation', () => {
  it('adds new gyro sensors after LSM6DSV16X', () => {
    const idx = gyroElements.indexOf('LSM6DSV16X');
    expect(gyroElements.slice(idx + 1, idx + 4))
      .toEqual(['IIM42653', 'ICM45686', 'ICM45605']);
  });

  it('adds new accelerometer sensors after LSM6DSV16X', () => {
    const idx = accElements.indexOf('LSM6DSV16X');
    expect(accElements.slice(idx + 1, idx + 4))
      .toEqual(['IIM42653', 'ICM45686', 'ICM45605']);
  });
});

@haslinghuis haslinghuis force-pushed the add-icm45686 branch 2 times, most recently from e64befd to 7f831d5 Compare May 5, 2025 23:07
Copy link

sonarqubecloud bot commented May 5, 2025

Copy link
Contributor

github-actions bot commented May 5, 2025

Preview URL: https://c9305682.betaflight-configurator.pages.dev

@haslinghuis
Copy link
Member Author

Rebased

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants