Adjust looping on fan ; add debug output for fine tuning purposes

This commit is contained in:
KemoNine 2020-09-04 15:04:44 -04:00
parent 638bd93675
commit 6c6bbe02fe

View file

@ -55,45 +55,40 @@ func main() {
log.Fatalf("Error parsing interval duration : %s", err) log.Fatalf("Error parsing interval duration : %s", err)
} }
ticker := time.NewTicker(pollInterval) ticker := time.NewTicker(pollInterval)
go func() { for range ticker.C {
for { cpuTemp := utils.GetCPUTemp()
select { gpuTemp := utils.GetGPUTemp()
case <-ticker.C:
cpuTemp := utils.GetCPUTemp()
gpuTemp := utils.GetGPUTemp()
if cpuTemp >= SPEED_FULL_TEMP || gpuTemp >= SPEED_FULL_TEMP { log.Printf("CPU Temp : %.2f", cpuTemp)
fan.SetSpeed(100) log.Printf("GPU Temp : %.2f", gpuTemp)
continue
} if cpuTemp >= SPEED_FULL_TEMP || gpuTemp >= SPEED_FULL_TEMP {
if cpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP { fan.SetSpeed(100)
fan.SetSpeed(75) log.Print("Setting fan speed to 100%")
continue continue
}
if cpuTemp >= SPEED_FIFTY_PERCENT_TEMP || gpuTemp >= SPEED_FIFTY_PERCENT_TEMP {
fan.SetSpeed(50)
continue
}
if cpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP {
fan.SetSpeed(25)
continue
}
if cpuTemp <= SPEED_OFF_TEMP || gpuTemp <= SPEED_OFF_TEMP {
fan.SetSpeed(0)
continue
}
// We should never get here but...
fan.SetSpeed(100)
}
} }
}() if cpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP {
fan.SetSpeed(75)
// Infinate loop of sleeps to let ticker do it's job working with fan speed log.Print("Setting fan speed to 75%")
sleepInterval, err := time.ParseDuration("5m") continue
if err != nil { }
log.Fatalf("Error parsing sleep interval : %s", err) if cpuTemp >= SPEED_FIFTY_PERCENT_TEMP || gpuTemp >= SPEED_FIFTY_PERCENT_TEMP {
} fan.SetSpeed(50)
for { log.Print("Setting fan speed to 50%")
time.Sleep(sleepInterval) continue
}
if cpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP {
fan.SetSpeed(25)
log.Print("Setting fan speed to 25%")
continue
}
if cpuTemp <= SPEED_OFF_TEMP || gpuTemp <= SPEED_OFF_TEMP {
fan.SetSpeed(0)
log.Print("Setting fan speed to 0%")
continue
}
// We should never get here but...
log.Print("Shouldn't see this but here we are")
fan.SetSpeed(100)
} }
} }