Skip to content

Commit 7a32906

Browse files
ctrlVntmarcnause
authored andcommitted
Added psLab ch1 listen
1 parent 4a72ace commit 7a32906

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/providers/dust_sensor_state_provider.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:fl_chart/fl_chart.dart';
66
import 'package:geolocator/geolocator.dart';
77
import 'package:intl/intl.dart';
88

9+
import '../communication/science_lab.dart';
910
import '../l10n/app_localizations.dart';
1011
import '../others/logger_service.dart';
1112
import 'dust_sensor_config_provider.dart';
@@ -90,6 +91,8 @@ class DustSensorStateProvider extends ChangeNotifier {
9091
onSensorError = onError;
9192

9293
try {
94+
ScienceLab scienceLab = getIt.get<ScienceLab>();
95+
9396
_startTime = DateTime.now().millisecondsSinceEpoch / 1000.0;
9497

9598
_timeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
@@ -100,10 +103,11 @@ class DustSensorStateProvider extends ChangeNotifier {
100103
});
101104

102105
int interval = _configProvider?.config.updatePeriod ?? 1000;
103-
_dustTimer = Timer.periodic(Duration(milliseconds: interval), (timer) {
104-
105-
/// TO DO
106+
_dustTimer =
107+
Timer.periodic(Duration(milliseconds: interval), (timer) async {
108+
double voltageReading = await scienceLab.getVoltage("CH1", 1);
106109

110+
_currentDust = voltageReading;
107111
notifyListeners();
108112
});
109113
} catch (e) {

0 commit comments

Comments
 (0)