Skip to content

Commit

Permalink
fix raspi PWMPin.SetDutyCycle (#800)
Browse files Browse the repository at this point in the history
raspi: PWMPin.SetDutyCycle
   - value 0 is allowed in pi blaster
   - for pi-blaster, duty should not going below 2us, unless the duty is 0
  • Loading branch information
DiscreteTom authored Apr 24, 2022
1 parent 3b3ad4d commit 3bfba27
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions platforms/raspi/pwm_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 3bfba27

Please sign in to comment.