Skip to content

Commit da43abd

Browse files
Yugesh-Kumar-SAsCressmarcnause
authored
feat: Added experiment framework and created light intensity vs distance experiment. (#2857)
Co-authored-by: Anashuman Singh <anash.cheema@gmail.com> Co-authored-by: Marc Nause <marc.nause@audioattack.de>
1 parent 4339d62 commit da43abd

18 files changed

+1124
-23
lines changed

assets/images/lightDistance1.gif

2.34 MB
Loading

assets/images/lightDistance2.gif

1.09 MB
Loading

assets/images/lightDistance3.gif

602 KB
Loading

lib/l10n/app_en.arb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,26 @@
444444
"time" : "Time",
445445
"notAvailable" : "N/A",
446446
"estimated" : "Estimated",
447+
"experiments" : "Experiments",
448+
"startExperiment" : "Start Experiment",
449+
"lightIntensityVsDistance" : "Light Intensity vs Distance",
450+
"lightIntensityVsDistanceDesc" : "Measure how light intensity changes with distance from the source",
451+
"stepCompleted" : "Step Completed!",
452+
"endExperiment" : "End Experiment",
453+
"next" : "Next",
454+
"previous" : "Previous",
455+
"step" : "Step",
456+
"experimentCompleted" : "Experiment Completed",
457+
"setUp": "Setup",
458+
"lightExperimentSetUpContent" : "Place your device near a light source (lamp, window, or flashlight).",
459+
"preparation" : "Preparation",
460+
"lightExperimentPreparationContent" : "Make sure you have space to move towards the light source gradually.",
461+
"instructions" : "Instructions",
462+
"lightExperimentInstructionContent" : "You will measure light intensity at different distances. Follow the on-screen prompts to move closer or farther from the light source.",
463+
"moveTowardsLight" : "Move towards the light source",
464+
"moveAwayFromLight" : "Move away from the light source",
465+
"holdPosition" : "Hold your position and let the reading stabilize",
466+
"followInstructions" : "Follow the on-screen instructions to set up your experiment.",
447467
"gesture" : "Gesture",
448468
"blueLabel" : "Blue",
449469
"greenLabel" : "Green",

lib/l10n/app_localizations.dart

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,6 +2790,126 @@ abstract class AppLocalizations {
27902790
/// **'Estimated'**
27912791
String get estimated;
27922792

2793+
/// No description provided for @experiments.
2794+
///
2795+
/// In en, this message translates to:
2796+
/// **'Experiments'**
2797+
String get experiments;
2798+
2799+
/// No description provided for @startExperiment.
2800+
///
2801+
/// In en, this message translates to:
2802+
/// **'Start Experiment'**
2803+
String get startExperiment;
2804+
2805+
/// No description provided for @lightIntensityVsDistance.
2806+
///
2807+
/// In en, this message translates to:
2808+
/// **'Light Intensity vs Distance'**
2809+
String get lightIntensityVsDistance;
2810+
2811+
/// No description provided for @lightIntensityVsDistanceDesc.
2812+
///
2813+
/// In en, this message translates to:
2814+
/// **'Measure how light intensity changes with distance from the source'**
2815+
String get lightIntensityVsDistanceDesc;
2816+
2817+
/// No description provided for @stepCompleted.
2818+
///
2819+
/// In en, this message translates to:
2820+
/// **'Step Completed!'**
2821+
String get stepCompleted;
2822+
2823+
/// No description provided for @endExperiment.
2824+
///
2825+
/// In en, this message translates to:
2826+
/// **'End Experiment'**
2827+
String get endExperiment;
2828+
2829+
/// No description provided for @next.
2830+
///
2831+
/// In en, this message translates to:
2832+
/// **'Next'**
2833+
String get next;
2834+
2835+
/// No description provided for @previous.
2836+
///
2837+
/// In en, this message translates to:
2838+
/// **'Previous'**
2839+
String get previous;
2840+
2841+
/// No description provided for @step.
2842+
///
2843+
/// In en, this message translates to:
2844+
/// **'Step'**
2845+
String get step;
2846+
2847+
/// No description provided for @experimentCompleted.
2848+
///
2849+
/// In en, this message translates to:
2850+
/// **'Experiment Completed'**
2851+
String get experimentCompleted;
2852+
2853+
/// No description provided for @setUp.
2854+
///
2855+
/// In en, this message translates to:
2856+
/// **'Setup'**
2857+
String get setUp;
2858+
2859+
/// No description provided for @lightExperimentSetUpContent.
2860+
///
2861+
/// In en, this message translates to:
2862+
/// **'Place your device near a light source (lamp, window, or flashlight).'**
2863+
String get lightExperimentSetUpContent;
2864+
2865+
/// No description provided for @preparation.
2866+
///
2867+
/// In en, this message translates to:
2868+
/// **'Preparation'**
2869+
String get preparation;
2870+
2871+
/// No description provided for @lightExperimentPreparationContent.
2872+
///
2873+
/// In en, this message translates to:
2874+
/// **'Make sure you have space to move towards the light source gradually.'**
2875+
String get lightExperimentPreparationContent;
2876+
2877+
/// No description provided for @instructions.
2878+
///
2879+
/// In en, this message translates to:
2880+
/// **'Instructions'**
2881+
String get instructions;
2882+
2883+
/// No description provided for @lightExperimentInstructionContent.
2884+
///
2885+
/// In en, this message translates to:
2886+
/// **'You will measure light intensity at different distances. Follow the on-screen prompts to move closer or farther from the light source.'**
2887+
String get lightExperimentInstructionContent;
2888+
2889+
/// No description provided for @moveTowardsLight.
2890+
///
2891+
/// In en, this message translates to:
2892+
/// **'Move towards the light source'**
2893+
String get moveTowardsLight;
2894+
2895+
/// No description provided for @moveAwayFromLight.
2896+
///
2897+
/// In en, this message translates to:
2898+
/// **'Move away from the light source'**
2899+
String get moveAwayFromLight;
2900+
2901+
/// No description provided for @holdPosition.
2902+
///
2903+
/// In en, this message translates to:
2904+
/// **'Hold your position and let the reading stabilize'**
2905+
String get holdPosition;
2906+
2907+
/// No description provided for @followInstructions.
2908+
///
2909+
/// In en, this message translates to:
2910+
/// **'Follow the on-screen instructions to set up your experiment.'**
2911+
String get followInstructions;
2912+
27932913
/// No description provided for @gesture.
27942914
///
27952915
/// In en, this message translates to:

lib/l10n/app_localizations_en.dart

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,71 @@ class AppLocalizationsEn extends AppLocalizations {
14451445
@override
14461446
String get estimated => 'Estimated';
14471447

1448+
@override
1449+
String get experiments => 'Experiments';
1450+
1451+
@override
1452+
String get startExperiment => 'Start Experiment';
1453+
1454+
@override
1455+
String get lightIntensityVsDistance => 'Light Intensity vs Distance';
1456+
1457+
@override
1458+
String get lightIntensityVsDistanceDesc =>
1459+
'Measure how light intensity changes with distance from the source';
1460+
1461+
@override
1462+
String get stepCompleted => 'Step Completed!';
1463+
1464+
@override
1465+
String get endExperiment => 'End Experiment';
1466+
1467+
@override
1468+
String get next => 'Next';
1469+
1470+
@override
1471+
String get previous => 'Previous';
1472+
1473+
@override
1474+
String get step => 'Step';
1475+
1476+
@override
1477+
String get experimentCompleted => 'Experiment Completed';
1478+
1479+
@override
1480+
String get setUp => 'Setup';
1481+
1482+
@override
1483+
String get lightExperimentSetUpContent =>
1484+
'Place your device near a light source (lamp, window, or flashlight).';
1485+
1486+
@override
1487+
String get preparation => 'Preparation';
1488+
1489+
@override
1490+
String get lightExperimentPreparationContent =>
1491+
'Make sure you have space to move towards the light source gradually.';
1492+
1493+
@override
1494+
String get instructions => 'Instructions';
1495+
1496+
@override
1497+
String get lightExperimentInstructionContent =>
1498+
'You will measure light intensity at different distances. Follow the on-screen prompts to move closer or farther from the light source.';
1499+
1500+
@override
1501+
String get moveTowardsLight => 'Move towards the light source';
1502+
1503+
@override
1504+
String get moveAwayFromLight => 'Move away from the light source';
1505+
1506+
@override
1507+
String get holdPosition => 'Hold your position and let the reading stabilize';
1508+
1509+
@override
1510+
String get followInstructions =>
1511+
'Follow the on-screen instructions to set up your experiment.';
1512+
14481513
@override
14491514
String get gesture => 'Gesture';
14501515

@@ -1475,6 +1540,7 @@ class AppLocalizationsEn extends AppLocalizations {
14751540
@override
14761541
String get lux => 'Lux';
14771542

1543+
@override
14781544
String get distance => 'Distance';
14791545

14801546
@override

lib/main.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import 'package:pslab/theme/app_theme.dart';
2525
import 'package:pslab/view/soundmeter_screen.dart';
2626
import 'package:pslab/view/thermometer_screen.dart';
2727
import 'package:pslab/view/wave_generator_screen.dart';
28+
import 'package:pslab/view/experiments_screen.dart';
2829
import 'constants.dart';
2930

3031
void main() {
@@ -84,7 +85,8 @@ class MyApp extends StatelessWidget {
8485
'/barometer': (context) => const BarometerScreen(),
8586
'/soundmeter': (context) => const SoundMeterScreen(),
8687
'/thermometer': (context) => const ThermometerScreen(),
87-
'/sensors': (context) => const SensorsScreen()
88+
'/sensors': (context) => const SensorsScreen(),
89+
'/experiments': (context) => const ExperimentsScreen()
8890
},
8991
);
9092
},

lib/models/experiment_config.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:flutter/cupertino.dart';
2+
3+
import 'experiment_step.dart';
4+
5+
class ExperimentConfig {
6+
final String id;
7+
final String title;
8+
final String description;
9+
final IconData icon;
10+
final List<Map<String, String>> guideSteps;
11+
final List<ExperimentStep> experimentSteps;
12+
final String targetScreen;
13+
14+
ExperimentConfig({
15+
required this.id,
16+
required this.title,
17+
required this.description,
18+
required this.icon,
19+
required this.guideSteps,
20+
required this.experimentSteps,
21+
required this.targetScreen,
22+
});
23+
}

lib/models/experiment_step.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
abstract class ExperimentStep {
2+
final String id;
3+
final String instruction;
4+
final Duration? timeout;
5+
6+
ExperimentStep({
7+
required this.id,
8+
required this.instruction,
9+
this.timeout,
10+
});
11+
12+
bool checkCondition(List<double> values, List<double> timeData);
13+
}

0 commit comments

Comments
 (0)