diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 3e1193db..baeba0ef 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1092,6 +1092,8 @@ type settings struct { OwnshipModeS string WatchList string DeveloperMode bool + AHRSSmoothingConstant float64 + AHRSGPSWeight float64 StaticIps []string } diff --git a/main/managementinterface.go b/main/managementinterface.go index 7807ce29..6f49513e 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -324,6 +324,16 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) { } case "WatchList": globalSettings.WatchList = val.(string) + case "AHRSSmoothingConstant": + log.Printf("AHRS Info: received %s for Smoothing Const\n", val) + globalSettings.AHRSSmoothingConstant = val.(float64) + SetAHRSConfig(globalSettings.AHRSSmoothingConstant, globalSettings.AHRSGPSWeight) + log.Printf("AHRS Info: Smoothing Constant set to %6f\n", globalSettings.AHRSSmoothingConstant) + case "AHRSGPSWeight": + log.Printf("AHRS Info: received %s for GPS Weight\n", val) + globalSettings.AHRSGPSWeight = val.(float64) + SetAHRSConfig(globalSettings.AHRSSmoothingConstant, globalSettings.AHRSGPSWeight) + log.Printf("AHRS Info: GPS Weight set to %6f\n", globalSettings.AHRSGPSWeight) case "OwnshipModeS": // Expecting a hex string less than 6 characters (24 bits) long. if len(val.(string)) > 6 { // Too long. diff --git a/main/sensors.go b/main/sensors.go index 3b07a952..924bae52 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -149,6 +149,7 @@ func sensorAttitudeSender() { ) log.Println("AHRS Info: initializing new Simple AHRS") s = ahrs.InitializeSimple() + SetAHRSConfig(globalSettings.AHRSSmoothingConstant, globalSettings.AHRSGPSWeight) m = ahrs.NewMeasurement() cage = make(chan (bool), 1) @@ -355,6 +356,11 @@ func CageAHRS() { cage <- true } +// SetAHRSConfig TODO westphae remove after debugging +func SetAHRSConfig(smoothConst, weight float64) { + ahrs.SetConfig(smoothConst, weight) +} + func updateAHRSStatus() { var ( msg uint8 diff --git a/web/plates/js/settings.js b/web/plates/js/settings.js index 2d8bb08b..0dfdadcb 100644 --- a/web/plates/js/settings.js +++ b/web/plates/js/settings.js @@ -37,6 +37,8 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.PPM = settings.PPM; $scope.WatchList = settings.WatchList; + $scope.AHRSSmoothingConstant = settings.AHRSSmoothingConstant; + $scope.AHRSGPSWeight = settings.AHRSGPSWeight; $scope.OwnshipModeS = settings.OwnshipModeS; $scope.DeveloperMode = settings.DeveloperMode; } @@ -114,14 +116,42 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { } }; - $scope.updatewatchlist = function () { - if ($scope.WatchList !== settings["WatchList"]) { - settings["WatchList"] = ""; - if ($scope.WatchList !== undefined) { - settings["WatchList"] = $scope.WatchList.toUpperCase(); + $scope.updatewatchlist = function () { + if ($scope.WatchList !== settings["WatchList"]) { + settings["WatchList"] = ""; + if ($scope.WatchList !== undefined) { + settings["WatchList"] = $scope.WatchList.toUpperCase(); + } + newsettings = { + "WatchList": settings["WatchList"] + }; + // console.log(angular.toJson(newsettings)); + setSettings(angular.toJson(newsettings)); + } + }; + + $scope.updateAHRSSmoothingConst = function () { + if ($scope.AHRSSmoothingConstant !== settings["AHRSSmoothingConstant"]) { + settings["AHRSSmoothingConstant"] = "0.8"; + if ($scope.AHRSSmoothingConstant!== undefined) { + settings["AHRSSmoothingConstant"] = parseFloat($scope.AHRSSmoothingConstant); + } + newsettings = { + "AHRSSmoothingConstant": settings["AHRSSmoothingConstant"] + }; + // console.log(angular.toJson(newsettings)); + setSettings(angular.toJson(newsettings)); + } + }; + + $scope.updateAHRSGPSWeight = function () { + if ($scope.AHRSGPSWeight !== settings["AHRSGPSWeight"]) { + settings["AHRSGPSWeight"] = "0.05"; + if ($scope.AHRSGPSWeight!== undefined) { + settings["AHRSGPSWeight"] = parseFloat($scope.AHRSGPSWeight); } newsettings = { - "WatchList": settings["WatchList"] + "AHRSGPSWeight": settings["AHRSGPSWeight"] }; // console.log(angular.toJson(newsettings)); setSettings(angular.toJson(newsettings)); diff --git a/web/plates/settings.html b/web/plates/settings.html index 52768ba7..89fd9975 100644 --- a/web/plates/settings.html +++ b/web/plates/settings.html @@ -82,9 +82,25 @@
- +
+
+ +
+ +
+
+
+ +
+ +
+