Skip to content

Commit 188aab4

Browse files
committed
Initial commit, first working version
0 parents  commit 188aab4

16 files changed

Lines changed: 2705 additions & 0 deletions

.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Web related
36+
lib/generated_plugin_registrant.dart
37+
38+
# Symbolication related
39+
app.*.symbols
40+
41+
# Obfuscation related
42+
app.*.map.json
43+
44+
# Android Studio will place build artifacts here
45+
/android/app/debug
46+
/android/app/profile
47+
/android/app/release
48+
/windows/

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# qs_ds_app
2+
3+
QS DS Application
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

lib/main.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:qs_ds_app/screens/port_screen.dart';
3+
import 'package:qs_ds_app/screens/settings_screen.dart';
4+
import 'package:window_size/window_size.dart';
5+
import 'dart:io' show Platform;
6+
7+
void main() {
8+
WidgetsFlutterBinding.ensureInitialized();
9+
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
10+
setWindowTitle('Quick - Down - Shifter APP');
11+
setWindowMinSize(const Size(1050, 400));
12+
// setWindowMaxSize(const Size(1200, 730));
13+
}
14+
15+
runApp(const MyApp());
16+
}
17+
18+
class MyApp extends StatefulWidget {
19+
const MyApp({Key? key}) : super(key: key);
20+
21+
@override
22+
State<MyApp> createState() => _MyAppState();
23+
}
24+
25+
class _MyAppState extends State<MyApp> {
26+
@override
27+
Widget build(BuildContext context) {
28+
return MaterialApp(
29+
theme: ThemeData(
30+
appBarTheme: AppBarTheme(
31+
backgroundColor: Colors.transparent,
32+
elevation: 1,
33+
shadowColor: Colors.black,
34+
toolbarHeight: 0,
35+
// surfaceTintColor: Colors.red,
36+
),
37+
),
38+
// color: Colors.green,
39+
home: PortScreen(),
40+
// home: SettingsScreen(),
41+
);
42+
}
43+
}

lib/model/serial_testing.dart

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import 'dart:typed_data';
2+
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter_libserialport/flutter_libserialport.dart';
5+
6+
void main() {
7+
// final name = SerialPort.availablePorts.first;
8+
final name = 'COM9';
9+
final port = SerialPort(name);
10+
if (!port.openReadWrite()) {
11+
print(SerialPort.lastError);
12+
}
13+
SerialPortConfig config = SerialPortConfig();
14+
config.baudRate = 9600;
15+
config.bits = 8;
16+
config.stopBits = 1;
17+
config.parity = SerialPortParity.none;
18+
config.dtr = SerialPortDtr.on;
19+
config.setFlowControl(SerialPortFlowControl.none);
20+
port.config = config;
21+
22+
port.write(Uint8List.fromList('Onomatopejaqwertasdgaerfg'.codeUnits));
23+
24+
final reader = SerialPortReader(port);
25+
// int i = 0;
26+
var b = BytesBuilder();
27+
// Uint8List datas = Uint8List.fromList([]);
28+
reader.stream.listen((data) {
29+
b.add(data);
30+
// datas.addAll(Uint8List.fromList('${i}'.codeUnits));
31+
// i++;
32+
// print('received: $data');
33+
if(String.fromCharCodes(b.toBytes()).contains('\n')){
34+
List<String> stringList = String.fromCharCodes(b.toBytes()).split('\n');
35+
b.clear();
36+
if(stringList[stringList.length-1] == ''){
37+
for(int i = 0; i < stringList.length-1; i++){
38+
print('${i}-ty element: ${stringList[i]}');
39+
}
40+
} else{
41+
b.add(Uint8List.fromList(stringList[stringList.length-1].codeUnits));
42+
for(int i = 0; i < stringList.length-1; i++){
43+
print('${i}-ty element: ${stringList[i]}');
44+
}
45+
print('Pozostało: ${stringList[stringList.length-1]}');
46+
}
47+
}
48+
// if (i == 5) {
49+
// List<String> stringList = String.fromCharCodes(b.toBytes()).split('\n');
50+
// print('This is the last element \' ${stringList[stringList.length-1]}\'');
51+
// // print('Pierwszy element: ${stringList[0]}');
52+
// // print('Drugi element: ${stringList[1]}');
53+
// // print('Trzeci element: ${stringList[2]}');
54+
// // print('Czwarty element: ${stringList[3]}');
55+
// // print('Piąty element: ${stringList[4]}');
56+
// // print('${String.fromCharCodes(b.toBytes())}');
57+
// b.clear();
58+
// i = 0;
59+
// }
60+
});
61+
}

lib/model/setting.dart

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
class Setting {
2+
final SettingType type;
3+
String value;
4+
late final String label;
5+
6+
Setting(this.type, this.value) {
7+
this.label = generateLabel(this.type);
8+
}
9+
}
10+
11+
enum SettingType {
12+
RPM,
13+
Sensor,
14+
MajorVersion,
15+
MinorVersion,
16+
QSType,
17+
DSType,
18+
QSEnable,
19+
DSEnable,
20+
PushCheckQS,
21+
Pulses,
22+
PreDelayQS,
23+
CutTime1,
24+
CutTime2,
25+
CutTime3,
26+
CutTime4,
27+
CutTime5,
28+
CutTime6,
29+
CutTime7,
30+
CutTime8,
31+
QSForce,
32+
MinRPMQS,
33+
PreDelayDS,
34+
BlipTime1,
35+
BlipTime2,
36+
BlipTime3,
37+
BlipTime4,
38+
BlipTime5,
39+
BlipTime6,
40+
BlipTime7,
41+
BlipTime8,
42+
DSForce,
43+
MinRPMDS,
44+
MaxRPMDS,
45+
PostDelayQS,
46+
PostDelayDS
47+
}
48+
49+
String generateLabel(SettingType settingType) {
50+
if (settingType == SettingType.RPM) {
51+
return 'RPM';
52+
} else if (settingType == SettingType.Sensor) {
53+
return 'Sensor value';
54+
} else if (settingType == SettingType.MajorVersion) {
55+
return 'Major Version';
56+
} else if (settingType == SettingType.MinorVersion) {
57+
return 'Minor Version';
58+
} else if (settingType == SettingType.QSType) {
59+
return 'QS Type';
60+
} else if (settingType == SettingType.DSType) {
61+
return 'DS Type';
62+
} else if (settingType == SettingType.QSEnable) {
63+
return 'Enabled';
64+
} else if (settingType == SettingType.DSEnable) {
65+
return 'Enabled';
66+
} else if (settingType == SettingType.PushCheckQS) {
67+
return 'QS Push';
68+
} else if (settingType == SettingType.Pulses) {
69+
return 'Pulses / RPM';
70+
} else if (settingType == SettingType.PreDelayQS) {
71+
return 'Pre-delay';
72+
} else if (settingType == SettingType.CutTime1) {
73+
return 'Cut Time at 2000';
74+
} else if (settingType == SettingType.CutTime2) {
75+
return 'Cut Time at 4000';
76+
} else if (settingType == SettingType.CutTime3) {
77+
return 'Cut Time at 6000';
78+
} else if (settingType == SettingType.CutTime4) {
79+
return 'Cut Time at 8000';
80+
} else if (settingType == SettingType.CutTime5) {
81+
return 'Cut Time at 10000';
82+
} else if (settingType == SettingType.CutTime6) {
83+
return 'Cut Time at 12000';
84+
} else if (settingType == SettingType.CutTime7) {
85+
return 'Cut Time at 14000';
86+
} else if (settingType == SettingType.CutTime8) {
87+
return 'Cut Time at 16000';
88+
} else if (settingType == SettingType.QSForce) {
89+
return 'Sensor threshold';
90+
} else if (settingType == SettingType.MinRPMQS) {
91+
return 'Minimum RPM';
92+
} else if (settingType == SettingType.PreDelayDS) {
93+
return 'Pre-delay';
94+
} else if (settingType == SettingType.BlipTime1) {
95+
return 'Blip Time at 2000';
96+
} else if (settingType == SettingType.BlipTime2) {
97+
return 'Blip Time at 4000';
98+
} else if (settingType == SettingType.BlipTime3) {
99+
return 'Blip Time at 6000';
100+
} else if (settingType == SettingType.BlipTime4) {
101+
return 'Blip Time at 8000';
102+
} else if (settingType == SettingType.BlipTime5) {
103+
return 'Blip Time at 10000';
104+
} else if (settingType == SettingType.BlipTime6) {
105+
return 'Blip Time at 12000';
106+
} else if (settingType == SettingType.BlipTime7) {
107+
return 'Blip Time at 14000';
108+
} else if (settingType == SettingType.BlipTime8) {
109+
return 'Blip Time at 16000';
110+
} else if (settingType == SettingType.DSForce) {
111+
return 'Sensor threshold';
112+
} else if (settingType == SettingType.MinRPMDS) {
113+
return 'Minimum RPM';
114+
} else if (settingType == SettingType.MaxRPMDS) {
115+
return 'Maximum RPM';
116+
} else if (settingType == SettingType.PostDelayQS) {
117+
return 'Post-delay';
118+
} else if (settingType == SettingType.PostDelayDS) {
119+
return 'Post-delay';
120+
} else {
121+
return 'Wrong Type';
122+
}
123+
}

0 commit comments

Comments
 (0)