Skip to content

Commit 83dd01f

Browse files
committed
Minor changes
1 parent fd4e971 commit 83dd01f

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

lib/model/serial_utils.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,34 @@ class SerialPortUtils {
3434
this.notify = notify;
3535
}
3636

37-
void closeConnection() {
37+
void disconnect() {
3838
stopListener = true;
3939
sendString('E');
4040
serialPort.close();
4141
serialPort.dispose();
4242
instance = null;
4343
}
4444

45+
void cut(){
46+
sendString('C');
47+
}
48+
49+
void blip(){
50+
sendString('B');
51+
}
52+
53+
void readData(){
54+
sendString('R');
55+
}
56+
57+
void saveSettings(){
58+
sendString(SettingsRepository().generateSaveSettings());
59+
}
60+
61+
void resetSettings(){
62+
sendString('W');
63+
}
64+
4565
void sendString(String string) {
4666
serialPort.write(Uint8List.fromList('$string\n'.codeUnits), timeout: 100);
4767
}

lib/screens/settings_screen.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
8686
labelBackgroundColor: Colors.yellow,
8787
backgroundColor: Colors.yellow,
8888
onTap: () {
89-
SerialPortUtils().sendString('R');
89+
SerialPortUtils().readData();
9090
},
9191
),
9292
SpeedDialChild(
@@ -96,8 +96,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
9696
labelBackgroundColor: Colors.green,
9797
backgroundColor: Colors.green,
9898
onTap: () {
99-
SerialPortUtils().sendString(
100-
SettingsRepository().generateSaveSettings());
99+
SerialPortUtils().saveSettings();
101100
},
102101
),
103102
SpeedDialChild(
@@ -107,7 +106,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
107106
labelBackgroundColor: Colors.blue,
108107
backgroundColor: Colors.blue,
109108
onTap: () {
110-
SerialPortUtils().sendString('W');
109+
SerialPortUtils().resetSettings();
111110
}),
112111
SpeedDialChild(
113112
child: const Icon(Icons.exit_to_app),
@@ -116,7 +115,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
116115
labelBackgroundColor: Colors.red,
117116
backgroundColor: Colors.red,
118117
onTap: () {
119-
SerialPortUtils().closeConnection();
118+
SerialPortUtils().disconnect();
120119
Navigator.pop(context);
121120
}),
122121
],

lib/widgets/downshifter_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,6 @@ class _DownshifterWidgetState extends State<DownshifterWidget> {
282282
}
283283

284284
Future<void> blipCommandCall() async {
285-
SerialPortUtils().sendString('B');
285+
SerialPortUtils().blip();
286286
}
287287
}

lib/widgets/quickshifter_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,6 @@ class _QuickshifterWidgetState extends State<QuickshifterWidget> {
270270
}
271271

272272
Future<void> cutCommandCall() async {
273-
SerialPortUtils().sendString('C');
273+
SerialPortUtils().cut();
274274
}
275275
}

0 commit comments

Comments
 (0)