aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordodoradio <dodoradio@outlook.com>2023-07-12 20:28:18 +0100
committerdodoradio <dodoradio@outlook.com>2023-07-12 22:28:51 +0100
commit34f0cb81fe8f6133c5d6d5c26af69486aa6d24ef (patch)
treecf47ffe8eb244056d73f179ccd5ad7794829f23d /src
parent73cbf360e599a184d85ea220b13ffc70b308d4e7 (diff)
Fix inverted altimeter behaviour and allow negative altimeter calibrations
The altimeter was erroneously made to add to the sea level air pressure instead of subtracting from it, which resulted in inverted behaviour. This has now been fixed. This also allows setting a negative altimeter offset
Diffstat (limited to 'src')
-rw-r--r--src/Altimeter.qml4
-rw-r--r--src/SettingsPage.qml30
2 files changed, 24 insertions, 10 deletions
diff --git a/src/Altimeter.qml b/src/Altimeter.qml
index ae71493..3ee11ac 100644
--- a/src/Altimeter.qml
+++ b/src/Altimeter.qml
@@ -44,13 +44,13 @@ Item {
id: pressureText
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
- text: Math.round(pressureSensor.reading.pressure/12 + altimeterOffset.value)
+ text: Math.round(-pressureSensor.reading.pressure/12 + altimeterOffset.value)
font.pixelSize: parent.height / 4
}
ConfigurationValue {
id: altimeterOffset
key: "/org/asteroidos/sensors/altimeter-offset"
- defaultValue: -8443
+ defaultValue: 8443
}
Label {
anchors.horizontalCenter: parent.horizontalCenter
diff --git a/src/SettingsPage.qml b/src/SettingsPage.qml
index 4d36e7f..a0744a1 100644
--- a/src/SettingsPage.qml
+++ b/src/SettingsPage.qml
@@ -63,7 +63,7 @@ Item {
ConfigurationValue {
id: altimeterOffset
key: "/org/asteroidos/sensors/altimeter-offset"
- defaultValue: -8443
+ defaultValue: 8443
}
Component {
id: barometerAdjustDialog
@@ -163,9 +163,17 @@ Item {
height: parent.height*0.6
CircularSpinner {
+ id: signSelector
+ height: parent.height
+ width: parent.width/5
+ model: 2
+ showSeparator: false
+ delegate: SpinnerDelegate { text: index ? "-" : "+" }
+ }
+ CircularSpinner {
id: thousandsSelector
height: parent.height
- width: parent.width/3
+ width: parent.width/5
model: 10
showSeparator: false
delegate: SpinnerDelegate { text: index }
@@ -173,7 +181,7 @@ Item {
CircularSpinner {
id: hundredsSelector
height: parent.height
- width: parent.width/4
+ width: parent.width/5
model: 10
showSeparator: false
delegate: SpinnerDelegate { text: index }
@@ -181,23 +189,26 @@ Item {
CircularSpinner {
id: tensSelector
height: parent.height
- width: parent.width/4
+ width: parent.width/5
model: 10
delegate: SpinnerDelegate { text: index }
}
CircularSpinner {
id: onesSelector
height: parent.height
- width: parent.width/4
+ width: parent.width/5
model: 10
- showSeparator: true
delegate: SpinnerDelegate { text: index }
}
}
Component.onCompleted: {
- var currValue = Math.round(altimeterOffset.value + pressureSensor.reading.pressure/12);
+ var currValue = Math.round(altimeterOffset.value - pressureSensor.reading.pressure/12);
console.log(currValue)
+ if (currValue < 0) {
+ currValue = -currValue
+ signSelector.currentIndex = 1
+ }
thousandsSelector.currentIndex = Math.floor((currValue/1000))
hundredsSelector.currentIndex = Math.floor((currValue/100)%10)
tensSelector.currentIndex = Math.floor((currValue/10)%10)
@@ -214,7 +225,10 @@ Item {
onClicked: {
var newValue = thousandsSelector.currentIndex*1000 + hundredsSelector.currentIndex*100 + tensSelector.currentIndex*10 + onesSelector.currentIndex
- altimeterOffset.value = newValue - Math.round(pressureSensor.reading.pressure/12)
+ if (signSelector.currentIndex) {
+ newValue = -newValue
+ }
+ altimeterOffset.value = Math.round(pressureSensor.reading.pressure/12) + newValue
pageStack.pop(pageStack.currentLayer)
}
}