Skip to content

Conversation

@haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented Aug 15, 2025

Before:

image

After:

image

Log from 4.5:

image

Summary by CodeRabbit

  • Bug Fixes

    • Hide the “RC Smoothing Feedforward (Hz)” control on BetaFlight 4.6.0 and newer; keep it visible and populated on earlier versions.
    • Limit the “RC Smoothing Active Cutoffs (FF)” control to firmware up through 4.5.x and ensure correct value initialization for BetaFlight 4.3.0–4.5.x.
  • Chores

    • Added a DOM id to a configuration table cell to improve element targeting (non-functional UI attribute).

@haslinghuis haslinghuis added this to the 4.0.0 milestone Aug 15, 2025
@haslinghuis haslinghuis self-assigned this Aug 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 15, 2025

Walkthrough

Adds id attributes to two table cells in index.html and updates header_dialog.js to change the max firmware for rc_smoothing_active_cutoffs_ff and to gate visibility/initialization of feedforward-related controls by BetaFlight firmware version (different handling for >=4.6.0, >=4.3.0, and older).

Changes

Cohort / File(s) Summary of changes
UI markup updates
index.html
Added id="rcSmoothingFeedforwardHz" and id="rcSmoothingActiveCutoffsFf" to the corresponding <td> elements; no other DOM/content changes.
Header dialog rendering logic
src/header_dialog.js
- Changed max firmware for rc_smoothing_active_cutoffs_ff to 4.5.999 (was 999.9.9).
- In renderSysConfig, added BetaFlight-version gating: for BetaFlight >= 4.6.0 hide rcSmoothingFeedforwardHz and rcSmoothingActiveCutoffsFf and initialize rcSmoothingActiveCutoffsSp and rcSmoothingActiveCutoffsThr from sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[0] and [1] (0 decimals). For BetaFlight >= 4.3.0 (and < 4.6.0) set rcSmoothingFeedforwardHz from sysConfig.rc_smoothing_feedforward_hz and map rcSmoothingActiveCutoffsFf/Sp/Thr from sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[0..2] (0 decimals). Removed prior in-branch assignment of rcSmoothingFeedforwardHz in favor of the new gating logic. No exported/public signatures changed.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant HeaderDialog
  participant renderSysConfig
  participant DOM

  User->>HeaderDialog: Open header dialog
  HeaderDialog->>renderSysConfig: Render with sysConfig + firmwareType/version
  renderSysConfig->>renderSysConfig: If firmwareType == BetaFlight
  alt firmware >= 4.6.0
    renderSysConfig->>DOM: Hide rcSmoothingFeedforwardHz, rcSmoothingActiveCutoffsFf
    renderSysConfig->>DOM: Init rcSmoothingActiveCutoffsSp <- rc_smoothing_active_cutoffs_ff_sp_thr[0]
    renderSysConfig->>DOM: Init rcSmoothingActiveCutoffsThr <- rc_smoothing_active_cutoffs_ff_sp_thr[1]
  else if firmware >= 4.3.0
    renderSysConfig->>DOM: Set rcSmoothingFeedforwardHz <- rc_smoothing_feedforward_hz
    renderSysConfig->>DOM: Set rcSmoothingActiveCutoffsFf <- rc_smoothing_active_cutoffs_ff_sp_thr[0]
    renderSysConfig->>DOM: Set rcSmoothingActiveCutoffsSp <- rc_smoothing_active_cutoffs_ff_sp_thr[1]
    renderSysConfig->>DOM: Set rcSmoothingActiveCutoffsThr <- rc_smoothing_active_cutoffs_ff_sp_thr[2]
  else
    renderSysConfig->>DOM: Legacy handling (unchanged)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 marked this pull request as draft August 15, 2025 11:36
@haslinghuis haslinghuis marked this pull request as ready for review August 15, 2025 11:38
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: 2

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b0449b4 and 77ab0cb.

📒 Files selected for processing (2)
  • index.html (1 hunks)
  • src/header_dialog.js (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/header_dialog.js (3)
src/graph_spectrum.js (1)
  • sysConfig (30-30)
src/graph_config.js (1)
  • sysConfig (232-232)
src/flightlog.js (1)
  • sysConfig (1438-1438)
🔇 Additional comments (1)
index.html (1)

1950-1953: LGTM: explicit id enables precise gating from JS.

Adding id="rcSmoothingFeedforwardHz" is appropriate for the new visibility logic in header_dialog.js.

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 15, 2025
@haslinghuis haslinghuis marked this pull request as draft August 15, 2025 14:47
@sonarqubecloud
Copy link

@haslinghuis haslinghuis marked this pull request as ready for review August 15, 2025 15:43
@github-actions
Copy link

Preview URL: https://e1715b39.betaflight-blackbox.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: 0

♻️ Duplicate comments (1)
src/header_dialog.js (1)

1575-1588: Guard against missing rc_smoothing_active_cutoffs_ff_sp_thr in BF 4.6+ logs (prevent TypeError).

In the 4.6.0+ branch you index sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[0/1]. If BF 4.6 swapped the key to rc_smoothing_active_cutoffs_sp_thr (FF removed), this will be undefined and indexing will throw, breaking renderSysConfig. Use optional chaining and a fallback to the SP/THR-only key.

Apply this diff to make the block robust:

     // RC Smoothing
     if (activeSysConfig.firmwareType === FIRMWARE_TYPE_BETAFLIGHT) {
-      if (semver.gte(activeSysConfig.firmwareVersion, "4.6.0")) {
-        $("#rcSmoothingFeedforwardHz").hide();
-        $("#rcSmoothingActiveCutoffsFf").hide();
-        setParameter("rcSmoothingActiveCutoffsSp", sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[0], 0);
-        setParameter("rcSmoothingActiveCutoffsThr", sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[1], 0);
-      } else if (semver.gte(activeSysConfig.firmwareVersion, "4.3.0")) {
-        setParameter("rcSmoothingFeedforwardHz", sysConfig.rc_smoothing_feedforward_hz, 0);
-        setParameter("rcSmoothingActiveCutoffsFf", sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[0], 0);
-        setParameter("rcSmoothingActiveCutoffsSp", sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[1], 0);
-        setParameter("rcSmoothingActiveCutoffsThr", sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr[2], 0);
-      }
+      // Normalize 4.3–4.5 (FF+SP+THR) vs 4.6+ (SP+THR only)
+      const ffSpThr = sysConfig.rc_smoothing_active_cutoffs_ff_sp_thr;
+      const spThr = sysConfig.rc_smoothing_active_cutoffs_sp_thr;
+      if (semver.gte(activeSysConfig.firmwareVersion, "4.6.0")) {
+        $("#rcSmoothingFeedforwardHz").hide();
+        $("#rcSmoothingActiveCutoffsFf").hide();
+        const arr = Array.isArray(spThr) ? spThr : ffSpThr; // fallback if logs still use old key
+        setParameter("rcSmoothingActiveCutoffsSp", arr?.[0], 0);
+        setParameter("rcSmoothingActiveCutoffsThr", arr?.[1], 0);
+      } else if (semver.gte(activeSysConfig.firmwareVersion, "4.3.0")) {
+        setParameter("rcSmoothingFeedforwardHz", sysConfig.rc_smoothing_feedforward_hz, 0);
+        setParameter("rcSmoothingActiveCutoffsFf", ffSpThr?.[0], 0);
+        setParameter("rcSmoothingActiveCutoffsSp", ffSpThr?.[1], 0);
+        setParameter("rcSmoothingActiveCutoffsThr", ffSpThr?.[2], 0);
+      }
     }
🧹 Nitpick comments (1)
src/header_dialog.js (1)

623-627: Capping rc_smoothing_active_cutoffs_ff to 4.5.999 is correct; consider aligning related caps and normalizing name matching.

  • Good update: BF 4.6+ removed FF active cutoff, so max "4.5.999" is appropriate.
  • Optional: For consistency, also cap "rc_smoothing_feedforward_hz" at "4.5.999" in parameterVersion. You’re already hiding it in UI, but codifying the cap improves discoverability and reduces reliance on ad-hoc DOM gating.
  • Optional: isParameterValid compares parameterVersion snake_case to DOM/caller camelCase (e.g., rcSmoothingActiveCutoffsFf), which makes the caps ineffective for UI-driven visibility. Consider normalizing names in isParameterValid (camelCase → snake_case) once, to make version gating universally reliable.

If you want the canonical fix for isParameterValid, I can prepare a follow-up patch that adds a tiny normalizeName helper and applies it inside isParameterValid.

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a82f3be and e1715b3.

📒 Files selected for processing (2)
  • index.html (2 hunks)
  • src/header_dialog.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • index.html

@ctzsnooze
Copy link
Member

@haslinghuis - this definitely works. Happy for you to merge it when you are ready. Thank you!

@haslinghuis haslinghuis merged commit 1aa54e6 into betaflight:master Aug 16, 2025
5 checks passed
@haslinghuis haslinghuis deleted the ff-cutoff branch August 16, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants