-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IMACS widget update to show data in a more user friendly manner (#14)
* added gridview, changed UI * wrote tests for data fields
- Loading branch information
1 parent
7aa1060
commit 1fdd607
Showing
6 changed files
with
300 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import 'dart:math'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:imacs/mavlink_communication.dart'; | ||
|
||
import 'data_field_widget.dart'; | ||
|
||
/// Widget to arrange multiple data widgets in tabular form. | ||
/// | ||
/// This widget selective data made available by MavlinkCommunication. | ||
/// Arranges the data in a grid with two columns and applies a border. | ||
/// | ||
class DroneInformation extends StatelessWidget { | ||
/// @brief Constructs a DroneInformation widget. | ||
/// | ||
/// @param comm The communication channel (MAVLink) where to get | ||
/// the data from | ||
/// | ||
const DroneInformation({ | ||
super.key, | ||
required this.comm, | ||
}); | ||
|
||
final MavlinkCommunication comm; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
decoration: BoxDecoration( | ||
border: Border.all( | ||
color: Colors.black, | ||
), | ||
), | ||
child: GridView.count( | ||
crossAxisCount: 2, | ||
|
||
/// describes how many items in one row. | ||
childAspectRatio: 2, | ||
|
||
/// describes how spaced out things are. | ||
children: <DataField>[ | ||
DataField<double>( | ||
name: 'Yaw (deg)', | ||
value: comm.getYawStream(), | ||
formatter: (double value) => | ||
(value / pi * 180.0).toStringAsFixed(2), | ||
), | ||
DataField<double>( | ||
name: 'Pitch (deg)', | ||
value: comm.getPitchStream(), | ||
formatter: (double value) => | ||
(value / pi * 180.0).toStringAsFixed(2), | ||
), | ||
DataField<double>( | ||
name: 'Roll (deg)', | ||
value: comm.getRollStream(), | ||
formatter: (double value) => | ||
(value / pi * 180.0).toStringAsFixed(2), | ||
), | ||
// global position | ||
DataField<int>( | ||
name: 'Latitude', | ||
value: comm.getLatStream(), | ||
formatter: (int value) => (value / 1e7).toStringAsFixed(2), | ||
), | ||
DataField<int>( | ||
name: 'Longitude', | ||
value: comm.getLonStream(), | ||
formatter: (int value) => (value / 1e7).toStringAsFixed(2), | ||
), | ||
DataField<int>( | ||
name: 'Altitude (m)', | ||
value: comm.getAltStream(), | ||
formatter: (int value) => (value / 1e3).toStringAsFixed(2), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.