Skip to content

Commit a8a92d0

Browse files
authored
Merge pull request #7 from Kamoool/develop
Merge v2.0 develop into main
2 parents f729e76 + f32579e commit a8a92d0

15 files changed

+652
-308
lines changed

lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_easyloading/flutter_easyloading.dart';
23
import 'package:qs_ds_app/screens/port_screen.dart';
34
import 'package:window_size/window_size.dart';
45
import 'dart:io' show Platform;
@@ -37,6 +38,7 @@ class _MyAppState extends State<MyApp> {
3738
toolbarHeight: 0,
3839
),
3940
),
41+
builder: EasyLoading.init(),
4042
home: const PortScreen(),
4143
);
4244
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
class ConstantsRepository {
2+
static ConstantsRepository instance = ConstantsRepository.internal();
3+
4+
//General tab pulses numeric
5+
final double pulsesNumericMin = 0.5;
6+
final double pulsesNumericMax = 10;
7+
final double pulsesNumericStep = 0.5;
8+
9+
//QS cut times numerics
10+
final double qsCutNumericMin = 30;
11+
final double qsCutNumericMax = 150;
12+
final double qsCutNumericStep = 1;
13+
14+
//Sensor threshold numerics
15+
final double sensorNumericMin = 1;
16+
final double sensorNumericMax = 2000;
17+
final double sensorNumericStep = 1;
18+
19+
//MinRPM numerics
20+
final double minRPMNumericMin = 0;
21+
final double minRPMNumericMax = 15500;
22+
final double minRPMNumericStep = 100;
23+
24+
//MaxRPM numerics
25+
final double maxRPMNumericMin = 500;
26+
final double maxRPMNumericMax = 16000;
27+
final double maxRPMNumericStep = 100;
28+
29+
//PreDelay numerics
30+
final double preDelayNumericMin = 0;
31+
final double preDelayNumericMax = 100;
32+
final double preDelayNumericStep = 1;
33+
34+
//PostDelay numerics
35+
final double postDelayNumericMin = 300;
36+
final double postDelayNumericMax = 10000;
37+
final double postDelayNumericStep = 10;
38+
39+
//DS blip times numerics
40+
final double dsBlipNumericMin = 30;
41+
final double dsBlipNumericMax = 300;
42+
final double dsBlipNumericStep = 1;
43+
44+
//Average readings sensor numerics
45+
final double averageReadingsNumericMin = 1;
46+
final double averageReadingsNumericMax = 100;
47+
final double averageReadingsNumericStep = 1;
48+
49+
//Sensor allowed numerics
50+
final double sensorAllowedNumericMin = 1;
51+
final double sensorAllowedNumericMax = 2047;
52+
final double sensorAllowedNumericStep = 1;
53+
54+
//Sensor above numerics
55+
final double sensorAboveNumericMin = 0;
56+
final double sensorAboveNumericMax = 4095;
57+
final double sensorAboveNumericStep = 1;
58+
59+
//Sensor below numerics
60+
final double sensorBelowNumericMin = 0;
61+
final double sensorBelowNumericMax = 4095;
62+
final double sensorBelowNumericStep = 1;
63+
64+
//RPM Average numerics
65+
final double averageRPMNumericMin = 1;
66+
final double averageRPMNumericMax = 200;
67+
final double averageRPMNumericStep = 1;
68+
69+
//DAC Adjustment numerics
70+
final double adjustmentDACNumericMin = 1;
71+
final double adjustmentDACNumericMax = 200;
72+
final double adjustmentDACNumericStep = 1;
73+
74+
//Reading DAC numerics
75+
final double readingDACNumericMin = 1000;
76+
final double readingDACNumericMax = 500000;
77+
final double readingDACNumericStep = 1000;
78+
79+
factory ConstantsRepository() {
80+
return instance;
81+
}
82+
83+
ConstantsRepository.internal();
84+
}
Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,62 @@ class SerialPortUtils {
3434
}
3535

3636
void disconnect() {
37+
if (SettingsRepository().systemUnlocked) {
38+
lockSession();
39+
}
3740
stopListener = true;
38-
sendString('E');
41+
sendString('X');
3942
serialPort.close();
4043
serialPort.dispose();
4144
instance = null;
4245
}
4346

44-
void cut(){
47+
void cut() {
4548
sendString('C');
4649
}
4750

48-
void blip(){
51+
void blip() {
4952
sendString('B');
5053
}
5154

52-
void readData(){
55+
void readData() {
5356
sendString('R');
5457
}
5558

56-
void saveSettings(){
57-
sendString(SettingsRepository().generateSaveSettings());
59+
void readSystemData() {
60+
if (SettingsRepository().systemUnlocked) {
61+
unlockSession();
62+
}
63+
}
64+
65+
void unlockSession() {
66+
sendString('K,${SettingsRepository().unlockPassword.value}');
67+
}
68+
69+
void lockSession() {
70+
SettingsRepository().systemUnlocked = false;
71+
SettingsRepository().unlockPassword.value = '0';
72+
sendString('N');
73+
}
74+
75+
void saveSettings() {
76+
sendString('S,${SettingsRepository().generateSaveSettings()}');
77+
}
78+
79+
void saveSystemSettings() {
80+
if (SettingsRepository().systemUnlocked) {
81+
sendString('L,${SettingsRepository().generateSaveSystemSettings()}');
82+
}
5883
}
5984

60-
void resetSettings(){
61-
sendString('W');
85+
void resetSettings() {
86+
sendString('T');
87+
}
88+
89+
void resetSystemSettings() {
90+
if (SettingsRepository().systemUnlocked) {
91+
sendString('M,${SettingsRepository().unlockPassword.value}');
92+
}
6293
}
6394

6495
void sendString(String string) {
@@ -71,17 +102,15 @@ class SerialPortUtils {
71102
reader.stream.listen((Uint8List data) {
72103
b.add(data);
73104
if (String.fromCharCodes(b.toBytes()).contains('\r\n')) {
74-
List<String> stringList =
75-
String.fromCharCodes(b.toBytes()).split('\r\n');
105+
List<String> stringList = String.fromCharCodes(b.toBytes()).split('\r\n');
76106
b.clear();
77107
if (stringList[stringList.length - 1] == '') {
78108
for (int i = 0; i < stringList.length - 1; i++) {
79109
SettingsRepository().parseValues(stringList[i]);
80110
notify!();
81111
}
82112
} else {
83-
b.add(
84-
Uint8List.fromList(stringList[stringList.length - 1].codeUnits));
113+
b.add(Uint8List.fromList(stringList[stringList.length - 1].codeUnits));
85114
for (int i = 0; i < stringList.length - 1; i++) {
86115
SettingsRepository().parseValues(stringList[i]);
87116
notify!();

lib/model/setting.dart

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ enum SettingType {
4343
MinRPMDS,
4444
MaxRPMDS,
4545
PostDelayQS,
46-
PostDelayDS
46+
PostDelayDS,
47+
UnlockPassword,
48+
AverageReadingsSensor,
49+
SensorAllowedChange,
50+
SensorBelowAdjust,
51+
SensorAboveAdjust,
52+
AverageRPM,
53+
DACAdjustmentValue,
54+
ReadingDAC,
55+
ReadingDACConnected,
4756
}
4857

4958
String generateLabel(SettingType settingType) {
@@ -117,6 +126,24 @@ String generateLabel(SettingType settingType) {
117126
return 'Post-delay';
118127
} else if (settingType == SettingType.PostDelayDS) {
119128
return 'Post-delay';
129+
} else if (settingType == SettingType.UnlockPassword) {
130+
return 'Unlock password';
131+
}else if (settingType == SettingType.AverageReadingsSensor) {
132+
return 'Average sensor';
133+
}else if (settingType == SettingType.SensorAllowedChange) {
134+
return 'Sensor allowed';
135+
}else if (settingType == SettingType.SensorAboveAdjust) {
136+
return 'Sensor above';
137+
}else if (settingType == SettingType.SensorBelowAdjust) {
138+
return 'Sensor below';
139+
}else if (settingType == SettingType.AverageRPM) {
140+
return 'Average RPM';
141+
}else if (settingType == SettingType.DACAdjustmentValue) {
142+
return 'DAC Adjustment';
143+
}else if (settingType == SettingType.ReadingDAC) {
144+
return 'Readings DAC';
145+
}else if (settingType == SettingType.ReadingDACConnected) {
146+
return 'Readings connected';
120147
} else {
121148
return 'Wrong Type';
122149
}

0 commit comments

Comments
 (0)