Skip to content

Commit

Permalink
Merge pull request mavlink#5153 from DonLakeFlyer/AltSliderUnits
Browse files Browse the repository at this point in the history
Altitude Slider: Respect app units
  • Loading branch information
DonLakeFlyer authored May 15, 2017
2 parents c7a9943 + f41429a commit 2cf4fb8
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/FlightDisplay/GuidedAltitudeSlider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Rectangle {
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property real _vehicleAltitude: _activeVehicle ? _activeVehicle.altitudeRelative.rawValue : 0
property bool _fixedWing: _activeVehicle ? _activeVehicle.fixedWing : false
property real _sliderMaxAlt: _fixedWing ? _guidedSettings.fixedWingMaximumAltitude.value : _guidedSettings.vehicleMaximumAltitude.value
property real _sliderMinAlt: _fixedWing ? _guidedSettings.fixedWingMinimumAltitude.value : _guidedSettings.vehicleMinimumAltitude.value
property real _sliderMaxAlt: _fixedWing ? _guidedSettings.fixedWingMaximumAltitude.rawValue : _guidedSettings.vehicleMaximumAltitude.rawValue
property real _sliderMinAlt: _fixedWing ? _guidedSettings.fixedWingMinimumAltitude.rawValue : _guidedSettings.vehicleMinimumAltitude.rawValue

function reset() {
altSlider.value = 0
}

function getValue() {
return altField.newAltitude - _vehicleAltitude
return altField.newAltitudeMeters - _vehicleAltitude
}

function log10(value) {
Expand Down Expand Up @@ -62,13 +62,14 @@ Rectangle {
QGCLabel {
id: altField
anchors.horizontalCenter: parent.horizontalCenter
text: Math.abs(newAltitude.toFixed(1)) + " " + QGroundControl.appSettingsDistanceUnitsString
text: newAltitudeAppUnits + " " + QGroundControl.appSettingsDistanceUnitsString

property real altGainRange: Math.max(_sliderMaxAlt - _vehicleAltitude, 0)
property real altLossRange: Math.max(_vehicleAltitude - _sliderMinAlt, 0)
property real altExp: Math.pow(altSlider.value, 3)
property real altLossGain: altExp * (altSlider.value > 0 ? altGainRange : altLossRange)
property real newAltitude: _vehicleAltitude + altLossGain // QGroundControl.metersToAppSettingsDistanceUnits(_root._vehicleAltitude + altSlider.value).toFixed(1)
property real altGainRange: Math.max(_sliderMaxAlt - _vehicleAltitude, 0)
property real altLossRange: Math.max(_vehicleAltitude - _sliderMinAlt, 0)
property real altExp: Math.pow(altSlider.value, 3)
property real altLossGain: altExp * (altSlider.value > 0 ? altGainRange : altLossRange)
property real newAltitudeMeters: _vehicleAltitude + altLossGain
property string newAltitudeAppUnits: QGroundControl.metersToAppSettingsDistanceUnits(newAltitudeMeters).toFixed(1)
}
}

Expand Down

0 comments on commit 2cf4fb8

Please sign in to comment.