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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/communication/analytics_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AnalyticsClass {

complex = fft(yReal2.map((x) => Complex(x)).toList());
yHat = fftToRfft(complex);
yHatSquare = List<double>.filled(yHat.length, 0);
for (int i = 0; i < yHat.length; i++) {
yHatSquare[i] = pow(yHat[i], 2).toDouble();
if (yHatSquare[i] > maximum) {
Expand Down Expand Up @@ -125,7 +126,7 @@ class AnalyticsClass {
}

double amplitude = (sumGreaterThanOffset / n1) - (sumLesserThanOffset / n2);
List<bool> bools = [];
List<bool> bools = List.filled(yTmp.length - 1, false);
double tmp;
for (int i = 0; i < yTmp.length - 1; i++) {
tmp = yTmp[i + 1] - yTmp[i];
Expand Down
61 changes: 61 additions & 0 deletions lib/others/oscilloscope_axes_scale.dart
Original file line number Diff line number Diff line change
@@ -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 {

late double _yAxisScale;
late double _yAxisScaleMin;
late double _yAxisScaleMax;
late double _xAxisScale;

OscillscopeAxesScale() {
_yAxisScale = 16;
_yAxisScaleMin = -16;
_yAxisScaleMax = 16;
_xAxisScale = 875;
}

double get yAxisScale => _yAxisScale;
double get yAxisScaleMin => _yAxisScaleMin;
double get yAxisScaleMax => _yAxisScaleMax;
double get xAxisScale => _xAxisScale;

void setYAxisScale(double value) {
_yAxisScale = value;
_yAxisScaleMax = value;
_yAxisScaleMin = -value;
}

void setYAxisScaleMin(double value) {
_yAxisScaleMin = value;
}

void setYAxisScaleMax(double value) {
_yAxisScaleMax = value;
}

void setXAxisScale(double value) {
_xAxisScale = value;
}

double getTimebaseInterval() {
switch (_xAxisScale) {
case 875.00:
return 100;
case 1000.00:
return 0.2;
case 2000.00:
return 0.3;
case 4000.00:
return 0.7;
case 8000.00:
return 1;
case 25600.00:
return 4;
case 38400.00:
return 10;
case 51200.00:
return 10;
case 102400.00:
return 20;
default:
return _xAxisScale / 5000;
}
}
}
Loading