Clean up fancontrol.

Working on #663.
pull/609/head^2
Christopher Young 2017-09-12 08:56:31 -04:00
rodzic f8646d9ebe
commit 05aa90b125
1 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -69,6 +69,8 @@ func fanControl(pwmDutyMin int, pin int, tempTarget float32) {
})
pwmDuty := 0
delay := time.NewTicker(delaySeconds * time.Second)
for {
if temp > (tempTarget + hysteresis) {
pwmDuty = iMax(iMin(pwmDutyMax, pwmDuty+1), pwmDutyMin)
@ -80,7 +82,7 @@ func fanControl(pwmDutyMin int, pin int, tempTarget float32) {
}
//log.Println(temp, " ", pwmDuty)
C.pwmWrite(cPin, C.int(pwmDuty))
time.Sleep(delaySeconds * time.Second)
<-delay.C
}
// Default to "ON".
@ -158,7 +160,7 @@ func (service *Service) Manage() (string, error) {
}
// Accept a client connection and collect it in a channel
func acceptConnection(listener net.Listener, listen chan<- net.Conn) {
func acceptConnection(listener net.Listener, listen chan net.Conn) {
for {
conn, err := listener.Accept()
if err != nil {
@ -169,6 +171,7 @@ func acceptConnection(listener net.Listener, listen chan<- net.Conn) {
}
func handleClient(client net.Conn) {
defer client.Close()
for {
buf := make([]byte, 4096)
numbytes, err := client.Read(buf)