File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 11package 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}
You can’t perform that action at this time.
0 commit comments