Skip to content

Commit 535bfe5

Browse files
feat: added instrument guide for soundmeter, luxmeter, accelerometer and gyroscope (#2751)
1 parent 6742a6f commit 535bfe5

10 files changed

+572
-68
lines changed

assets/images/bh1750_schematic.png

69.4 KB
Loading
22.7 KB
Loading

lib/constants.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,37 @@ String soundMeterError = 'Sound sensor error:';
259259
String soundMeterInitialError = 'Sound sensor initialization error:';
260260
String db = 'dB';
261261
String soundMeterTitle = 'Sound Meter';
262+
String soundMeterIntro = 'Sound meter Introduction';
263+
String soundMeterDesc =
264+
'To measure the loudness in the environment in decibel(dB)';
265+
String luxMeterDesc =
266+
'The Lux meter can be used to measure the ambient light intensity. This instruments is compatible with either the built-in light sensor on any Android device or the BH-1750 light sensor.';
267+
String luxMeterSensorIntro =
268+
'If you want to use the sensor BH-1750, connect the sensor to PSLab device as shown below';
269+
String luxMeterBulletPoint1 =
270+
'The above pin configuration has to be same except for the pin GND. GND is meant for Ground and any of the PSLab device GND pins can be used since they are common.';
271+
String luxMeterBulletPoint2 =
272+
'Select sensor by going to the Configure tab from the bottom navigation bar and choose BHT-1750 in the drop down menu under Select Sensor.';
273+
String gyroscopeIntro =
274+
'Gyroscope is used to measure rate of rotation of a body along X, Y, and Z axis.';
275+
String gyroscopeDesc =
276+
'Orientation of the positive X, Y, and Z axes. For any positive axis on the device, clockwise rotation outputs negative values, and counterclockwise rotation outputs positive values.';
277+
String accelerometerIntro =
278+
'Accelerometer is used to measure acceleration of a body along the X, Y, and Z axis.';
279+
String accelerometerImageDesc =
280+
'The figure above shows the direction of all the three axis when the mobile is held straight.';
281+
String accelerometerSteps = 'Steps to measure acceleration in PSLab app:';
282+
String accelerometerBulletPoint1 =
283+
'Hold the device as shown in the above figure.';
284+
String accelerometerBulletPoint2 =
285+
'Accelerate the device along any one or multiple axis.';
286+
String accelerometerBulletPoint3 =
287+
'Observe the values in the cards or the plotted graph of any particular axis.';
288+
String accelerometerDesc =
289+
'The Accelerometer instrument can also be used to measure the acceleration of a moving body by placing the device on/inside the body and then accelerating the body.';
290+
String accelerometerNote =
291+
'NOTE: Don\'t accelerate the body if the device isn\'t properly attached else the device could be damaged.';
292+
String hideGuide = 'Hide Guide';
262293
String minLabel = 'Min';
263294
String maxLabel = 'Max';
264295
String avgLabel = 'Avg';

lib/theme/colors.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ Color selectedMenuColor = Colors.red;
4040
Color menuColor = Colors.grey;
4141
Color listTileFocusColor = Colors.grey[350]!;
4242
Color oscilloscopeOptionLabelColor = Colors.black;
43+
Color guideDrawerBackgroundColor = Colors.white;
44+
Color guideDrawerHeadingColor = Colors.black87;
45+
Color guideDrawerHighlightColor = Colors.black54;

lib/view/accelerometer_screen.dart

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:provider/provider.dart';
33
import 'package:pslab/constants.dart';
4+
import 'package:pslab/view/widgets/guide_widget.dart';
45
import 'package:pslab/providers/accelerometer_state_provider.dart';
56
import 'package:pslab/view/widgets/common_scaffold_widget.dart';
67
import 'package:pslab/view/widgets/accelerometer_card.dart';
@@ -15,6 +16,42 @@ class AccelerometerScreen extends StatefulWidget {
1516
}
1617

1718
class _AccelerometerScreenState extends State<AccelerometerScreen> {
19+
bool _showGuide = false;
20+
static const imagePath = 'assets/images/bh1750_schematic.png';
21+
void _showInstrumentGuide() {
22+
setState(() {
23+
_showGuide = true;
24+
});
25+
}
26+
27+
void _hideInstrumentGuide() {
28+
setState(() {
29+
_showGuide = false;
30+
});
31+
}
32+
33+
List<Widget> _getAccelerometerContent() {
34+
return [
35+
InstrumentIntroText(
36+
text: accelerometerIntro,
37+
),
38+
const InstrumentImage(
39+
imagePath: imagePath,
40+
),
41+
InstrumentIntroText(
42+
text: accelerometerImageDesc,
43+
),
44+
InstrumentIntroText(
45+
text: accelerometerSteps,
46+
),
47+
InstrumentBulletPoint(text: accelerometerBulletPoint1),
48+
InstrumentBulletPoint(text: accelerometerBulletPoint2),
49+
InstrumentBulletPoint(text: accelerometerBulletPoint3),
50+
InstrumentIntroText(text: accelerometerDesc),
51+
InstrumentIntroText(text: accelerometerNote),
52+
];
53+
}
54+
1855
@override
1956
Widget build(BuildContext context) {
2057
return MultiProvider(
@@ -23,22 +60,31 @@ class _AccelerometerScreenState extends State<AccelerometerScreen> {
2360
create: (_) => AccelerometerStateProvider()..initializeSensors(),
2461
),
2562
],
26-
child: CommonScaffold(
27-
title: accelerometer,
28-
body: SafeArea(
29-
child: Column(
30-
children: [
31-
Expanded(
32-
child: AccelerometerCard(
33-
color: xOrientationChartLineColor, axis: xAxis)),
34-
Expanded(
35-
child: AccelerometerCard(
36-
color: yOrientationChartLineColor, axis: yAxis)),
37-
Expanded(
38-
child: AccelerometerCard(
39-
color: zOrientationChartLineColor, axis: zAxis)),
40-
],
41-
))),
63+
child: Stack(children: [
64+
CommonScaffold(
65+
title: accelerometer,
66+
onGuidePressed: _showInstrumentGuide,
67+
body: SafeArea(
68+
child: Column(
69+
children: [
70+
Expanded(
71+
child: AccelerometerCard(
72+
color: xOrientationChartLineColor, axis: xAxis)),
73+
Expanded(
74+
child: AccelerometerCard(
75+
color: yOrientationChartLineColor, axis: yAxis)),
76+
Expanded(
77+
child: AccelerometerCard(
78+
color: zOrientationChartLineColor, axis: zAxis)),
79+
],
80+
))),
81+
if (_showGuide)
82+
InstrumentOverviewDrawer(
83+
instrumentName: accelerometer,
84+
content: _getAccelerometerContent(),
85+
onHide: _hideInstrumentGuide,
86+
),
87+
]),
4288
);
4389
}
4490
}

lib/view/gyroscope_screen.dart

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:provider/provider.dart';
33
import 'package:pslab/providers/gyroscope_state_provider.dart';
44
import 'package:pslab/constants.dart';
5+
import 'package:pslab/view/widgets/guide_widget.dart';
56
import 'package:pslab/view/widgets/gyroscope_card.dart';
67
import 'package:pslab/view/widgets/common_scaffold_widget.dart';
78

@@ -15,6 +16,35 @@ class GyroscopeScreen extends StatefulWidget {
1516
}
1617

1718
class _GyroscopeScreenState extends State<GyroscopeScreen> {
19+
bool _showGuide = false;
20+
static const imagePath = 'assets/images/gyroscope_axes_orientation.png';
21+
void _showInstrumentGuide() {
22+
setState(() {
23+
_showGuide = true;
24+
});
25+
}
26+
27+
void _hideInstrumentGuide() {
28+
setState(() {
29+
_showGuide = false;
30+
});
31+
}
32+
33+
List<Widget> _getGyroscopeContent() {
34+
return [
35+
InstrumentIntroText(
36+
text: gyroscopeIntro,
37+
),
38+
const InstrumentImage(
39+
imagePath: imagePath,
40+
height: 200.0,
41+
),
42+
InstrumentIntroText(
43+
text: gyroscopeDesc,
44+
),
45+
];
46+
}
47+
1848
@override
1949
Widget build(BuildContext context) {
2050
return MultiProvider(
@@ -23,27 +53,36 @@ class _GyroscopeScreenState extends State<GyroscopeScreen> {
2353
create: (_) => GyroscopeProvider()..initializeSensors(),
2454
),
2555
],
26-
child: CommonScaffold(
27-
title: gyroscopeTitle,
28-
body: SafeArea(
29-
child: Column(
30-
children: [
31-
Expanded(
32-
child: GyroscopeCard(
33-
color: xOrientationChartLineColor, axis: xAxis),
34-
),
35-
Expanded(
36-
child: GyroscopeCard(
37-
color: yOrientationChartLineColor, axis: yAxis),
38-
),
39-
Expanded(
40-
child: GyroscopeCard(
41-
color: zOrientationChartLineColor, axis: zAxis),
42-
),
43-
],
56+
child: Stack(children: [
57+
CommonScaffold(
58+
title: gyroscopeTitle,
59+
onGuidePressed: _showInstrumentGuide,
60+
body: SafeArea(
61+
child: Column(
62+
children: [
63+
Expanded(
64+
child: GyroscopeCard(
65+
color: xOrientationChartLineColor, axis: xAxis),
66+
),
67+
Expanded(
68+
child: GyroscopeCard(
69+
color: yOrientationChartLineColor, axis: yAxis),
70+
),
71+
Expanded(
72+
child: GyroscopeCard(
73+
color: zOrientationChartLineColor, axis: zAxis),
74+
),
75+
],
76+
),
4477
),
4578
),
46-
),
79+
if (_showGuide)
80+
InstrumentOverviewDrawer(
81+
instrumentName: gyroscopeTitle,
82+
content: _getGyroscopeContent(),
83+
onHide: _hideInstrumentGuide,
84+
),
85+
]),
4786
);
4887
}
4988
}

lib/view/luxmeter_screen.dart

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:provider/provider.dart';
33
import 'package:pslab/constants.dart';
44
import 'package:pslab/providers/luxmeter_state_provider.dart';
5+
import 'package:pslab/view/widgets/guide_widget.dart';
56
import 'package:pslab/view/widgets/common_scaffold_widget.dart';
67
import 'package:pslab/view/widgets/luxmeter_card.dart';
78
import 'package:fl_chart/fl_chart.dart';
@@ -15,6 +16,38 @@ class LuxMeterScreen extends StatefulWidget {
1516
}
1617

1718
class _LuxMeterScreenState extends State<LuxMeterScreen> {
19+
bool _showGuide = false;
20+
static const imagePath = 'assets/images/bh1750_schematic.png';
21+
void _showInstrumentGuide() {
22+
setState(() {
23+
_showGuide = true;
24+
});
25+
}
26+
27+
void _hideInstrumentGuide() {
28+
setState(() {
29+
_showGuide = false;
30+
});
31+
}
32+
33+
List<Widget> _getLuxMeterContent() {
34+
return [
35+
InstrumentBulletPoint(
36+
text: luxMeterDesc,
37+
),
38+
InstrumentBulletPoint(
39+
text: luxMeterSensorIntro,
40+
),
41+
const InstrumentImage(
42+
imagePath: imagePath,
43+
),
44+
InstrumentBulletPoint(
45+
text: luxMeterBulletPoint1,
46+
),
47+
InstrumentBulletPoint(text: luxMeterBulletPoint2),
48+
];
49+
}
50+
1851
@override
1952
Widget build(BuildContext context) {
2053
return MultiProvider(
@@ -23,23 +56,32 @@ class _LuxMeterScreenState extends State<LuxMeterScreen> {
2356
create: (_) => LuxMeterStateProvider()..initializeSensors(),
2457
),
2558
],
26-
child: CommonScaffold(
27-
title: luxMeterTitle,
28-
body: SafeArea(
29-
child: Column(
30-
children: [
31-
const Expanded(
32-
flex: 45,
33-
child: LuxMeterCard(),
34-
),
35-
Expanded(
36-
flex: 55,
37-
child: _buildChartSection(),
38-
),
39-
],
59+
child: Stack(children: [
60+
CommonScaffold(
61+
title: luxMeterTitle,
62+
onGuidePressed: _showInstrumentGuide,
63+
body: SafeArea(
64+
child: Column(
65+
children: [
66+
const Expanded(
67+
flex: 45,
68+
child: LuxMeterCard(),
69+
),
70+
Expanded(
71+
flex: 55,
72+
child: _buildChartSection(),
73+
),
74+
],
75+
),
4076
),
4177
),
42-
),
78+
if (_showGuide)
79+
InstrumentOverviewDrawer(
80+
instrumentName: luxMeterTitle,
81+
content: _getLuxMeterContent(),
82+
onHide: _hideInstrumentGuide,
83+
),
84+
]),
4385
);
4486
}
4587

0 commit comments

Comments
 (0)