aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Barometer.qml62
-rw-r--r--src/CMakeLists.txt8
-rw-r--r--src/Compass.qml118
-rw-r--r--src/SettingsPage.qml138
-rw-r--r--src/main.qml126
-rw-r--r--src/resources.qrc3
6 files changed, 366 insertions, 89 deletions
diff --git a/src/Barometer.qml b/src/Barometer.qml
new file mode 100644
index 0000000..c34f51d
--- /dev/null
+++ b/src/Barometer.qml
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2023 Arseniy Movshev <dodoradio@outlook.com>
+ * 2021 Timo Könnecke <github.com/eLtMosen>
+ * 2021 Darrel Griët <dgriet@gmail.com>
+ * 2019 Florent Revest <revestflo@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.9
+import QtSensors 5.11
+import org.asteroid.controls 1.0
+import org.asteroid.utils 1.0
+import Nemo.Configuration 1.0
+
+Item {
+ id: barometerRoot
+
+
+ PressureSensor {
+ id: pressureSensor
+ active: true
+ }
+ IconButton {
+ onClicked: pageStack.push(settingsPage)
+ iconName: "ios-settings-outline"
+ width: parent.width*0.2
+ height: width
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: pressureText.top
+ }
+ Label {
+ id: pressureText
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignHCenter
+ text: (pressureSensor.reading.pressure + barometerOffset.value)/100
+ font.pixelSize: parent.height / 4
+ }
+ ConfigurationValue {
+ id: barometerOffset
+ key: "/org/asteroidos/sensors/barometer-offset"
+ defaultValue: 0
+ }
+ Label {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.top: pressureText.bottom
+ horizontalAlignment: Text.AlignHCenter
+ text: "hPa"
+ font.pixelSize: parent.height / 6
+ }
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b5930c5..5c71d10 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,8 +1,8 @@
-add_library(asteroid-compass main.cpp resources.qrc)
-set_target_properties(asteroid-compass PROPERTIES PREFIX "")
+add_library(asteroid-toolwatch main.cpp resources.qrc)
+set_target_properties(asteroid-toolwatch PROPERTIES PREFIX "")
-target_link_libraries(asteroid-compass PUBLIC
+target_link_libraries(asteroid-toolwatch PUBLIC
AsteroidApp)
-install(TARGETS asteroid-compass
+install(TARGETS asteroid-toolwatch
DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/src/Compass.qml b/src/Compass.qml
new file mode 100644
index 0000000..48e9557
--- /dev/null
+++ b/src/Compass.qml
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2022 - Darrel Griët <dgriet@gmail.com>
+ * 2017 - Florent Revest <revestflo@gmail.com>
+ * - Niels Tholenaar <info@123quality.nl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.5
+import org.asteroid.controls 1.0
+import QtSensors 5.3
+import QtGraphicalEffects 1.15
+
+Item {
+ id: compassRoot
+
+ property int rotation: 0;
+ property int calibration: 0;
+ property int ringValueOffset: Math.sqrt(Math.pow(Dims.l(40), 2) / 2);
+
+ Compass {
+ active: true
+ onReadingChanged: {
+ compassRoot.rotation = reading.azimuth;
+ compassRoot.calibration = reading.calibrationLevel;
+ }
+ }
+
+ StatusPage {
+ //% "<h3>No data</h3>Calibrate the sensor by moving it in an ∞ figure."
+ text: qsTrId("id-no-data-calibrate")
+ icon: "ios-infinite-outline"
+ visible: !compassRoot.calibration
+ }
+
+ Item {
+ visible: compassRoot.calibration
+ anchors.fill: parent
+
+ Item {
+ id: centerDisplay
+ anchors.fill: parent
+ Label {
+ id: magneticRotation
+ anchors.centerIn: parent
+ text: compassRoot.rotation
+ font {
+ pixelSize: parent.height / 4
+ capitalization: Font.Capitalize
+ styleName: "SemiCondensed"
+ kerning: true
+ preferShaping: true
+ }
+ }
+ Label {
+ id: degreeSymbol
+ anchors.top: magneticRotation.top
+ anchors.left: magneticRotation.right
+ text: "°"
+ font {
+ pixelSize: parent.height / 4
+ capitalization: Font.Capitalize
+ styleName: "SemiCondensed"
+ kerning: true
+ preferShaping: true
+ }
+ }
+ Image {
+ anchors.top: parent.top
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: -Dims.l(35)
+ width: Dims.l(10)
+ height: width
+ source: "compass.svg"
+ }
+ }
+
+ Item {
+ anchors.fill: parent
+ rotation: -compassRoot.rotation
+ Repeater {
+ id: outerRing
+ anchors.fill: parent
+ model: 8
+ Label {
+ property var angle: (index / outerRing.count) * 2 * Math.PI
+ property var cardinalDirections: ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
+ rotation: compassRoot.rotation
+ color: index == 0 ? "#c2620c" : "white"
+ text: cardinalDirections[index]
+ anchors {
+ centerIn: parent
+ verticalCenterOffset: -Math.cos(angle) * Dims.l(40)
+ horizontalCenterOffset: Math.sin(angle) * Dims.l(40)
+ }
+ font {
+ pixelSize: index % 2 ? Dims.l(8) : Dims.l(10)
+ capitalization: Font.Capitalize
+ styleName: "Condensed Bold"
+ kerning: true
+ preferShaping: true
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/SettingsPage.qml b/src/SettingsPage.qml
new file mode 100644
index 0000000..c5c81f1
--- /dev/null
+++ b/src/SettingsPage.qml
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2023 Arseniy Movshev <dodoradio@outlook.com>
+ * 2019 Florent Revest <revestflo@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.15
+import org.asteroid.utils 1.0
+import org.asteroid.controls 1.0
+import QtSensors 5.11
+import Nemo.Configuration 1.0
+
+Item {
+ PageHeader {
+ text: "Settings"
+ z: 5
+ }
+ Flickable {
+ anchors.fill: parent
+ contentHeight: contentColumn.implicitHeight
+ Column {
+ id: contentColumn
+ anchors.fill: parent
+
+ Item { width: parent.width; height: parent.width*0.2}
+ LabeledActionButton {
+ width: parent.width
+ height: width*0.2
+ text: qsTr("Adjust barometer")
+ icon: "ios-settings-outline"
+ onClicked: pageStack.push(barometerAdjustDialog,{})
+ }
+ }
+ }
+ PressureSensor {
+ id: pressureSensor
+ active: true
+ }
+ ConfigurationValue {
+ id: barometerOffset
+ key: "/org/asteroidos/sensors/barometer-offset"
+ defaultValue: 0
+ }
+ Component {
+ id: barometerAdjustDialog
+ Item {
+ id: root
+ Row {
+ id: valueSelector
+ anchors {
+ left: parent.left
+ leftMargin: DeviceInfo.hasRoundScreen ? Dims.w(5) : 0
+ right: parent.right
+ rightMargin: DeviceInfo.hasRoundScreen ? Dims.w(5) : 0
+ verticalCenter: parent.verticalCenter
+ }
+ height: parent.height*0.6
+
+ CircularSpinner {
+ id: hundredsSelector
+ height: parent.height
+ width: parent.width/5
+ model: 11
+ showSeparator: false
+ delegate: SpinnerDelegate { text: index }
+ }
+ CircularSpinner {
+ id: tensSelector
+ height: parent.height
+ width: parent.width/5
+ model: 10
+ delegate: SpinnerDelegate { text: index }
+ }
+ CircularSpinner {
+ id: onesSelector
+ height: parent.height
+ width: parent.width/5
+ model: 10
+ showSeparator: true
+ delegate: SpinnerDelegate { text: index }
+ }
+ CircularSpinner {
+ id: tenthsSelector
+ height: parent.height
+ width: parent.width/5
+ model: 10
+ showSeparator: false
+ delegate: SpinnerDelegate { text: index }
+ }
+ CircularSpinner {
+ id: hundredthsSelector
+ height: parent.height
+ width: parent.width/5
+ model: 10
+ showSeparator: false
+ delegate: SpinnerDelegate { text: index }
+ }
+ }
+
+ Component.onCompleted: {
+ var currValue = barometerOffset.value + pressureSensor.reading.pressure;
+ console.log(currValue)
+ hundredsSelector.currentIndex = Math.floor((currValue/10000))
+ tensSelector.currentIndex = Math.floor((currValue/1000)%10)
+ onesSelector.currentIndex = Math.floor((currValue/100)%10)
+ tenthsSelector.currentIndex = Math.floor((currValue/10)%10)
+ hundredthsSelector.currentIndex = Math.floor(currValue%10)
+ }
+
+ IconButton {
+ iconName: "ios-checkmark-circle-outline"
+ anchors {
+ bottom: parent.bottom
+ horizontalCenter: parent.horizontalCenter
+ bottomMargin: Dims.iconButtonMargin
+ }
+
+ onClicked: {
+ var newValue = hundredsSelector.currentIndex*10000 + tensSelector.currentIndex*1000 + onesSelector.currentIndex*100 + tenthsSelector.currentIndex*10 + hundredthsSelector.currentIndex
+ barometerOffset.value = newValue - pressureSensor.reading.pressure
+ pageStack.pop(pageStack.currentLayer)
+ }
+ }
+ }
+ }
+}
diff --git a/src/main.qml b/src/main.qml
index 70bfc13..5471752 100644
--- a/src/main.qml
+++ b/src/main.qml
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2022 - Darrel Griët <dgriet@gmail.com>
+ * Copyright (C) 2023 Arseniy Movshev <dodoradio@outlook.com>
+ * 2022 - Darrel Griët <dgriet@gmail.com>
* 2017 - Florent Revest <revestflo@gmail.com>
* - Niels Tholenaar <info@123quality.nl>
*
@@ -19,8 +20,8 @@
import QtQuick 2.5
import org.asteroid.controls 1.0
-import QtSensors 5.3
import QtGraphicalEffects 1.15
+import QtQml.Models 2.15
Application {
id: app
@@ -28,94 +29,49 @@ Application {
centerColor: "#29A600"
outerColor: "#070C00"
- property int rotation: 0;
- property int calibration: 0;
- property int ringValueOffset: Math.sqrt(Math.pow(Dims.l(40), 2) / 2);
-
- Compass {
- active: true
- onReadingChanged: {
- app.rotation = reading.azimuth;
- app.calibration = reading.calibrationLevel;
- }
- }
-
- StatusPage {
- //% "<h3>No data</h3>Calibrate the sensor by moving it in an ∞ figure."
- text: qsTrId("id-no-data-calibrate")
- icon: "ios-infinite-outline"
- visible: !app.calibration
- }
-
- Item {
- visible: app.calibration
- anchors.fill: parent
+ LayerStack {
+ id: pageStack
+ firstPage: Component {
+ MouseArea {
+ id: mainPage
+ PathView { // modified from circularspinner in qml-asteroid
+ id: pv
+ width: parent.width
+ height: Dims.h(100)
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ highlightRangeMode: PathView.StrictlyEnforceRange
+ highlightMoveDuration: 0
+ clip: true
+ model: ObjectModel {
+ id: contentColumn
+ Compass {
+ height: pv.height
+ width: pv.width
+ property string name: qsTr("Compass")
+ }
+ Barometer {
+ height: pv.height
+ width: pv.width
+ property string name: qsTr("Barometer")
+ }
+ }
- Item {
- id: centerDisplay
- anchors.fill: parent
- Label {
- id: magneticRotation
- anchors.centerIn: parent
- text: app.rotation
- font {
- pixelSize: parent.height / 4
- capitalization: Font.Capitalize
- styleName: "SemiCondensed"
- kerning: true
- preferShaping: true
- }
- }
- Label {
- id: degreeSymbol
- anchors.top: magneticRotation.top
- anchors.left: magneticRotation.right
- text: "°"
- font {
- pixelSize: parent.height / 4
- capitalization: Font.Capitalize
- styleName: "SemiCondensed"
- kerning: true
- preferShaping: true
+ path: Path {
+ startX: pv.width/2; startY: pv.height/2-pv.count*pv.height/2
+ PathLine { x: pv.width/2; y: pv.height/2+pv.count*pv.height/2 }
+ }
}
- }
- Image {
- anchors.top: parent.top
- anchors.centerIn: parent
- anchors.verticalCenterOffset: -Dims.l(35)
- width: Dims.l(10)
- height: width
- source: "compass.svg"
- }
- }
- Item {
- anchors.fill: parent
- rotation: -app.rotation
- Repeater {
- id: outerRing
- anchors.fill: parent
- model: 8
- Label {
- property var angle: (index / outerRing.count) * 2 * Math.PI
- property var cardinalDirections: ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
- rotation: app.rotation
- color: index == 0 ? "#c2620c" : "white"
- text: cardinalDirections[index]
- anchors {
- centerIn: parent
- verticalCenterOffset: -Math.cos(angle) * Dims.l(40)
- horizontalCenterOffset: Math.sin(angle) * Dims.l(40)
- }
- font {
- pixelSize: index % 2 ? Dims.l(8) : Dims.l(10)
- capitalization: Font.Capitalize
- styleName: "Condensed Bold"
- kerning: true
- preferShaping: true
- }
+ PageHeader {
+ text: pv.currentItem.name
+ z: 5
}
}
}
}
+ Component {
+ id: settingsPage
+ SettingsPage {}
+ }
}
diff --git a/src/resources.qrc b/src/resources.qrc
index acd1a74..804fc9e 100644
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -1,6 +1,9 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
+ <file>Compass.qml</file>
+ <file>Barometer.qml</file>
<file>compass.svg</file>
+ <file>SettingsPage.qml</file>
</qresource>
</RCC>