Adjust looping on fan ; add debug output for fine tuning purposes
This commit is contained in:
parent
638bd93675
commit
6c6bbe02fe
|
@ -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 {
|
|
||||||
select {
|
|
||||||
case <-ticker.C:
|
|
||||||
cpuTemp := utils.GetCPUTemp()
|
cpuTemp := utils.GetCPUTemp()
|
||||||
gpuTemp := utils.GetGPUTemp()
|
gpuTemp := utils.GetGPUTemp()
|
||||||
|
|
||||||
|
log.Printf("CPU Temp : %.2f", cpuTemp)
|
||||||
|
log.Printf("GPU Temp : %.2f", gpuTemp)
|
||||||
|
|
||||||
if cpuTemp >= SPEED_FULL_TEMP || gpuTemp >= SPEED_FULL_TEMP {
|
if cpuTemp >= SPEED_FULL_TEMP || gpuTemp >= SPEED_FULL_TEMP {
|
||||||
fan.SetSpeed(100)
|
fan.SetSpeed(100)
|
||||||
|
log.Print("Setting fan speed to 100%")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP {
|
if cpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP {
|
||||||
fan.SetSpeed(75)
|
fan.SetSpeed(75)
|
||||||
|
log.Print("Setting fan speed to 75%")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cpuTemp >= SPEED_FIFTY_PERCENT_TEMP || gpuTemp >= SPEED_FIFTY_PERCENT_TEMP {
|
if cpuTemp >= SPEED_FIFTY_PERCENT_TEMP || gpuTemp >= SPEED_FIFTY_PERCENT_TEMP {
|
||||||
fan.SetSpeed(50)
|
fan.SetSpeed(50)
|
||||||
|
log.Print("Setting fan speed to 50%")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP {
|
if cpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP {
|
||||||
fan.SetSpeed(25)
|
fan.SetSpeed(25)
|
||||||
|
log.Print("Setting fan speed to 25%")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cpuTemp <= SPEED_OFF_TEMP || gpuTemp <= SPEED_OFF_TEMP {
|
if cpuTemp <= SPEED_OFF_TEMP || gpuTemp <= SPEED_OFF_TEMP {
|
||||||
fan.SetSpeed(0)
|
fan.SetSpeed(0)
|
||||||
|
log.Print("Setting fan speed to 0%")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// We should never get here but...
|
// We should never get here but...
|
||||||
|
log.Print("Shouldn't see this but here we are")
|
||||||
fan.SetSpeed(100)
|
fan.SetSpeed(100)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Infinate loop of sleeps to let ticker do it's job working with fan speed
|
|
||||||
sleepInterval, err := time.ParseDuration("5m")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error parsing sleep interval : %s", err)
|
|
||||||
}
|
|
||||||
for {
|
|
||||||
time.Sleep(sleepInterval)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue