Skip to content

Commit 3dccd0a

Browse files
committed
refactor: renamed parameters of SetDuty function
1 parent 8270fd3 commit 3dccd0a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

utils.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package tinygo_pwm
22

3-
// SetDuty sets the duty cycle of a PWM signal given the pulse width and period width in microseconds.
3+
// SetDuty sets the duty cycle of a PWM signal given the pulse width and period width.
44
//
55
// Parameters:
66
//
77
// pwm: PWM to control its signal
88
// channel: PWM channel
9-
// pulseMicroseconds: pulse width in microseconds
10-
// periodMicroseconds: period width in microseconds
11-
func SetDuty(pwm PWM, channel uint8, pulseMicroseconds, periodMicroseconds uint32) {
9+
// pulse: pulse width
10+
// period: period width
11+
func SetDuty(pwm PWM, channel uint8, pulse, period uint32) {
1212
// Avoid division by zero
13-
if periodMicroseconds == 0 {
13+
if period == 0 {
1414
return
1515
}
1616

1717
// Set the duty cycle
1818
if pwm != nil {
19-
pwm.Set(channel, uint32(float64(pwm.Top())*float64(pulseMicroseconds)/float64(periodMicroseconds)))
19+
pwm.Set(channel, uint32(float64(pwm.Top())*float64(pulse)/float64(period)))
2020
}
2121
}

0 commit comments

Comments
 (0)