Skip to content

Commit 5b2a328

Browse files
committed
feat: added functionality for Wave Generator
1 parent 53f4102 commit 5b2a328

5 files changed

Lines changed: 139 additions & 37 deletions

File tree

lib/l10n/app_localizations_en.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ class AppLocalizationsEn extends AppLocalizations {
10581058
String get temperatureSensorUnavailableMessage =>
10591059
'Ambient temperature sensor is not available on this device';
10601060

1061+
@override
10611062
String get sharingMessage => 'Sharing PSLab Data';
10621063

10631064
@override
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:pslab/providers/wave_generator_state_provider.dart';
2+
3+
class WaveGeneratorConstants {
4+
static final Map<WaveConst, Map<WaveConst, int>> wave = {
5+
WaveConst.wave1: {
6+
WaveConst.frequency: WaveData.freqMin.value,
7+
WaveConst.waveType: WaveGeneratorStateProvider.sin,
8+
},
9+
WaveConst.wave2: {
10+
WaveConst.phase: WaveData.phaseMin.value,
11+
WaveConst.frequency: WaveData.freqMin.value,
12+
WaveConst.waveType: WaveGeneratorStateProvider.sin,
13+
},
14+
WaveConst.waveType: {},
15+
WaveConst.sqr1: {
16+
WaveConst.frequency: WaveData.freqMin.value,
17+
WaveConst.duty: WaveData.dutyMin.value,
18+
},
19+
WaveConst.sqr2: {
20+
WaveConst.frequency: WaveData.freqMin.value,
21+
WaveConst.phase: WaveData.phaseMin.value,
22+
WaveConst.duty: WaveData.dutyMin.value,
23+
},
24+
WaveConst.sqr3: {
25+
WaveConst.phase: WaveData.phaseMin.value,
26+
WaveConst.duty: WaveData.dutyMin.value,
27+
},
28+
WaveConst.sqr4: {
29+
WaveConst.phase: WaveData.phaseMin.value,
30+
WaveConst.duty: WaveData.dutyMin.value,
31+
},
32+
};
33+
34+
static WaveConst modeSelected = WaveConst.square;
35+
36+
static final Map<String, int> state = {
37+
'SQR1': 0,
38+
'SQR2': 0,
39+
'SQR3': 0,
40+
'SQR4': 0,
41+
};
42+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import 'package:flutter/foundation.dart';
2+
import 'package:pslab/others/wave_generator_constants.dart';
3+
4+
enum WaveConst {
5+
waveType,
6+
wave1,
7+
wave2,
8+
sqr1,
9+
sqr2,
10+
sqr3,
11+
sqr4,
12+
frequency,
13+
phase,
14+
duty,
15+
sine,
16+
triangular,
17+
square,
18+
pwm
19+
}
20+
21+
enum WaveData {
22+
freqMin(10),
23+
dutyMin(0),
24+
phaseMin(0),
25+
freqMax(5000),
26+
phaseMax(360),
27+
dutyMax(100);
28+
29+
final int value;
30+
const WaveData(this.value);
31+
32+
int get getValue => value;
33+
}
34+
35+
class WaveGeneratorStateProvider extends ChangeNotifier {
36+
static final int sin = 1;
37+
static final int triangular = 2;
38+
static final int pwm = 3;
39+
40+
late WaveConst? selectedAnalogWave;
41+
42+
late WaveConst? selectedDigitalWave;
43+
44+
late WaveConst? propSelected;
45+
46+
late WaveGeneratorConstants waveGeneratorConstants;
47+
48+
WaveGeneratorStateProvider() {
49+
selectedAnalogWave = WaveConst.wave1;
50+
51+
selectedDigitalWave = WaveConst.sqr1;
52+
53+
propSelected = null;
54+
55+
waveGeneratorConstants = WaveGeneratorConstants();
56+
}
57+
}

lib/view/wave_generator_screen.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ class _WaveGeneratorScreenState extends State<WaveGeneratorScreen> {
3636
child: Column(
3737
children: [
3838
Expanded(
39-
flex: 70,
4039
child: AnalogWaveformControls(),
4140
),
42-
Expanded(
43-
flex: 30,
41+
IntrinsicHeight(
4442
child: Row(
4543
crossAxisAlignment: CrossAxisAlignment.stretch,
4644
children: [
@@ -57,7 +55,7 @@ class _WaveGeneratorScreenState extends State<WaveGeneratorScreen> {
5755
textAlign: TextAlign.center,
5856
style: TextStyle(
5957
color: Colors.white,
60-
fontSize: 14,
58+
fontSize: 11,
6159
),
6260
),
6361
onPressed: () => {},

lib/view/widgets/analog_waveform_controls.dart

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,48 +27,52 @@ class _AnalogWaveformControlsState extends State<AnalogWaveformControls> {
2727
),
2828
child: Column(
2929
children: [
30-
Row(
31-
children: [
32-
Expanded(
33-
child: TextButton(
34-
style: TextButton.styleFrom(
35-
backgroundColor: primaryRed,
36-
shape: RoundedRectangleBorder(
37-
borderRadius: BorderRadius.circular(6),
30+
Expanded(
31+
child: Row(
32+
crossAxisAlignment: CrossAxisAlignment.stretch,
33+
children: [
34+
Expanded(
35+
child: TextButton(
36+
style: TextButton.styleFrom(
37+
backgroundColor: primaryRed,
38+
shape: RoundedRectangleBorder(
39+
borderRadius: BorderRadius.circular(6),
40+
),
3841
),
39-
),
40-
child: Text(
41-
appLocalizations.wave1,
42-
style: TextStyle(
43-
color: Colors.white,
44-
fontSize: 14,
42+
child: Text(
43+
appLocalizations.wave1,
44+
style: TextStyle(
45+
color: Colors.white,
46+
fontSize: 14,
47+
),
4548
),
49+
onPressed: () => {},
4650
),
47-
onPressed: () => {},
4851
),
49-
),
50-
const SizedBox(width: 4),
51-
Expanded(
52-
child: TextButton(
53-
style: TextButton.styleFrom(
54-
backgroundColor: primaryRed,
55-
shape: RoundedRectangleBorder(
56-
borderRadius: BorderRadius.circular(6),
52+
const SizedBox(width: 4),
53+
Expanded(
54+
child: TextButton(
55+
style: TextButton.styleFrom(
56+
backgroundColor: primaryRed,
57+
shape: RoundedRectangleBorder(
58+
borderRadius: BorderRadius.circular(6),
59+
),
5760
),
58-
),
59-
child: Text(
60-
appLocalizations.wave2,
61-
style: TextStyle(
62-
color: Colors.white,
63-
fontSize: 14,
61+
child: Text(
62+
appLocalizations.wave2,
63+
style: TextStyle(
64+
color: Colors.white,
65+
fontSize: 14,
66+
),
6467
),
68+
onPressed: () => {},
6569
),
66-
onPressed: () => {},
6770
),
68-
),
69-
],
71+
],
72+
),
7073
),
71-
IntrinsicHeight(
74+
const SizedBox(height: 4),
75+
Expanded(
7276
child: Row(
7377
crossAxisAlignment: CrossAxisAlignment.stretch,
7478
children: [

0 commit comments

Comments
 (0)