Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pressure altitude offset setting #828

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dump978/uat2text
gen_gdl90
libdump978.so
fancontrol
equations

*.mp4

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ xgen_gdl90:

fancontrol:
go get -t -d -v ./main
go build $(BUILDINFO_STATIC) -p 4 main/fancontrol.go main/equations.go main/cputemp.go
go build $(BUILDINFO_STATIC) -p 4 -o fancontrol main/fancontrol.go main/equations.go main/cputemp.go

xdump1090:
git submodule update --init
Expand Down
2 changes: 1 addition & 1 deletion godump978/godump978_exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

/*
#cgo CFLAGS: -L../
#cgo CFLAGS: -I../

#include <stdint.h>
#include "../dump978/dump978.h"
Expand Down
4 changes: 2 additions & 2 deletions main/equations.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ func distance(lat1, lon1, lat2, lon2 float64) (dist, bearing float64) {
}

// CalcAltitude determines the pressure altitude (feet) from the atmospheric pressure (hPa)
func CalcAltitude(press float64) (altitude float64) {
altitude = 145366.45 * (1.0 - math.Pow(press/1013.25, 0.190284))
func CalcAltitude(press float64, altoffset int) (altitude float64) {
altitude = 145366.45 * (1.0 - math.Pow(press/1013.25, 0.190284)) + float64(altoffset)
return
}

Expand Down
1 change: 1 addition & 0 deletions main/gen_gdl90.go
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ type settings struct {
SensorQuaternion [4]float64 // Quaternion mapping from sensor frame to aircraft frame
C, D [3]float64 // IMU Accel, Gyro zero bias
PPM int
AltitudeOffset int
OwnshipModeS string
WatchList string
DeveloperMode bool
Expand Down
2 changes: 2 additions & 0 deletions main/managementinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
}
case "PPM":
globalSettings.PPM = int(val.(float64))
case "AltitudeOffset":
globalSettings.AltitudeOffset = int(val.(float64))
case "Baud":
if serialOut, ok := globalSettings.SerialOutputs["/dev/serialout0"]; ok { //FIXME: Only one device for now.
newBaud := int(val.(float64))
Expand Down
2 changes: 1 addition & 1 deletion main/sensors.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func tempAndPressureSender() {
mySituation.muBaro.Lock()
mySituation.BaroLastMeasurementTime = stratuxClock.Time
mySituation.BaroTemperature = float32(temp)
altitude = CalcAltitude(press)
altitude = CalcAltitude(press,globalSettings.AltitudeOffset)
mySituation.BaroPressureAltitude = float32(altitude)
if altLast < -2000 {
altLast = altitude // Initialize
Expand Down
1 change: 1 addition & 0 deletions notes/app-vendor-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Stratux makes available a webserver to retrieve statistics which may be useful t
-1.890621662038
],
"PPM": 0,
"AltitudeOffset": 0,
"OwnshipModeS": "F00000",
"WatchList": "",
"DeveloperMode": false,
Expand Down
15 changes: 15 additions & 0 deletions web/plates/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
$scope.AHRSLog = settings.AHRSLog;

$scope.PPM = settings.PPM;
$scope.AltitudeOffset = settings.AltitudeOffset;
$scope.WatchList = settings.WatchList;
$scope.OwnshipModeS = settings.OwnshipModeS;
$scope.DeveloperMode = settings.DeveloperMode;
Expand Down Expand Up @@ -171,6 +172,20 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
}
};

$scope.updatealtitudeoffset = function () {
settings["AltitudeOffset"] = 0;
if (($scope.AltitudeOffset !== undefined) && ($scope.AltitudeOffset !== null) && ($scope.AltitudeOffset !== settings["AltitudeOffset"])) {
settings["AltitudeOffset"] = parseInt($scope.AltitudeOffset);
var newsettings = {
"AltitudeOffset": settings["AltitudeOffset"]
};
// console.log(angular.toJson(newsettings));
setSettings(angular.toJson(newsettings));
}
};



$scope.updateGLimits = function () {
if ($scope.GLimits !== settings["GLimits"]) {
settings["GLimits"] = $scope.GLimits;
Expand Down
9 changes: 9 additions & 0 deletions web/plates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@
ng-blur="updatestaticips()" />
</form>
</div>
<div class="form-group reset-flow">
<label class="control-label col-xs-5">P-Altitude Offset</label>
<form name="altForm" ng-submit="updatealtitudeoffset()" novalidate>
<!-- type="number" not supported except on mobile -->
<input class="col-xs-7" type="number" ng-model="AltitudeOffset" placeholder="integer"
ng-blur="updatealtitudeoffset()" />
</form>
</div>

</div>
</div>
</div>
Expand Down