Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console log updates #24

Merged
merged 12 commits into from
Jul 17, 2024
9 changes: 9 additions & 0 deletions flutter_app/lib/modules/custom_log_functions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'dart:developer';

void logDroneMode(int? currentMode, String? currentModeName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is making it to complicated, I see where you're coming from but I think it's better to keep it in the widget

if (currentMode != null) {
log("$currentModeName mode selected.");
} else {
log('No mode selected.');
}
}
3 changes: 2 additions & 1 deletion flutter_app/lib/modules/mavlink_communication.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:typed_data';
import 'dart:io';
import 'dart:developer';
import 'dart:async';
import 'package:flutter_libserialport/flutter_libserialport.dart';
import 'package:dart_mavlink/mavlink.dart';
Expand Down Expand Up @@ -67,7 +68,7 @@ class MavlinkCommunication {
_parser.parse(data);
}, onError: (error) {
// print if log does not work, I can't really test it, just avoid the warning
print(error);
log(error);
_tcpSocket.destroy();
});

Expand Down
7 changes: 7 additions & 0 deletions flutter_app/lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:imacs/modules/change_drone_mode.dart';
import 'package:imacs/modules/mavlink_communication.dart';
import 'package:imacs/modules/get_drone_information.dart';
import 'package:imacs/widgets/change_mode_widget.dart';
import 'package:imacs/widgets/drone_information_widget.dart';

class HomePage extends StatelessWidget {
Expand All @@ -18,6 +20,11 @@ class HomePage extends StatelessWidget {
),
body: Column(
children: [
DroneModeChanger(
systemId: 1,
componentId: 1,
changeDroneMode: ChangeDroneMode(comm: comm),
),
DroneInformation(
getDroneInformation: GetDroneInformation(comm: comm),
),
Expand Down
15 changes: 10 additions & 5 deletions flutter_app/lib/widgets/change_mode_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:dart_mavlink/dialects/common.dart';
import 'package:imacs/modules/change_drone_mode.dart';
import 'package:imacs/modules/custom_log_functions.dart';

/// Define the MavMode constants and their string representations.
const Map<int, String> mavModes = {
Expand Down Expand Up @@ -63,12 +64,16 @@ class DroneModeChangerState extends State<DroneModeChanger> {
widget.componentId,
_selectedMode!,
);
setState(() {
_confirmedMode = _selectedMode;
});
} else {
print('No mode selected');
setState(
() {
_confirmedMode = _selectedMode;
},
);
}
logDroneMode(
_selectedMode,
_selectedMode != null ? mavModes[_selectedMode] : null,
);
}

@override
Expand Down
4 changes: 2 additions & 2 deletions flutter_app/lib/widgets/drone_information_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class DroneInformation extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 500,
width: 400,
height: 400,
width: 500,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
Expand Down