From 043867e1f56f77faebd5cc26ed4a500762b391c1 Mon Sep 17 00:00:00 2001 From: Karan Misra Date: Fri, 10 Jan 2014 07:36:01 +0530 Subject: [PATCH] pca9685: default the freq to 490 Hz --- controller/pca9685/pca9685.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controller/pca9685/pca9685.go b/controller/pca9685/pca9685.go index 5e19957..3c9ded5 100644 --- a/controller/pca9685/pca9685.go +++ b/controller/pca9685/pca9685.go @@ -22,6 +22,8 @@ const ( minAnalogValue = 0 maxAnalogValue = 255 + + defaultFreq = 490 ) // PCA9685 represents a PCA9685 PWM generator. @@ -72,6 +74,9 @@ func (d *PCA9685) setup() (err error) { return } + if d.Freq == 0 { + d.Freq = defaultFreq + } preScaleValue := byte(math.Floor(float64(clockFreq/(pwmControlPoints*d.Freq))+float64(0.5)) - 1) if d.Debug { log.Printf("pca9685: calculated prescale value = %#02x", preScaleValue)