From 3db11bd09d7b36a642d66210291c7da7ffe9da67 Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Mon, 15 May 2017 22:22:32 -0400 Subject: [PATCH] Add goflying submodule. Change imports. --- .gitmodules | 3 +++ Makefile | 2 -- goflying | 1 + main/sensors.go | 26 +++++++++++++------------- sensors/bmp280.go | 2 +- sensors/mpu9250.go | 12 ++++++------ 6 files changed, 24 insertions(+), 22 deletions(-) create mode 160000 goflying diff --git a/.gitmodules b/.gitmodules index 13a52a3c..97641a87 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "dump1090"] path = dump1090 url = https://github.com/AvSquirrel/dump1090 +[submodule "goflying"] + path = goflying + url = https://github.com/westphae/goflying diff --git a/Makefile b/Makefile index 1e52c0da..c5173108 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,6 @@ all: xgen_gdl90: go get -t -d -v ./main ./test ./godump978 ./uatparse ./sensors - go get -u github.com/westphae/goflying/ahrs - go get -u github.com/westphae/goflying/ahrsweb go build $(BUILDINFO) -p 4 main/gen_gdl90.go main/traffic.go main/gps.go main/network.go main/managementinterface.go main/sdr.go main/ping.go main/uibroadcast.go main/monotonic.go main/datalog.go main/equations.go main/sensors.go main/cputemp.go fancontrol: diff --git a/goflying b/goflying new file mode 160000 index 00000000..ba2ef8b1 --- /dev/null +++ b/goflying @@ -0,0 +1 @@ +Subproject commit ba2ef8b155f74b3e7108b98b5ddbc92826b0cec3 diff --git a/main/sensors.go b/main/sensors.go index f2898f50..9c50c59d 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -9,15 +9,15 @@ import ( "../sensors" + "../goflying/ahrs" + "../goflying/ahrsweb" "github.com/kidoman/embd" _ "github.com/kidoman/embd/host/all" - "github.com/westphae/goflying/ahrs" - "github.com/westphae/goflying/ahrsweb" ) const ( - numRetries uint8 = 5 - invalid float32 = float32(ahrs.Invalid) + numRetries uint8 = 5 + invalid float32 = float32(ahrs.Invalid) ) var ( @@ -142,15 +142,15 @@ func initIMU() (ok bool) { func sensorAttitudeSender() { var ( - roll, pitch, heading float64 - t time.Time - s ahrs.AHRSProvider - m *ahrs.Measurement - a, b, c, d, mm [3]float64 // IMU measurements: accel, gyro, accel bias, gyro bias, magnetometer - ff [3][3]float64 // Sensor orientation matrix - cc float64 - mpuError, magError error - failnum uint8 + roll, pitch, heading float64 + t time.Time + s ahrs.AHRSProvider + m *ahrs.Measurement + a, b, c, d, mm [3]float64 // IMU measurements: accel, gyro, accel bias, gyro bias, magnetometer + ff [3][3]float64 // Sensor orientation matrix + cc float64 + mpuError, magError error + failnum uint8 ) log.Println("AHRS Info: initializing new Simple AHRS") s = ahrs.InitializeSimple() diff --git a/sensors/bmp280.go b/sensors/bmp280.go index baa7608b..ecc6210c 100644 --- a/sensors/bmp280.go +++ b/sensors/bmp280.go @@ -5,8 +5,8 @@ import ( "errors" "time" + "../goflying/bmp280" "github.com/kidoman/embd" - "github.com/westphae/goflying/bmp280" ) const ( diff --git a/sensors/mpu9250.go b/sensors/mpu9250.go index d04ab467..0ad98746 100644 --- a/sensors/mpu9250.go +++ b/sensors/mpu9250.go @@ -5,19 +5,19 @@ import ( "log" "time" - "github.com/westphae/goflying/mpu9250" + "../goflying/mpu9250" ) const ( gyroRange = 250 // gyroRange is the default range to use for the Gyro. - accelRange = 4 // accelRange is the default range to use for the Accel. - updateFreq = 50 // updateFreq is the rate at which to update the sensor values. + accelRange = 4 // accelRange is the default range to use for the Accel. + updateFreq = 50 // updateFreq is the rate at which to update the sensor values. ) // MPU9250 represents an InvenSense MPU9250 attached to the I2C bus and satisfies // the IMUReader interface. type MPU9250 struct { - mpu *mpu9250.MPU9250 + mpu *mpu9250.MPU9250 } // NewMPU9250 returns an instance of the MPU9250 IMUReader, connected to an @@ -52,11 +52,11 @@ func NewMPU9250() (*MPU9250, error) { func (m *MPU9250) Read() (T int64, G1, G2, G3, A1, A2, A3, M1, M2, M3 float64, GAError, MAGError error) { var ( data *mpu9250.MPUData - i int8 + i int8 ) data = new(mpu9250.MPUData) - for data.N==0 && i < 5 { + for data.N == 0 && i < 5 { data = <-m.mpu.CAvg T = data.T.UnixNano() G1 = data.G1