Skip to content

Conversation

haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented May 5, 2025

Summary by CodeRabbit

  • New Features
    • Sensor information display now includes optical flow sensor info for API versions 1.47 and above.
  • Improvements
    • Sensor info box is now hidden for API versions below 1.46 to prevent displaying unsupported information.
    • Enhanced control over sensor info visibility based on API version.
  • Style
    • Added a unique identifier to the sensor info box for improved element targeting.

@haslinghuis haslinghuis added this to the 11.0 milestone May 5, 2025
@haslinghuis haslinghuis self-assigned this May 5, 2025
Copy link
Contributor

coderabbitai bot commented May 5, 2025

Walkthrough

The changes update the logic for displaying sensor information in the setup tab. The request for sensor data is now unconditional, except for the optical flow sensor, which is only included for API versions 1.47 and above. The sensor info box is shown only for API versions 1.46 and higher; otherwise, it is hidden using a new hideSensorInfo function. Additionally, the sensor info container in the HTML is now uniquely identified with an id="sensorInfoBox" attribute.

Changes

File(s) Change Summary
src/js/tabs/setup.js Refactored sensor info request logic: unconditional requests for most sensors, opticalflow gated by API version ≥1.47. Introduced hideSensorInfo to hide the info box for API versions <1.46. Adjusted initialization to conditionally show or hide sensor info based on API version.
src/tabs/setup.html Added id="sensorInfoBox" to the sensor info container <div>.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Setup Tab UI
    participant API as API Layer

    UI->>API: Request sensor info (gyro, accel, baro, mag, sonar)
    alt API version >= 1.47
        UI->>API: Request opticalflow sensor info
    end
    API-->>UI: Return sensor info
    alt API version >= 1.46
        UI->>UI: showSensorInfo()
    else API version < 1.46
        UI->>UI: hideSensorInfo()
    end
Loading

📜 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 6f35f09 and 1f8f426.

📒 Files selected for processing (2)
  • src/js/tabs/setup.js (2 hunks)
  • src/tabs/setup.html (1 hunks)
🔇 Additional comments (4)
src/tabs/setup.html (1)

181-181: Adding ID to sensorInfoBox is a clean solution.

This change adds a specific ID to the sensor information container, which allows for direct DOM manipulation in JavaScript. This approach is better than relying on class selectors which could match multiple elements.

src/js/tabs/setup.js (3)

307-338: Good refactoring of sensor info request logic.

The sensor info request is now made unconditionally, with only the optical flow sensor handling being conditionally based on API version 1.47+. This maintains backward compatibility while simplifying the code flow.


341-343: Clean implementation of the hideSensorInfo function.

This new function provides a clean way to hide the sensor info box when needed. It correctly uses the ID selector added to the HTML element.


518-523: Proper API version check for sensor info display.

This conditional block ensures that the sensor info is only shown for API versions 1.46 and above, while hiding it for older versions. This is a proper fix for backward compatibility.

✨ 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.

@haslinghuis haslinghuis moved this to App in 2025.12.0 May 5, 2025
Copy link

sonarqubecloud bot commented May 5, 2025

Copy link
Contributor

github-actions bot commented May 5, 2025

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

@haslinghuis haslinghuis merged commit c5f5e15 into betaflight:master May 6, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from App to Done in 2025.12.0 May 6, 2025
@haslinghuis haslinghuis deleted the fix-backwards-compatibility branch May 6, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants