Reduce number of fan modes to 10 from 256. Add five second run-up at startup.
@@ -21,19 +21,16 @@ const (
defaultTempTarget = 50.
hysteresis = float32(1.)
- /* This puts our PWM frequency at 19.2 MHz / 128 =
- /* 150kHz. Higher frequencies will reduce audible switching
- /* noise but will be less efficient */
- pwmClockDivisor = 128
+ pwmClockDivisor = 100
/* Minimum duty cycle is the point below which the fan does
/* not spin. This depends on both your fan and the switching
/* transistor used. */
- defaultPwmDutyMin = 20
- pwmDutyMax = 256
+ defaultPwmDutyMin = 1
+ pwmDutyMax = 10
// how often to update
- delaySeconds = 2
+ delaySeconds = 30
// GPIO-1/BCM "18"/Pin 12 on a Raspberry PI 3
defaultPin = 1
@@ -50,7 +47,15 @@ var stdlog, errlog *log.Logger
func fanControl(pwmDutyMin int, pin int, tempTarget float32) {
cPin := C.int(pin)
+
C.wiringPiSetup()
+
+ // Power on "test". Allows the user to verify that their fan is working.
+ C.pinMode(cPin, C.OUTPUT)
+ C.digitalWrite(cPin, C.HIGH)
+ time.Sleep(5 * time.Second)
+ C.digitalWrite(cPin, C.LOW)
+
C.pwmSetMode(C.PWM_MODE_BAL)
C.pinMode(cPin, C.PWM_OUTPUT)
C.pwmSetRange(pwmDutyMax)
