AHRS settings in the UI

pull/610/head
Eric Westphal 2017-05-12 20:40:53 -04:00
rodzic a6f9aaf9f5
commit 338f1cc934
5 zmienionych plików z 71 dodań i 7 usunięć

Wyświetl plik

@ -1092,6 +1092,8 @@ type settings struct {
OwnshipModeS string
WatchList string
DeveloperMode bool
AHRSSmoothingConstant float64
AHRSGPSWeight float64
StaticIps []string
}

Wyświetl plik

@ -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.

Wyświetl plik

@ -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

Wyświetl plik

@ -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));

Wyświetl plik

@ -82,9 +82,25 @@
<div class="panel-body">
<div class="col-xs-12">
<span style="position:relative; overflow: hidden;">
<button class="btn btn-primary btn-block" ui-turn-on="modalCalibrateForward">Set AHRS Sensor Orientation</button>
<button class="btn btn-primary btn-block" ui-turn-on="modalCalibrateForward">
Set AHRS Sensor Orientation
</button>
</span>
</div>
<div class="form-group reset-flow">
<label class="control-label col-xs-5">AHRS Smoothing Constant</label>
<form name="watchForm" ng-submit="updateAHRSSmoothingConst()" novalidate>
<input class="col-xs-7" type="string" required ng-model="AHRSSmoothingConstant"
placeholder="number 0-1" ng-blur="updateAHRSSmoothingConst()" />
</form>
</div>
<div class="form-group reset-flow">
<label class="control-label col-xs-5">AHRS GPS Weight</label>
<form name="watchForm" ng-submit="updateAHRSGPSWeight()" novalidate>
<input class="col-xs-7" type="string" required ng-model="AHRSGPSWeight"
placeholder="number 0-1" ng-blur="updateAHRSGPSWeight()" />
</form>
</div>
</div>
</div>
</div>