Skip to content

Commit

Permalink
Merge pull request #6 from Mangero/master
Browse files Browse the repository at this point in the history
Turn off PWM when duty cycle is set to zero

CL: pwm: Turn off PWM when duty cycle is set to zero
  • Loading branch information
rojer authored Oct 1, 2019
2 parents 5818662 + a0344b7 commit 783b43d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/esp8266/esp_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ bool mgos_pwm_set(int pin, int freq, float duty) {
*/
if (freq > 0 && freq < 10) return false;

p = find_or_create_pwm_info(pin, (freq > 0));
p = find_or_create_pwm_info(pin, (freq > 0) && (duty > 0));
if (p == NULL) {
return false;
}

if (freq <= 0) {
if (freq <= 0 || duty <= 0) {
remove_pwm_info(p);
pwm_configure_timer();
mgos_gpio_write(pin, 0);
Expand Down

0 comments on commit 783b43d

Please sign in to comment.