From 3bfba27dadbca545bf95bac75e7c806de3be54db Mon Sep 17 00:00:00 2001 From: DiscreteTom Date: Sun, 24 Apr 2022 17:19:49 +0800 Subject: [PATCH] fix raspi PWMPin.SetDutyCycle (#800) raspi: PWMPin.SetDutyCycle - value 0 is allowed in pi blaster - for pi-blaster, duty should not going below 2us, unless the duty is 0 --- platforms/raspi/pwm_pin.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platforms/raspi/pwm_pin.go b/platforms/raspi/pwm_pin.go index 57f08073f..d5373496c 100644 --- a/platforms/raspi/pwm_pin.go +++ b/platforms/raspi/pwm_pin.go @@ -83,9 +83,10 @@ func (p *PWMPin) SetDutyCycle(duty uint32) (err error) { p.dc = duty val := gobot.FromScale(float64(p.dc), 0, float64(p.period)) - + // never go below minimum allowed duty for pi blaster - if val < 0.05 { + // unless the duty equals to 0 + if val < 0.05 && val != 0 { val = 0.05 } return p.piBlaster(fmt.Sprintf("%v=%v\n", p.pin, val))