kopia lustrzana https://github.com/cyoung/stratux
Merge remote-tracking branch 'origin/master' into ahrs_dev
commit
0678955b01
|
@ -63,19 +63,37 @@ func fanControl(pwmDutyMin int, pin int, tempTarget float32) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
pwmDuty := 0
|
pwmDuty := 0
|
||||||
|
|
||||||
|
tempWhenRampStarted := float32(0.)
|
||||||
for {
|
for {
|
||||||
if temp > (tempTarget + hysteresis) {
|
if temp > (tempTarget + hysteresis) {
|
||||||
|
if tempWhenRampStarted < 1. {
|
||||||
|
tempWhenRampStarted = temp
|
||||||
|
}
|
||||||
pwmDuty = iMax(iMin(pwmDutyMax, pwmDuty+1), pwmDutyMin)
|
pwmDuty = iMax(iMin(pwmDutyMax, pwmDuty+1), pwmDutyMin)
|
||||||
|
if pwmDuty == pwmDutyMax {
|
||||||
|
// At the maximum duty cycle currently.
|
||||||
|
// Has the temperature increased "substantially" since the ramp-up started?
|
||||||
|
if temp > (tempWhenRampStarted + hysteresis) {
|
||||||
|
// Give up. The fan does not like the PWM control.
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if temp < (tempTarget - hysteresis) {
|
} else if temp < (tempTarget - hysteresis) {
|
||||||
pwmDuty = iMax(pwmDuty-1, 0)
|
pwmDuty = iMax(pwmDuty-1, 0)
|
||||||
if pwmDuty < pwmDutyMin {
|
if pwmDuty < pwmDutyMin {
|
||||||
pwmDuty = 0
|
pwmDuty = 0
|
||||||
|
tempWhenRampStarted = 0.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//log.Println(temp, " ", pwmDuty)
|
//log.Println(temp, " ", pwmDuty)
|
||||||
C.pwmWrite(cPin, C.int(pwmDuty))
|
C.pwmWrite(cPin, C.int(pwmDuty))
|
||||||
time.Sleep(delaySeconds * time.Second)
|
time.Sleep(delaySeconds * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default to "ON".
|
||||||
|
C.pinMode(cPin, C.OUTPUT)
|
||||||
|
C.digitalWrite(cPin, C.HIGH)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Service has embedded daemon
|
// Service has embedded daemon
|
||||||
|
|
|
@ -223,7 +223,7 @@ func sendTrafficUpdates() {
|
||||||
if globalSettings.DEBUG {
|
if globalSettings.DEBUG {
|
||||||
log.Printf("Ownship target detected for code %X\n", code)
|
log.Printf("Ownship target detected for code %X\n", code)
|
||||||
}
|
}
|
||||||
OwnshipTrafficInfo = ti
|
// OwnshipTrafficInfo = ti
|
||||||
} else {
|
} else {
|
||||||
cur_n := len(msgs) - 1
|
cur_n := len(msgs) - 1
|
||||||
if len(msgs[cur_n]) >= 35 {
|
if len(msgs[cur_n]) >= 35 {
|
||||||
|
@ -259,6 +259,10 @@ func registerTrafficUpdate(ti TrafficInfo) {
|
||||||
func isTrafficAlertable(ti TrafficInfo) bool {
|
func isTrafficAlertable(ti TrafficInfo) bool {
|
||||||
// Set alert bit if possible and traffic is within some threshold
|
// Set alert bit if possible and traffic is within some threshold
|
||||||
// TODO: Could be more intelligent, taking into account headings etc.
|
// TODO: Could be more intelligent, taking into account headings etc.
|
||||||
|
if !ti.BearingDist_valid {
|
||||||
|
// If not able to calculate the distance to the target, let the alert bit be set always.
|
||||||
|
return true
|
||||||
|
}
|
||||||
if ti.BearingDist_valid &&
|
if ti.BearingDist_valid &&
|
||||||
ti.Distance < 3704 { // 3704 meters, 2 nm.
|
ti.Distance < 3704 { // 3704 meters, 2 nm.
|
||||||
return true
|
return true
|
||||||
|
|
Ładowanie…
Reference in New Issue