diff --git a/main/equations.go b/main/equations.go index a125d974..112e2292 100644 --- a/main/equations.go +++ b/main/equations.go @@ -250,7 +250,7 @@ func degreesHdg(angle float64) float64 { } // roundToInt16 cheaply rounds a float64 to an int16, rather than truncating -func roundToInt16(in float32) (out int16) { +func roundToInt16(in float64) (out int16) { if in >= 0 { out = int16(in + 0.5) } else { diff --git a/main/gps.go b/main/gps.go index 1b5c6cd5..55ba1b7f 100644 --- a/main/gps.go +++ b/main/gps.go @@ -87,15 +87,15 @@ type SituationData struct { // From AHRS source. muAttitude *sync.Mutex - AHRSPitch float32 - AHRSRoll float32 - AHRSGyroHeading float32 - AHRSMagHeading float32 - AHRSSlipSkid float32 - AHRSTurnRate float32 - AHRSGLoad float32 - AHRSGLoadMin float32 - AHRSGLoadMax float32 + AHRSPitch float64 + AHRSRoll float64 + AHRSGyroHeading float64 + AHRSMagHeading float64 + AHRSSlipSkid float64 + AHRSTurnRate float64 + AHRSGLoad float64 + AHRSGLoadMin float64 + AHRSGLoadMax float64 AHRSLastAttitudeTime time.Time AHRSStatus uint8 } @@ -1874,7 +1874,7 @@ func makeAHRSGDL90Report() { } if isTempPressValid() { palt = uint16(mySituation.BaroPressureAltitude + 5000.5) - vs = roundToInt16(mySituation.BaroVerticalSpeed) + vs = roundToInt16(float64(mySituation.BaroVerticalSpeed)) } // Roll. @@ -1936,9 +1936,9 @@ func gpsAttitudeSender() { mySituation.muGPSPerformance.Lock() index := len(myGPSPerfStats) - 1 if index > 1 { - mySituation.AHRSPitch = float32(myGPSPerfStats[index].gpsPitch) - mySituation.AHRSRoll = float32(myGPSPerfStats[index].gpsRoll) - mySituation.AHRSGyroHeading = mySituation.GPSTrueCourse + mySituation.AHRSPitch = myGPSPerfStats[index].gpsPitch + mySituation.AHRSRoll = myGPSPerfStats[index].gpsRoll + mySituation.AHRSGyroHeading = float64(mySituation.GPSTrueCourse) mySituation.AHRSLastAttitudeTime = stratuxClock.Time makeAHRSGDL90Report() diff --git a/main/sensors.go b/main/sensors.go index 6b20df99..a7d2e5fb 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -278,15 +278,15 @@ func sensorAttitudeSender() { mySituation.muAttitude.Lock() if s.Valid() { roll, pitch, heading = s.RollPitchHeading() - mySituation.AHRSRoll = float32(roll / ahrs.Deg) - mySituation.AHRSPitch = float32(pitch / ahrs.Deg) - mySituation.AHRSGyroHeading = float32(heading / ahrs.Deg) + mySituation.AHRSRoll = roll / ahrs.Deg + mySituation.AHRSPitch = pitch / ahrs.Deg + mySituation.AHRSGyroHeading = heading / ahrs.Deg // TODO westphae: until magnetometer calibration is performed, no mag heading mySituation.AHRSMagHeading = ahrs.Invalid - mySituation.AHRSSlipSkid = float32(s.SlipSkid()) - mySituation.AHRSTurnRate = float32(s.RateOfTurn()) - mySituation.AHRSGLoad = float32(s.GLoad()) + mySituation.AHRSSlipSkid = s.SlipSkid() + mySituation.AHRSTurnRate = s.RateOfTurn() + mySituation.AHRSGLoad = s.GLoad() if mySituation.AHRSGLoad < mySituation.AHRSGLoadMin || mySituation.AHRSGLoadMin == 0 { mySituation.AHRSGLoadMin = mySituation.AHRSGLoad } @@ -462,6 +462,6 @@ func updateAHRSStatus() { } } -func isAHRSInvalidValue(val float32) bool { - return math.Abs(float64(val)-float64(ahrs.Invalid)) < 0.01 +func isAHRSInvalidValue(val float64) bool { + return math.Abs(val-ahrs.Invalid) < 0.01 }