diff --git a/assets/assets.qrc b/assets/assets.qrc
index 9c084cfc..d0c939e4 100644
--- a/assets/assets.qrc
+++ b/assets/assets.qrc
@@ -97,5 +97,7 @@
qml/SetupPanes/MQTT.qml
qml/Widgets/CompassDelegate.qml
icons/compass.svg
+ instruments/Compass.svg
+ instruments/CompassCase.svg
diff --git a/assets/instruments/Compass.svg b/assets/instruments/Compass.svg
new file mode 100644
index 00000000..855ce3aa
--- /dev/null
+++ b/assets/instruments/Compass.svg
@@ -0,0 +1,4640 @@
+
+
+
+
diff --git a/assets/instruments/CompassCase.svg b/assets/instruments/CompassCase.svg
new file mode 100644
index 00000000..8a393756
--- /dev/null
+++ b/assets/instruments/CompassCase.svg
@@ -0,0 +1,3809 @@
+
+
+
+
diff --git a/assets/messages/Acknowledgements.txt b/assets/messages/Acknowledgements.txt
index 20a101ee..a82831ef 100644
--- a/assets/messages/Acknowledgements.txt
+++ b/assets/messages/Acknowledgements.txt
@@ -57,6 +57,28 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+## QFlightInstruments
+
+Copyright (C) 2013 Marek M. Cel
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
+
## qmqtt
This project is dual licensed under the Eclipse Public License 1.0 and the
@@ -312,4 +334,4 @@ including all Contributors.
intellectual property laws of the United States of America. No party to this
Agreement will bring a legal action under this Agreement more than one year
after the cause of action arose. Each party waives its rights to a jury trial
- in any resulting litigation.
\ No newline at end of file
+ in any resulting litigation.
diff --git a/assets/qml/Widgets/AccelerometerDelegate.qml b/assets/qml/Widgets/AccelerometerDelegate.qml
index 4568b4d2..b85b4021 100644
--- a/assets/qml/Widgets/AccelerometerDelegate.qml
+++ b/assets/qml/Widgets/AccelerometerDelegate.qml
@@ -129,10 +129,10 @@ Window {
//
function calculateGaugeSize() {
if (root.width < root.height)
- root.gaugeSize = Math.max(120, root.width - controls.implicitWidth - 12 * app.spacing)
+ root.gaugeSize = Math.max(120, root.width - controls.implicitWidth - 12 * app.spacing) * 0.8
else
- root.gaugeSize = Math.max(120, root.height - controls.implicitWidth - 4 * app.spacing)
+ root.gaugeSize = Math.max(120, root.height - controls.implicitWidth - 4 * app.spacing) * 0.8
}
//
diff --git a/assets/qml/Widgets/CompassDelegate.qml b/assets/qml/Widgets/CompassDelegate.qml
index 5ccfe19e..7b0fc0d2 100644
--- a/assets/qml/Widgets/CompassDelegate.qml
+++ b/assets/qml/Widgets/CompassDelegate.qml
@@ -46,5 +46,95 @@ Window {
//
// Custom properties
//
+ property int angle: 0
property int datasetIndex: 0
+ property string direction: "0 N"
+ property int widgetSize: Math.min(root.height, root.width) * 0.6
+
+ //
+ // Connections with widget manager
+ //
+ Connections {
+ target: Cpp_UI_WidgetProvider
+
+ //*! Optimize this function
+ function onDataChanged() {
+ root.updateValues()
+ }
+ }
+
+ //
+ // Updates the internal values of the compass widget
+ //
+ //*! Optimize this function
+ // About 6% of the UI thread is spent here
+ function updateValues() {
+ if (Cpp_UI_WidgetProvider.compassDatasetCount() > root.datasetIndex) {
+ root.angle = Cpp_UI_WidgetProvider.compass(root.datasetIndex)
+ root.title = Cpp_UI_WidgetProvider.compassDatasetAt(root.datasetIndex).title
+
+ if (root.angle <= 22)
+ root.direction = root.angle + "° N"
+ else if (root.angle > 22 && root.angle <= 67)
+ root.direction = root.angle + "° NE"
+ else if (root.angle > 67 && root.angle <= 112)
+ root.direction = root.angle + "° E"
+ else if (root.angle > 112 && root.angle <= 157)
+ root.direction = root.angle + "° SE"
+ else if (root.angle > 157 && root.angle <= 203)
+ root.direction = root.angle + "° S"
+ else if (root.angle > 203 && root.angle <= 247)
+ root.direction = root.angle + "° SW"
+ else if (root.angle > 247 && root.angle <= 292)
+ root.direction = root.angle + "° W"
+ else if (root.angle > 292 && root.angle <= 337)
+ root.direction = root.angle + "° NW"
+ else
+ root.direction = root.angle + "° N"
+ }
+
+ else {
+ root.angle = 0
+ root.title = ""
+ root.direction = "0° N"
+ }
+ }
+
+ //
+ // Compass image
+ //
+ ColumnLayout {
+ anchors.centerIn: parent
+ spacing: app.spacing * 2
+
+ Item {
+ Layout.alignment: Qt.AlignHCenter
+ Layout.minimumWidth: root.widgetSize
+ Layout.maximumWidth: root.widgetSize
+ Layout.minimumHeight: root.widgetSize
+ Layout.maximumHeight: root.widgetSize
+
+ Image {
+ anchors.fill: parent
+ rotation: 360 - root.angle
+ source: "qrc:/instruments/Compass.svg"
+ sourceSize: Qt.size(root.widgetSize, root.widgetSize)
+ }
+
+ Image {
+ anchors.fill: parent
+ source: "qrc:/instruments/CompassCase.svg"
+ sourceSize: Qt.size(root.widgetSize, root.widgetSize)
+ }
+ }
+
+ Label {
+ color: "#8ecd9d"
+ font.bold: true
+ font.pixelSize: 24
+ text: root.direction
+ font.family: app.monoFont
+ Layout.alignment: Qt.AlignHCenter
+ }
+ }
}
diff --git a/assets/qml/Windows/Widgets.qml b/assets/qml/Windows/Widgets.qml
index e2527044..fae19cfe 100644
--- a/assets/qml/Windows/Widgets.qml
+++ b/assets/qml/Windows/Widgets.qml
@@ -263,54 +263,54 @@ Control {
}
}
}
- }
- Repeater {
- id: compassGenerator
+ Repeater {
+ id: compassGenerator
- delegate: Item {
- Layout.fillWidth: true
- Layout.fillHeight: true
- Layout.minimumWidth: root.minimumWidgetSize
- Layout.minimumHeight: root.minimumWidgetSize
-
- Widgets.CompassDelegate {
- datasetIndex: index
- anchors.fill: parent
- onHeaderDoubleClicked: windowCompass.show()
- }
-
- QtWindow.Window {
- id: windowCompass
- width: 640
- height: 480
- minimumWidth: root.minimumWidgetSize * 1.2
- minimumHeight: root.minimumWidgetSize * 1.2
- title: compass.title
-
- Rectangle {
- anchors.fill: parent
- color: compass.backgroundColor
- }
+ delegate: Item {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.minimumWidth: root.minimumWidgetSize
+ Layout.minimumHeight: root.minimumWidgetSize
Widgets.CompassDelegate {
- id: compass
- showIcon: true
- gradient: false
- headerHeight: 48
datasetIndex: index
- anchors.margins: 0
anchors.fill: parent
- borderColor: backgroundColor
- headerDoubleClickEnabled: false
+ onHeaderDoubleClicked: windowCompass.show()
+ }
+
+ QtWindow.Window {
+ id: windowCompass
+ width: 640
+ height: 480
+ minimumWidth: root.minimumWidgetSize * 1.2
+ minimumHeight: root.minimumWidgetSize * 1.2
+ title: compass.title
+
+ Rectangle {
+ anchors.fill: parent
+ color: compass.backgroundColor
+ }
+
+ Widgets.CompassDelegate {
+ id: compass
+ showIcon: true
+ gradient: false
+ headerHeight: 48
+ datasetIndex: index
+ anchors.margins: 0
+ anchors.fill: parent
+ borderColor: backgroundColor
+ headerDoubleClickEnabled: false
+ }
}
}
}
}
- }
- Item {
- Layout.minimumHeight: 10
+ Item {
+ Layout.minimumHeight: 10
+ }
}
}
}
diff --git a/src/UI/WidgetProvider.cpp b/src/UI/WidgetProvider.cpp
index 7e85c9a2..1b16955b 100644
--- a/src/UI/WidgetProvider.cpp
+++ b/src/UI/WidgetProvider.cpp
@@ -228,7 +228,7 @@ int WidgetProvider::compass(const int index)
{
auto compass = compassDatasetAt(index);
if (compass)
- return compass->value().toInt();
+ return qMax(0, qMin(360, compass->value().toInt()));
return INT_MAX;
}