From 20c1e32ff70eee94178b1e0f50e0e32e2ab53c76 Mon Sep 17 00:00:00 2001 From: Eric Westphal Date: Wed, 17 May 2017 17:32:05 -0400 Subject: [PATCH 1/4] mySituation tracks min/max G Load. --- main/gps.go | 2 ++ main/sensors.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/main/gps.go b/main/gps.go index 4c73ab93..16728ce7 100644 --- a/main/gps.go +++ b/main/gps.go @@ -94,6 +94,8 @@ type SituationData struct { AHRSSlipSkid float32 AHRSTurnRate float32 AHRSGLoad float32 + AHRSGLoadMin float32 + AHRSGLoadMax float32 AHRSLastAttitudeTime time.Time AHRSStatus uint8 } diff --git a/main/sensors.go b/main/sensors.go index 9c50c59d..00a9f736 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -262,6 +262,12 @@ func sensorAttitudeSender() { mySituation.AHRSSlipSkid = float32(s.SlipSkid()) mySituation.AHRSTurnRate = float32(s.RateOfTurn()) mySituation.AHRSGLoad = float32(s.GLoad()) + if mySituation.AHRSGLoad < mySituation.AHRSGLoadMin || mySituation.AHRSGLoadMin == 0 { + mySituation.AHRSGLoadMin = mySituation.AHRSGLoad + } + if mySituation.AHRSGLoad > mySituation.AHRSGLoadMax { + mySituation.AHRSGLoadMax = mySituation.AHRSGLoad + } mySituation.AHRSLastAttitudeTime = t } else { @@ -273,6 +279,8 @@ func sensorAttitudeSender() { mySituation.AHRSSlipSkid = invalid mySituation.AHRSTurnRate = invalid mySituation.AHRSGLoad = invalid + mySituation.AHRSGLoadMin = invalid + mySituation.AHRSGLoadMax = 0 mySituation.AHRSLastAttitudeTime = time.Time{} } mySituation.muAttitude.Unlock() @@ -367,6 +375,12 @@ func CageAHRS() { cage <- true } +// ResetAHRSGLoad resets the min and max to the current G load value. +func ResetAHRSGLoad() { + mySituation.AHRSGLoadMax = mySituation.AHRSGLoad + mySituation.AHRSGLoadMin = mySituation.AHRSGLoad +} + func updateAHRSStatus() { var ( msg uint8 From c1ca21e8fbd7b7953dd862e54bd2d73df93edce8 Mon Sep 17 00:00:00 2001 From: Eric Westphal Date: Wed, 17 May 2017 17:54:32 -0400 Subject: [PATCH 2/4] Web UI G-Meter uses mySituation min/max G Load. --- main/managementinterface.go | 16 ++++++++++++++++ web/js/main.js | 1 + web/plates/js/ahrs.js | 16 +++++----------- web/plates/js/gps.js | 14 +++++++++++--- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/main/managementinterface.go b/main/managementinterface.go index 7807ce29..9344cb05 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -482,6 +482,21 @@ func handleCageAHRS(w http.ResponseWriter, r *http.Request) { } } +func handleResetGMeter(w http.ResponseWriter, r *http.Request) { + // define header in support of cross-domain AJAX + setNoCache(w) + w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Method", "GET, POST, OPTIONS") + w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") + + // For an OPTION method request, we return header without processing. + // This ensures we are recognized as supporting cross-domain AJAX REST calls. + if r.Method == "POST" { + ResetAHRSGLoad() + } +} + func doRestartApp() { time.Sleep(1) syscall.Sync() @@ -731,6 +746,7 @@ func managementInterface() { http.HandleFunc("/orientAHRS", handleOrientAHRS) http.HandleFunc("/cageAHRS", handleCageAHRS) + http.HandleFunc("/resetGMeter", handleResetGMeter) http.HandleFunc("/deletelogfile", handleDeleteLogFile) http.HandleFunc("/downloadlog", handleDownloadLogRequest) diff --git a/web/js/main.js b/web/js/main.js index 23eaa64d..26502120 100755 --- a/web/js/main.js +++ b/web/js/main.js @@ -17,6 +17,7 @@ var URL_RESTARTAPP = "http://" + URL_HOST_BASE + "/restart"; var URL_DEV_TOGGLE_GET = "http://" + URL_HOST_BASE + "/develmodetoggle"; var URL_AHRS_ORIENT = "http://" + URL_HOST_BASE + "/orientAHRS"; var URL_AHRS_CAGE = "http://" + URL_HOST_BASE + "/cageAHRS"; +var URL_GMETER_RESET = "http://" + URL_HOST_BASE + "/resetGMeter"; var URL_DELETELOGFILE = "http://" + URL_HOST_BASE + "/deletelogfile"; var URL_DOWNLOADLOGFILE = "http://" + URL_HOST_BASE + "/downloadlog"; var URL_DOWNLOADDB = "http://" + URL_HOST_BASE + "/downloaddb"; diff --git a/web/plates/js/ahrs.js b/web/plates/js/ahrs.js index 5fffd555..728e4544 100644 --- a/web/plates/js/ahrs.js +++ b/web/plates/js/ahrs.js @@ -143,7 +143,7 @@ AHRSRenderer.prototype = { } }; -function GMeterRenderer(locationId, plim, nlim) { +function GMeterRenderer(locationId, plim, nlim, resetCallback) { this.plim = plim; this.nlim = nlim; this.nticks = Math.floor(plim+1) - Math.floor(nlim) + 1; @@ -215,7 +215,7 @@ function GMeterRenderer(locationId, plim, nlim) { reset.text('RESET').cx(0).cy(0).addClass('text'); reset.on('click', function() { reset.animate(200).rotate(20, 0, 0); - this.reset(); + resetCallback(); reset.animate(200).rotate(0, 0, 0); }, this); } @@ -235,19 +235,13 @@ GMeterRenderer.prototype = { } }, - update: function (g) { + update: function (g, gmin, gmax) { this.g = g; - this.max = g > this.max ? g : this.max; - this.min = g < this.min ? g : this.min; + this.min = gmin; + this.max = gmax; this.pointer_el.animate(50).rotate((g-1)/this.nticks*360, 0, 0); this.max_el.animate(50).rotate((this.max-1)/this.nticks*360, 0, 0); this.min_el.animate(50).rotate((this.min-1)/this.nticks*360, 0, 0); - }, - - reset: function() { - this.g = 1; - this.max = 1; - this.min = 1; } }; diff --git a/web/plates/js/gps.js b/web/plates/js/gps.js index 9e760060..d68e811f 100644 --- a/web/plates/js/gps.js +++ b/web/plates/js/gps.js @@ -175,7 +175,7 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) { if ($scope.ahrs_gload > 360) { $scope.ahrs_gload = "--"; } else { - gMeter.update(situation.AHRSGLoad); + gMeter.update(situation.AHRSGLoad, situation.AHRSGLoadMin, situation.AHRSGLoadMax); } if (situation.AHRSTurnRate > 360) { @@ -204,7 +204,7 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) { } if (situation.AHRSStatus & 0x02) { if (statusIMU.classList.contains("off")) { - setTimeout(gMeter.reset(), 1000); + setTimeout($scope.GMeterReset, 1000); } statusIMU.classList.remove("off"); statusIMU.classList.add("on"); @@ -357,7 +357,15 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) { return caging; }; - var gMeter = new GMeterRenderer("gMeter_display", 4.4, -1.76); + $scope.GMeterReset = function() { + $http.post(URL_GMETER_RESET).then(function (response) { + // do nothing + }, function (response) { + // do nothing + }); + }; + + var gMeter = new GMeterRenderer("gMeter_display", 4.4, -1.76, $scope.GMeterReset); // GPS Controller tasks connect($scope); // connect - opens a socket and listens for messages From d69e195489d6ce99af812474106419ea74e5ac63 Mon Sep 17 00:00:00 2001 From: Eric Westphal Date: Sat, 20 May 2017 08:07:41 -0400 Subject: [PATCH 3/4] Use appropriate defaults for AHRS config. --- goflying | 2 +- main/gen_gdl90.go | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/goflying b/goflying index 06435486..f384d0d3 160000 --- a/goflying +++ b/goflying @@ -1 +1 @@ -Subproject commit 0643548684b88791b8a175e477449a26f2ea9209 +Subproject commit f384d0d328916c6c580c4f8c02c8d5083ad34849 diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 4418096f..c3819452 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1036,26 +1036,26 @@ func getProductNameFromId(product_id int) string { } type settings struct { - UAT_Enabled bool - ES_Enabled bool - Ping_Enabled bool - GPS_Enabled bool - BMP_Sensor_Enabled bool - IMU_Sensor_Enabled bool - NetworkOutputs []networkConnection - SerialOutputs map[string]serialConnection - DisplayTrafficSource bool - DEBUG bool - ReplayLog bool - AHRSLog bool - IMUMapping [2]int // Map from aircraft axis to sensor axis: accelerometer - PPM int - OwnshipModeS string - WatchList string - DeveloperMode bool + UAT_Enabled bool + ES_Enabled bool + Ping_Enabled bool + GPS_Enabled bool + BMP_Sensor_Enabled bool + IMU_Sensor_Enabled bool + NetworkOutputs []networkConnection + SerialOutputs map[string]serialConnection + DisplayTrafficSource bool + DEBUG bool + ReplayLog bool + AHRSLog bool + IMUMapping [2]int // Map from aircraft axis to sensor axis: accelerometer + PPM int + OwnshipModeS string + WatchList string + DeveloperMode bool AHRSSmoothingConstant float64 - AHRSGPSWeight float64 - StaticIps []string + AHRSGPSWeight float64 + StaticIps []string } type status struct { From 14e5c49e57479a0c6dcbbc08d3df08c22c8c2fb5 Mon Sep 17 00:00:00 2001 From: Eric Westphal Date: Sat, 20 May 2017 22:04:57 -0400 Subject: [PATCH 4/4] Add fancontrol to .gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0b2b015c..86d7598d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ dump978/uat2json dump978/uat2text gen_gdl90 libdump978.so +fancontrol *.mp4