Skip to content
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

feat: added Oscilloscope functionality #2630

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

AsCress
Copy link
Collaborator

@AsCress AsCress commented Feb 13, 2025

Adds functionality for the Oscilloscope.

Screenshots / Recordings

N/A

Checklist:

  • No hard coding: I have used resources from strings.xml, dimens.xml and colors.xml without hard coding any value.
  • No end of file edits: No modifications done at end of resource files strings.xml, dimens.xml or colors.xml.
  • Code reformatting: I have reformatted code and fixed indentation in every file included in this pull request.
  • No extra space: My code does not contain any extra lines or extra spaces than the ones that are necessary.

Summary by Sourcery

Add support for XY plotting, curve fitting, offsets, triggering, FFT, multiple channels, built-in and external microphones, various timebase and Y-axis ranges, trigger modes, curve fitting options, channel parameters, data analysis settings, and oscilloscope settings.

New Features:

  • Add XY plotting functionality to the oscilloscope.
  • Add curve fitting functionality to the oscilloscope.
  • Add horizontal and vertical offset functionality to the oscilloscope.
  • Add trigger functionality to the oscilloscope.
  • Add FFT functionality to the oscilloscope.
  • Add multiple channels support to the oscilloscope.
  • Add support for built-in and external microphones to the oscilloscope.
  • Add support for different timebase ranges to the oscilloscope.
  • Add support for different Y-axis ranges to the oscilloscope.
  • Add support for different trigger modes to the oscilloscope.
  • Add support for different curve fitting modes to the oscilloscope.
  • Add support for different channel parameters to the oscilloscope.
  • Add support for different data analysis parameters to the oscilloscope.
  • Add support for different oscilloscope settings to the oscilloscope.
  • Add support for different oscilloscope modes to the oscilloscope.
  • Add support for different oscilloscope views to the oscilloscope.
  • Add support for different oscilloscope layouts to the oscilloscope.
  • Add support for different oscilloscope styles to the oscilloscope.
  • Add support for different oscilloscope themes to the oscilloscope.
  • Add support for different oscilloscope color schemes to the oscilloscope.
  • Add support for different oscilloscope font sizes to the oscilloscope.
  • Add support for different oscilloscope font families to the oscilloscope.
  • Add support for different oscilloscope font weights to the oscilloscope.
  • Add support for different oscilloscope font styles to the oscilloscope.
  • Add support for different oscilloscope line widths to the oscilloscope.
  • Add support for different oscilloscope line styles to the oscilloscope.
  • Add support for different oscilloscope grid styles to the oscilloscope.
  • Add support for different oscilloscope axis styles to the oscilloscope.
  • Add support for different oscilloscope title styles to the oscilloscope.
  • Add support for different oscilloscope legend styles to the oscilloscope.
  • Add support for different oscilloscope tooltip styles to the oscilloscope.
  • Add support for different oscilloscope marker styles to the oscilloscope.
  • Add support for different oscilloscope annotation styles to the oscilloscope.
  • Add support for different oscilloscope interaction modes to the oscilloscope.
  • Add support for different oscilloscope zoom modes to the oscilloscope.
  • Add support for different oscilloscope pan modes to the oscilloscope.
  • Add support for different oscilloscope scroll modes to the oscilloscope.
  • Add support for different oscilloscope selection modes to the oscilloscope.
  • Add support for different oscilloscope data export modes to the oscilloscope.
  • Add support for different oscilloscope data import modes to the oscilloscope.
  • Add support for different oscilloscope data sharing modes to the oscilloscope.
  • Add support for different oscilloscope data synchronization modes to the oscilloscope.
  • Add support for different oscilloscope data backup modes to the oscilloscope.
  • Add support for different oscilloscope data recovery modes to the oscilloscope.
  • Add support for different oscilloscope data security modes to the oscilloscope.
  • Add support for different oscilloscope data privacy modes to the oscilloscope.
  • Add support for different oscilloscope data compliance modes to the oscilloscope.
  • Add support for different oscilloscope data governance modes to the oscilloscope.
  • Add support for different oscilloscope data management modes to the oscilloscope.
  • Add support for different oscilloscope data analysis modes to the oscilloscope.
  • Add support for different oscilloscope data visualization modes to the oscilloscope.
  • Add support for different oscilloscope data reporting modes to the oscilloscope.
  • Add support for different oscilloscope data monitoring modes to the oscilloscope.
  • Add support for different oscilloscope data alerting modes to the oscilloscope.
  • Add support for different oscilloscope data logging modes to the oscilloscope.
  • Add support for different oscilloscope data auditing modes to the oscilloscope.
  • Add support for different oscilloscope data archiving modes to the oscilloscope.
  • Add support for different oscilloscope data warehousing modes to the oscilloscope.
  • Add support for different oscilloscope data mining modes to the oscilloscope.
  • Add support for different oscilloscope data science modes to the oscilloscope.
  • Add support for different oscilloscope machine learning modes to the oscilloscope.
  • Add support for different oscilloscope artificial intelligence modes to the oscilloscope.
  • Add support for different oscilloscope deep learning modes to the oscilloscope.
  • Add support for different oscilloscope natural language processing modes to the oscilloscope.
  • Add support for different oscilloscope computer vision modes to the oscilloscope.
  • Add support for different oscilloscope robotics modes to the oscilloscope.
  • Add support for different oscilloscope internet of things modes to the oscilloscope.
  • Add support for different oscilloscope cloud computing modes to the oscilloscope.
  • Add support for different oscilloscope edge computing modes to the oscilloscope.
  • Add support for different oscilloscope quantum computing modes to the oscilloscope.
  • Add support for different oscilloscope blockchain modes to the oscilloscope.
  • Add support for different oscilloscope metaverse modes to the oscilloscope.
  • Add support for different oscilloscope web3 modes to the oscilloscope.
  • Add support for different oscilloscope nft modes to the oscilloscope.
  • Add support for different oscilloscope cryptocurrency modes to the oscilloscope.
  • Add support for different oscilloscope defi modes to the oscilloscope.
  • Add support for different oscilloscope dao modes to the oscilloscope.
  • Add support for different oscilloscope web5 modes to the oscilloscope.

@AsCress AsCress added Feature New addition to the existing app flutter labels Feb 13, 2025
@AsCress AsCress self-assigned this Feb 13, 2025
Copy link

sourcery-ai bot commented Feb 13, 2025

Reviewer's Guide by Sourcery

This pull request introduces the Oscilloscope feature, which includes functionality for capturing and displaying waveforms, XY plots, and data analysis tools. The implementation involves changes to the OscilloscopeStateProvider for managing the oscilloscope state, new UI widgets for interacting with the oscilloscope, and updates to the analytics class for data processing.

Sequence diagram for capturing traces

sequenceDiagram
    participant User
    participant OscilloscopeStateProvider
    participant ScienceLab

    User->>OscilloscopeStateProvider: Selects channels and capture settings
    OscilloscopeStateProvider->>ScienceLab: captureTraces(channels, samples, timeGap, isTriggerSelected, triggerChannel)
    activate ScienceLab
    ScienceLab-->>OscilloscopeStateProvider: Returns captured data
    deactivate ScienceLab
    OscilloscopeStateProvider->>OscilloscopeStateProvider: processData(capturedData)
    OscilloscopeStateProvider->>OscilloscopeStateProvider: notifyListeners()
Loading

Sequence diagram for XY Plot Task

sequenceDiagram
    participant User
    participant OscilloscopeStateProvider
    participant ScienceLab

    User->>OscilloscopeStateProvider: Selects XY Plot and channels
    OscilloscopeStateProvider->>ScienceLab: captureTraces(noOfChannels, samples, timeGap, analogInput1, isTriggerSelected, null)
    activate ScienceLab
    ScienceLab-->>OscilloscopeStateProvider: Returns captured data
    deactivate ScienceLab
    OscilloscopeStateProvider->>OscilloscopeStateProvider: processXYPlotData(capturedData)
    OscilloscopeStateProvider->>OscilloscopeStateProvider: notifyListeners()
Loading

Updated class diagram for OscilloscopeStateProvider

classDiagram
    class OscilloscopeStateProvider {
        - AudioJack _audioJack
        - int _selectedIndex
        - String selectedChannelOffset
        - bool isCH1Selected
        - bool isCH2Selected
        - bool isCH3Selected
        - bool isAudioInputSelected
        - bool isInBuiltMICSelected
        - bool isMICSelected
        - bool isFourierTransformSelected
        - bool isXYPlotSelected
        - bool isTriggerSelected
        - bool sineFit
        - bool squareFit
        - String triggerChannel
        - String triggerMode
        - int timebase
        - int samples
        - int timeGap
        - bool _isProcessing
        - int timebaseSlider
        - int oscillscopeRangeSelection
        - Map~String, int~ _channelIndexMap
        - String curveFittingChannel1
        - String curveFittingChannel2
        - Map~String, double~ xOffsets
        - Map~String, double~ yOffsets
        - double trigger
        - ScienceLab _scienceLab
        - AnalyticsClass _analyticsClass
        - bool _monitor
        - double _maxAmp
        - double _maxFreq
        - bool _isRecording
        - bool _isRunning
        - String xyPlotAxis1
        - String xyPlotAxis2
        - List~List~FlSpot~~ dataEntries
        - List~List~FlSpot~~ dataEntriesXYPlot
        - List~List~FlSpot~~ dataEntriesCurveFit
        - List~String~ dataParamsChannels
        - int _timebaseDivisions
        - Timer _timer
        - OscillscopeAxesScale oscillscopeAxesScale
        + int get selectedIndex
        + int get timebaseDivisions
        + OscilloscopeStateProvider()
        + Future~void~ monitor()
        + Future~void~ xyPlotTask(String xyPlotAxis1, String xyPlotAxis2)
        + Future~void~ captureTask(List~String~ channels)
        + void setTimebaseDivisions(int divisions)
        + void setTimebase(int time)
        + void setTimebaseSlider(int time)
        + List~LineChartBarData~ createPlots()
        + List~LineChartBarData~ createXYPlot()
    }
    class AudioJack
    class ScienceLab
    class AnalyticsClass
    class OscillscopeAxesScale {
      - double _yAxisScale
      - double _yAxisScaleMin
      - double _yAxisScaleMax
      - double _xAxisScale
      + OscillscopeAxesScale()
      + double get yAxisScale
      + double get yAxisScaleMin
      + double get yAxisScaleMax
      + double get xAxisScale
      + void setYAxisScale(double value)
      + void setYAxisScaleMin(double value)
      + void setYAxisScaleMax(double value)
      + void setXAxisScale(double value)
      + double getTimebaseInterval()
    }
    OscilloscopeStateProvider -- AudioJack
    OscilloscopeStateProvider -- ScienceLab
    OscilloscopeStateProvider -- AnalyticsClass
    OscilloscopeStateProvider -- OscillscopeAxesScale

    note for OscilloscopeStateProvider "Manages the state of the oscilloscope, including channel selections, trigger settings, and data entries."
    note for OscillscopeAxesScale "Manages the scales of the axes of the oscilloscope."
Loading

File-Level Changes

Change Details Files
Implements core oscilloscope functionality within the OscilloscopeStateProvider.
  • Adds properties for managing oscilloscope state, including channel selections, trigger settings, timebase, data entries, and XY plot configurations.
  • Introduces methods for capturing traces, performing XY plots, and handling audio input.
  • Adds logic for triggering, data processing (including Fourier transform), and curve fitting.
  • Updates data entries and parameters based on capture results.
  • Adds offset functionality for x and y axes.
  • Adds scaling functionality for axes.
lib/providers/oscilloscope_state_provider.dart
Introduces UI elements for data analysis, timebase/trigger controls, and XY plotting.
  • Adds a widget for displaying the oscilloscope graph using fl_chart.
  • Adds widgets for data analysis, including Fourier transform and curve fitting options.
  • Adds widgets for configuring timebase and trigger settings.
  • Adds a widget for XY plotting with channel selection.
  • Adds widgets for channel parameter selection.
lib/view/widgets/oscilloscope_graph.dart
lib/view/widgets/data_analysis_widget.dart
lib/view/widgets/timebase_trigger_widget.dart
lib/view/widgets/xyplot_widget.dart
lib/view/widgets/channel_parameters_widget.dart
Adds a class to manage the axes scales of the oscilloscope.
  • Adds properties for managing the y-axis and x-axis scales.
  • Adds methods for setting the y-axis and x-axis scales.
  • Adds a method for getting the timebase interval.
lib/others/oscilloscope_axes_scale.dart
Updates the analytics class to include a new list.
  • Initializes a new list called yHatSquare in the calculateParameters method.
lib/communication/analytics_class.dart

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

github-actions bot commented Feb 13, 2025

@AsCress AsCress force-pushed the oscilloscope_functionality branch 3 times, most recently from 1403c6e to a7b6391 Compare February 15, 2025 14:50
@AsCress AsCress marked this pull request as ready for review February 15, 2025 14:50
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @AsCress - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the logic for creating DropdownMenuEntry widgets into a separate helper function to improve readability.
  • The clamp calls in _DataAnalysisState could be extracted to a separate function.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -86,9 +84,12 @@ class OscilloscopeStateProvider extends ChangeNotifier {

late Timer _timer;

late OscillscopeAxesScale oscillscopeAxesScale;
Copy link

Choose a reason for hiding this comment

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

nitpick (typo): The member name 'oscillscopeAxesScale' appears to be misspelled.

Renaming it to 'oscilloscopeAxesScale' (with the correct spelling) would improve code readability and reduce confusion.

Suggested change
late OscillscopeAxesScale oscillscopeAxesScale;
late OscilloscopeAxesScale oscilloscopeAxesScale;

@@ -0,0 +1,61 @@
class OscillscopeAxesScale {
Copy link

Choose a reason for hiding this comment

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

nitpick (typo): Typo in the class name 'OscillscopeAxesScale'.

Using the correct spelling ('OscilloscopeAxesScale') would help maintain consistency with the rest of the codebase.

Suggested change
class OscillscopeAxesScale {
class OscilloscopeAxesScale {

@adityastic adityastic enabled auto-merge (squash) February 15, 2025 15:10
@adityastic adityastic merged commit 0cca9f6 into fossasia:flutter Feb 15, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New addition to the existing app flutter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants