Skip to content

Commit e241b2c

Browse files
rahul31124marcnause
authored andcommitted
feat added saw_tooth_wave
1 parent b9e4f70 commit e241b2c

25 files changed

Lines changed: 167 additions & 34 deletions

assets/icons/ic_sawtooth.png

2.97 KB
Loading

lib/communication/science_lab.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ class ScienceLab {
346346

347347
Future<void> loadEquation(String channel, String function) async {
348348
List<double> span = List.filled(2, 0);
349+
349350
if (function == 'sine') {
350351
span[0] = 0;
351352
span[1] = 2 * pi;
@@ -354,21 +355,31 @@ class ScienceLab {
354355
span[0] = 0;
355356
span[1] = 4;
356357
waveType[channel] = 'tria';
358+
} else if (function == 'sawtooth') {
359+
span[0] = 0;
360+
span[1] = 2 * pi;
361+
waveType[channel] = 'sawtooth';
357362
} else {
358363
waveType[channel] = 'orbit';
359364
}
365+
360366
double factor = (span[1] - span[0]) / 512;
361367
List<double> x = [];
362368
List<double> y = [];
369+
363370
for (int i = 0; i < 512; i++) {
364371
x.add(span[0] + i * factor);
372+
365373
switch (function) {
366374
case 'sine':
367375
y.add(sin(x[i]));
368376
break;
369377
case 'tria':
370378
y.add((x[i] % 4 - 2).abs());
371379
break;
380+
case 'sawtooth':
381+
y.add((x[i] / pi) - 1.0);
382+
break;
372383
default:
373384
break;
374385
}
@@ -1082,12 +1093,12 @@ class ScienceLab {
10821093
}
10831094

10841095
if (waveType != null) {
1085-
if (waveType == "sine" || waveType == "tria") {
1096+
if (waveType == "sine" || waveType == "tria" || waveType == "sawtooth") {
10861097
if (this.waveType["SI1"] != waveType) {
10871098
loadEquation("SI1", waveType);
10881099
}
10891100
} else {
1090-
logger.e("Not a valid waveform. try sine or tria");
1101+
logger.e("Not a valid waveform. try sine, tria, or sawtooth");
10911102
}
10921103
}
10931104

@@ -1139,12 +1150,12 @@ class ScienceLab {
11391150
}
11401151

11411152
if (waveType != null) {
1142-
if (waveType == "sine" || waveType == "tria") {
1153+
if (waveType == "sine" || waveType == "tria" || waveType == "sawtooth") {
11431154
if (this.waveType["SI2"] != waveType) {
11441155
loadEquation("SI2", waveType);
11451156
}
11461157
} else {
1147-
logger.e("Not a valid waveform. try sine or tria");
1158+
logger.e("Not a valid waveform. try sine, tria, or sawtooth");
11481159
}
11491160
}
11501161

lib/l10n/app_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,5 +664,6 @@
664664
"pin_cap_desc": "Capacitance Measurement Pin",
665665
"pin_res_name": "RES",
666666
"pin_res_desc": "Resistance Measurement Pin",
667-
"stopSound" : "Stop Sound"
667+
"stopSound" : "Stop Sound",
668+
"saw" : "Saw"
668669
}

lib/l10n/app_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4109,6 +4109,12 @@ abstract class AppLocalizations {
41094109
/// In en, this message translates to:
41104110
/// **'Stop Sound'**
41114111
String get stopSound;
4112+
4113+
/// No description provided for @saw.
4114+
///
4115+
/// In en, this message translates to:
4116+
/// **'Saw'**
4117+
String get saw;
41124118
}
41134119

41144120
class _AppLocalizationsDelegate

lib/l10n/app_localizations_de.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,4 +2158,7 @@ class AppLocalizationsDe extends AppLocalizations {
21582158

21592159
@override
21602160
String get stopSound => 'Stop Sound';
2161+
2162+
@override
2163+
String get saw => 'Saw';
21612164
}

lib/l10n/app_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,4 +2158,7 @@ class AppLocalizationsEn extends AppLocalizations {
21582158

21592159
@override
21602160
String get stopSound => 'Stop Sound';
2161+
2162+
@override
2163+
String get saw => 'Saw';
21612164
}

lib/l10n/app_localizations_es.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,4 +2158,7 @@ class AppLocalizationsEs extends AppLocalizations {
21582158

21592159
@override
21602160
String get stopSound => 'Stop Sound';
2161+
2162+
@override
2163+
String get saw => 'Saw';
21612164
}

lib/l10n/app_localizations_fr.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,4 +2158,7 @@ class AppLocalizationsFr extends AppLocalizations {
21582158

21592159
@override
21602160
String get stopSound => 'Stop Sound';
2161+
2162+
@override
2163+
String get saw => 'Saw';
21612164
}

lib/l10n/app_localizations_he.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,4 +2158,7 @@ class AppLocalizationsHe extends AppLocalizations {
21582158

21592159
@override
21602160
String get stopSound => 'Stop Sound';
2161+
2162+
@override
2163+
String get saw => 'Saw';
21612164
}

lib/l10n/app_localizations_hi.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,4 +2158,7 @@ class AppLocalizationsHi extends AppLocalizations {
21582158

21592159
@override
21602160
String get stopSound => 'Stop Sound';
2161+
2162+
@override
2163+
String get saw => 'Saw';
21612164
}

0 commit comments

Comments
 (0)