Skip to content

Revert "Added Power Spectral Density curves at the spectrum chart (Completion of #820 PR)" #830

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 1 commit into from
May 13, 2025

Conversation

demvlad
Copy link
Contributor

@demvlad demvlad commented May 13, 2025

Reverts #826

The all looks good, but it exists some issues.
It needs testing. Will resolved soon.

Summary by CodeRabbit

  • New Features

    • None.
  • Bug Fixes

    • None.
  • Refactor

    • Removed the Power Spectral Density (PSD) option from the spectrum type dropdown and all related PSD calculation and display functionality. The app no longer supports viewing or analyzing Power Spectral Density graphs.
  • Style

    • Adjusted label text and background color transparency for improved graph appearance.

Copy link

coderabbitai bot commented May 13, 2025

Walkthrough

The changes remove all functionality, UI elements, and code related to the Power Spectral Density (PSD) spectrum type. This includes eliminating the PSD option from the dropdown menu, deleting PSD data loading and calculation methods, and removing PSD rendering logic from the spectrum graph.

Changes

Files/Paths Change Summary
index.html Removed "Power spectral density" option from the spectrum type dropdown in the analyzer section.
src/graph_spectrum.js Removed handling of the POWER_SPECTRAL_DENSITY spectrum type in data loading and Y-axis zoom logic.
src/graph_spectrum_calc.js Deleted all PSD computation methods and helpers; simplified sample frequency method.
src/graph_spectrum_plot.js Removed all PSD-related rendering, constants, and methods; updated grid lines and marker labeling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant SpectrumLogic
    participant Plot

    User->>UI: Select spectrum type
    UI->>SpectrumLogic: Request data for selected type
    SpectrumLogic->>Plot: Provide data for rendering
    Plot->>UI: Render spectrum graph

    Note over UI,Plot: PSD spectrum type and related flows are now removed
Loading

Possibly related PRs

Suggested labels

RN: IMPROVEMENT

Suggested reviewers

  • haslinghuis

Poem

A hop, a skip, a code refactor,
The PSD’s gone—no need to track her!
Dropdowns lighter, graphs more lean,
The spectrum’s clear, the code is clean.
With every merge, a bunny cheers,
For tidier graphs in future years! 🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1480a62 and 2a5e238.

📒 Files selected for processing (4)
  • index.html (0 hunks)
  • src/graph_spectrum.js (0 hunks)
  • src/graph_spectrum_calc.js (2 hunks)
  • src/graph_spectrum_plot.js (6 hunks)
💤 Files with no reviewable changes (2)
  • index.html
  • src/graph_spectrum.js
🔇 Additional comments (8)
src/graph_spectrum_calc.js (1)

286-296: Method simplified by removing the scaled parameter

This change simplifies the _getFlightSamplesFreq method by removing the previously added scaled parameter and always applying the curve lookup to raw frame data. This is consistent with reverting the PSD functionality that was added in PR #826.

src/graph_spectrum_plot.js (7)

15-20: LGTM: Enum simplified by removing POWER_SPECTRAL_DENSITY type

The SPECTRUM_TYPE enum now only contains frequency, frequency vs throttle, PID error vs setpoint, and frequency vs RPM types, which is consistent with the removal of the PSD functionality.


297-297: Minor formatting fix

This is just a formatting adjustment for consistency, aligning parameters by removing a trailing comma.


307-307: Minor label update

Changed parameter to correctly display "Hz" as the unit label.


865-865: Label renamed from "Max noise" to "Max motor noise"

This provides more descriptive context about what kind of noise is being highlighted in the spectrum graph.


996-1012: Method simplified by using fixed tick count

The _drawVerticalGridLines method has been simplified to:

  1. Always use 5 ticks instead of accepting a variable amount
  2. Change parameter from ticks to label for clarity
  3. Simplify the vertical grid line calculation

This change makes the code more consistent and easier to maintain after removing the PSD functionality.


1132-1133: Background color adjustment for fullscreen mode

The gradient background color stops for fullscreen mode were adjusted to use slightly more transparent black colors (rgba(0,0,0,0.9) and rgba(0,0,0,0.7)), which should improve visibility of graph elements.


1362-1362: Minor formatting fix for condition check

Simple formatting adjustment for the spectrum type comparison.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Preview URL: https://4f172a30.betaflight-blackbox.pages.dev

Copy link

@haslinghuis
Copy link
Member

Just to be sure @demvlad @nerdCopter this should revert too ?

@haslinghuis haslinghuis added this to the 4.0.0 milestone May 13, 2025
@nerdCopter
Copy link
Member

Just to be sure @demvlad @nerdCopter this should revert too ?

i do not personally know. i did not test this one, but other functions seem to still work with it merged. did not test this code whatsoever.

@demvlad
Copy link
Contributor Author

demvlad commented May 13, 2025

I think, this PR and about slice PR can revert.
The reasons:

  • give to users reliable working BBE in master.
  • i've pushed PR to solve hang issue, but it needs test some time. And my other PSD ws rpm PR will need big rebase too.
    I need join 3 PR and test it by using power 2 size fft input. It exists some question too. Let's master branch will work free this time.

@haslinghuis haslinghuis merged commit 6eb3711 into betaflight:master May 13, 2025
4 checks passed
@demvlad
Copy link
Contributor Author

demvlad commented Jun 3, 2025

@coderabbitai
Has our FFT lib inverted FFT transform?

Copy link

coderabbitai bot commented Jun 3, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@demvlad Let me search the codebase to see what FFT library is being used and whether it supports inverse FFT transform.


🏁 Script executed:

#!/bin/bash
# Search for FFT-related imports, libraries, and usage
echo "=== Searching for FFT imports and libraries ==="
rg -i "import.*fft|require.*fft|from.*fft" --type js

echo -e "\n=== Searching for FFT function definitions and usage ==="
rg -i "fft|fourier" --type js -A 3 -B 1

echo -e "\n=== Checking package.json for FFT dependencies ==="
if [ -f "package.json" ]; then
    cat package.json | jq '.dependencies, .devDependencies' | grep -i fft || echo "No FFT dependencies found in package.json"
else
    echo "No package.json found"
fi

echo -e "\n=== Searching for inverse FFT functionality ==="
rg -i "ifft|inverse.*fft|fft.*inverse" --type js -A 2 -B 1

echo -e "\n=== Looking for any FFT library files ==="
fd -t f -e js | xargs grep -l -i "fft" | head -10

Length of output: 33019


🏁 Script executed:

#!/bin/bash
# Examine the FFT library implementation files
echo "=== Examining FFT complex.js library ==="
cat public/js/complex.js

echo -e "\n=== Examining FFT real.js library ==="
cat public/js/real.js

echo -e "\n=== Checking how FFT is used in the codebase ==="
rg "new FFT\." --type js -A 2 -B 1

Length of output: 23198


@demvlad Yes, your FFT library does support inverse FFT transform!

Based on my examination of the FFT implementation in public/js/complex.js and public/js/real.js, I can see that:

FFT.complex constructor supports inverse transforms:

var complex = function (n, inverse) {
    // ...
    var state = {
        n: n,
        inverse: inverse,  // This flag controls forward vs inverse
        // ...
    }
}

The library includes inverse logic in the butterfly functions:

if (state.inverse) {
    var r1_r = i1_r - i3_i
    var r1_i = i1_i + i3_r
} else {
    var r1_r = i1_r + i3_i
    var r1_i = i1_i - i3_r
}

Usage examples:

  • Forward FFT: new FFT.complex(length, false)
  • Inverse FFT: new FFT.complex(length, true)

Current usage in your codebase:
The code currently only uses forward FFT transforms:

const fft = new FFT.complex(fftChunkLength, false);  // false = forward FFT
const fft = new FFT.complex(fftLength, false);       // false = forward FFT  

So if you need inverse FFT for your PSD implementation or other signal processing work, you can simply change the second parameter from false to true when creating the FFT instance.

@demvlad
Copy link
Contributor Author

demvlad commented Jun 3, 2025

@coderabbitai thank's
i need inverted fft for next PRs.

Copy link

coderabbitai bot commented Jun 3, 2025

Tip

For best results, initiate chat on the files or code changes.

@demvlad You're welcome! That's great to hear that you'll be able to use the inverse FFT functionality for your upcoming PRs.

Feel free to tag me when you're working on those future implementations - I'd be happy to help review the inverse FFT usage or assist with any signal processing questions that come up during development.

Good luck with your PSD and other signal analysis work! 🐇

 (\   /)
( ._.)

o_(")(") thoughtful rabbit learning new FFT tricks

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.

3 participants