kopia lustrzana https://github.com/cyoung/stratux
Separate UI switches for BMP and IMU connected.
rodzic
c34592e347
commit
1344515c93
|
@ -468,7 +468,7 @@ func makeStratuxStatus() []byte {
|
|||
}
|
||||
|
||||
// Valid/Enabled: AHRS Enabled portion.
|
||||
if globalSettings.Sensors_Enabled {
|
||||
if globalSettings.IMU_Sensor_Enabled {
|
||||
msg[12] = 1 << 0
|
||||
}
|
||||
|
||||
|
@ -1033,7 +1033,8 @@ type settings struct {
|
|||
ES_Enabled bool
|
||||
Ping_Enabled bool
|
||||
GPS_Enabled bool
|
||||
Sensors_Enabled bool
|
||||
BMP_Sensor_Enabled bool
|
||||
IMU_Sensor_Enabled bool
|
||||
NetworkOutputs []networkConnection
|
||||
SerialOutputs map[string]serialConnection
|
||||
DisplayTrafficSource bool
|
||||
|
@ -1086,7 +1087,7 @@ type status struct {
|
|||
UAT_PIREP_total uint32
|
||||
UAT_NOTAM_total uint32
|
||||
UAT_OTHER_total uint32
|
||||
PressureSensorConnected bool
|
||||
BMPConnected bool
|
||||
IMUConnected bool
|
||||
|
||||
Errors []string
|
||||
|
@ -1099,7 +1100,8 @@ func defaultSettings() {
|
|||
globalSettings.UAT_Enabled = true
|
||||
globalSettings.ES_Enabled = true
|
||||
globalSettings.GPS_Enabled = true
|
||||
globalSettings.Sensors_Enabled = true
|
||||
globalSettings.IMU_Sensor_Enabled = true
|
||||
globalSettings.BMP_Sensor_Enabled = true
|
||||
//FIXME: Need to change format below.
|
||||
globalSettings.NetworkOutputs = []networkConnection{
|
||||
{Conn: nil, Ip: "", Port: 4000, Capability: NETWORK_GDL90_STANDARD | NETWORK_AHRS_GDL90},
|
||||
|
@ -1211,8 +1213,11 @@ func printStats() {
|
|||
log.Printf(" - Last GPS fix: %s, GPS solution type: %d using %d satellites (%d/%d seen/tracked), NACp: %d, est accuracy %.02f m\n", stratuxClock.HumanizeTime(mySituation.LastFixLocalTime), mySituation.Quality, mySituation.Satellites, mySituation.SatellitesSeen, mySituation.SatellitesTracked, mySituation.NACp, mySituation.Accuracy)
|
||||
log.Printf(" - GPS vertical velocity: %.02f ft/sec; GPS vertical accuracy: %v m\n", mySituation.GPSVertVel, mySituation.AccuracyVert)
|
||||
}
|
||||
if globalSettings.Sensors_Enabled {
|
||||
log.Printf(" - Last IMU read: %s, Last BMP read: %s\n", stratuxClock.HumanizeTime(mySituation.LastAttitudeTime), stratuxClock.HumanizeTime(mySituation.LastTempPressTime))
|
||||
if globalSettings.IMU_Sensor_Enabled {
|
||||
log.Printf(" - Last IMU read: %s\n", stratuxClock.HumanizeTime(mySituation.LastAttitudeTime))
|
||||
}
|
||||
if globalSettings.BMP_Sensor_Enabled {
|
||||
log.Printf(" - Last BMP read: %s\n", stratuxClock.HumanizeTime(mySituation.LastTempPressTime))
|
||||
}
|
||||
// Check if we're using more than 95% of the free space. If so, throw a warning (only once).
|
||||
if !diskUsageWarning && usage.Usage() > 95.0 {
|
||||
|
|
|
@ -1876,7 +1876,7 @@ func gpsAttitudeSender() {
|
|||
for {
|
||||
<-timer.C
|
||||
myGPSPerfStats = make([]gpsPerfStats, 0) // reinitialize statistics on disconnect / reconnect
|
||||
for !(globalSettings.Sensors_Enabled && globalStatus.IMUConnected) && (globalSettings.GPS_Enabled && globalStatus.GPS_connected) {
|
||||
for !(globalSettings.IMU_Sensor_Enabled && globalStatus.IMUConnected) && (globalSettings.GPS_Enabled && globalStatus.GPS_connected) {
|
||||
<-timer.C
|
||||
|
||||
if mySituation.Quality == 0 || !calcGPSAttitude() {
|
||||
|
|
|
@ -274,11 +274,15 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
|
|||
globalSettings.Ping_Enabled = val.(bool)
|
||||
case "GPS_Enabled":
|
||||
globalSettings.GPS_Enabled = val.(bool)
|
||||
case "Sensors_Enabled":
|
||||
globalSettings.Sensors_Enabled = val.(bool)
|
||||
if !globalSettings.Sensors_Enabled {
|
||||
case "IMU_Sensor_Enabled":
|
||||
globalSettings.IMU_Sensor_Enabled = val.(bool)
|
||||
if !globalSettings.IMU_Sensor_Enabled {
|
||||
globalStatus.IMUConnected = false
|
||||
globalStatus.PressureSensorConnected = false
|
||||
}
|
||||
case "BMP_Sensor_Enabled":
|
||||
globalSettings.BMP_Sensor_Enabled = val.(bool)
|
||||
if !globalSettings.BMP_Sensor_Enabled {
|
||||
globalStatus.BMPConnected = false
|
||||
}
|
||||
case "DEBUG":
|
||||
globalSettings.DEBUG = val.(bool)
|
||||
|
|
|
@ -37,14 +37,14 @@ func pollSensors() {
|
|||
<-timer.C
|
||||
|
||||
// If it's not currently connected, try connecting to pressure sensor
|
||||
if globalSettings.Sensors_Enabled && !globalStatus.PressureSensorConnected {
|
||||
if globalSettings.BMP_Sensor_Enabled && !globalStatus.BMPConnected {
|
||||
log.Println("AHRS Info: attempting pressure sensor connection.")
|
||||
globalStatus.PressureSensorConnected = initPressureSensor() // I2C temperature and pressure altitude.
|
||||
globalStatus.BMPConnected = initPressureSensor() // I2C temperature and pressure altitude.
|
||||
go tempAndPressureSender()
|
||||
}
|
||||
|
||||
// If it's not currently connected, try connecting to IMU
|
||||
if globalSettings.Sensors_Enabled && !globalStatus.IMUConnected {
|
||||
if globalSettings.IMU_Sensor_Enabled && !globalStatus.IMUConnected {
|
||||
log.Println("AHRS Info: attempting IMU connection.")
|
||||
globalStatus.IMUConnected = initIMU() // I2C accel/gyro/mag.
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func initPressureSensor() (ok bool) {
|
|||
// if err != nil {
|
||||
// time.Sleep(250 * time.Millisecond)
|
||||
// } else {
|
||||
// globalStatus.PressureSensorConnected = true
|
||||
// globalStatus.BMPConnected = true
|
||||
// log.Println("AHRS Info: Successfully initialized BMP180")
|
||||
// return nil
|
||||
// }
|
||||
|
@ -91,7 +91,7 @@ func tempAndPressureSender() {
|
|||
u := 5 / (5 + float64(dt)) // Use 5 sec decay time for rate of climb, slightly faster than typical VSI
|
||||
|
||||
timer := time.NewTicker(time.Duration(1000*dt) * time.Millisecond)
|
||||
for globalSettings.Sensors_Enabled && globalStatus.PressureSensorConnected {
|
||||
for globalSettings.BMP_Sensor_Enabled && globalStatus.BMPConnected {
|
||||
<-timer.C
|
||||
|
||||
// Read temperature and pressure altitude.
|
||||
|
@ -106,7 +106,7 @@ func tempAndPressureSender() {
|
|||
if failnum > numRetries {
|
||||
log.Printf("AHRS Error: Couldn't read pressure from sensor %d times, closing BMP: %s", failnum, err)
|
||||
myPressureReader.Close()
|
||||
globalStatus.PressureSensorConnected = false // Try reconnecting a little later
|
||||
globalStatus.BMPConnected = false // Try reconnecting a little later
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ func sensorAttitudeSender() {
|
|||
|
||||
failnum = 0
|
||||
<-timer.C
|
||||
for globalSettings.Sensors_Enabled && globalStatus.IMUConnected {
|
||||
for globalSettings.IMU_Sensor_Enabled && globalStatus.IMUConnected {
|
||||
<-timer.C
|
||||
select {
|
||||
case <-cage:
|
||||
|
@ -263,7 +263,7 @@ func sensorAttitudeSender() {
|
|||
if m.WValid {
|
||||
m.W1 = mySituation.GroundSpeed * math.Sin(float64(mySituation.TrueCourse) * ahrs.Deg)
|
||||
m.W2 = mySituation.GroundSpeed * math.Cos(float64(mySituation.TrueCourse) * ahrs.Deg)
|
||||
if globalStatus.PressureSensorConnected {
|
||||
if globalSettings.BMP_Sensor_Enabled && globalStatus.BMPConnected {
|
||||
m.W3 = mySituation.RateOfClimb * 60 / 6076.12
|
||||
} else {
|
||||
m.W3 = float64(mySituation.GPSVertVel) * 3600 / 6076.12
|
||||
|
|
|
@ -94,7 +94,13 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) {
|
|||
/* not currently used
|
||||
$scope.ahrs_temp = status.Temp;
|
||||
*/
|
||||
$scope.ahrs_alt = Math.round(status.Pressure_alt);
|
||||
$scope.press_time = Date.parse(status.LastTempPressTime);
|
||||
$scope.gps_time = Date.parse(status.LastGPSTimeTime);
|
||||
if ($scope.gps_time - $scope.press_time < 1000) {
|
||||
$scope.ahrs_alt = Math.round(status.Pressure_alt);
|
||||
} else {
|
||||
$scope.ahrs_alt = "---";
|
||||
}
|
||||
|
||||
$scope.ahrs_heading = Math.round(status.Gyro_heading);
|
||||
// pitch and roll are in degrees
|
||||
|
|
|
@ -6,7 +6,8 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
|
|||
|
||||
$scope.$parent.helppage = 'plates/settings-help.html';
|
||||
|
||||
var toggles = ['UAT_Enabled', 'ES_Enabled', 'Ping_Enabled', 'GPS_Enabled', 'Sensors_Enabled', 'DisplayTrafficSource', 'DEBUG', 'ReplayLog'];
|
||||
var toggles = ['UAT_Enabled', 'ES_Enabled', 'Ping_Enabled', 'GPS_Enabled', 'IMU_Sensor_Enabled',
|
||||
'BMP_Sensor_Enabled', 'DisplayTrafficSource', 'DEBUG', 'ReplayLog'];
|
||||
var settings = {};
|
||||
for (i = 0; i < toggles.length; i++) {
|
||||
settings[toggles[i]] = undefined;
|
||||
|
@ -26,7 +27,8 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
|
|||
$scope.ES_Enabled = settings.ES_Enabled;
|
||||
$scope.Ping_Enabled = settings.Ping_Enabled;
|
||||
$scope.GPS_Enabled = settings.GPS_Enabled;
|
||||
$scope.Sensors_Enabled = settings.Sensors_Enabled;
|
||||
$scope.IMU_Sensor_Enabled = settings.IMU_Sensor_Enabled;
|
||||
$scope.BMP_Sensor_Enabled = settings.BMP_Sensor_Enabled;
|
||||
$scope.DisplayTrafficSource = settings.DisplayTrafficSource;
|
||||
$scope.DEBUG = settings.DEBUG;
|
||||
$scope.ReplayLog = settings.ReplayLog;
|
||||
|
|
|
@ -29,9 +29,15 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-7">Sensors</label>
|
||||
<label class="control-label col-xs-7">Attitude Sensor</label>
|
||||
<div class="col-xs-5">
|
||||
<ui-switch ng-model='Sensors_Enabled' settings-change></ui-switch>
|
||||
<ui-switch ng-model='IMU_Sensor_Enabled' settings-change></ui-switch>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-7">Altitude Sensor</label>
|
||||
<div class="col-xs-5">
|
||||
<ui-switch ng-model='BMP_Sensor_Enabled' settings-change></ui-switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Ładowanie…
Reference in New Issue