From c1859fb0be106228fd08729d7540f01b7d221a58 Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Sun, 27 Dec 2015 17:50:10 -0500 Subject: [PATCH] Set heading from GPS with sustained >=10kts. --- main/ry835ai.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main/ry835ai.go b/main/ry835ai.go index d505e1f3b..6581d354c 100644 --- a/main/ry835ai.go +++ b/main/ry835ai.go @@ -192,10 +192,6 @@ func processNMEALine(l string) bool { return false } trueCourse = uint16(tc) - //FIXME: Experimental. Set heading to true heading on the MPU6050 reader. - if myMPU6050 != nil && globalStatus.RY835AI_connected && globalSettings.AHRS_Enabled { - myMPU6050.ResetHeading(float64(tc)) - } } else { // No movement. mySituation.TrueCourse = 0 @@ -208,6 +204,16 @@ func processNMEALine(l string) bool { return false } + //FIXME: Experimental. Set heading to true heading on the MPU6050 reader. + if myMPU6050 != nil && globalStatus.RY835AI_connected && globalSettings.AHRS_Enabled { + // Only count this heading if a "sustained" >10kts is obtained. This filters out a lot of heading + // changes while on the ground and "movement" is really only changes in GPS fix as it settles down. + //TODO: Some more robust checking above current and last speed. + if mySituation.GroundSpeed >= 10 && uint16(groundSpeed) >= 10 { + myMPU6050.ResetHeading(float64(trueCourse)) + } + } + mySituation.TrueCourse = uint16(trueCourse) mySituation.GroundSpeed = uint16(groundSpeed) mySituation.LastGroundTrackTime = time.Now()