Skip to content

Commit 2e06827

Browse files
dimonomidcesantabot
authored andcommitted
Fix PWM on esp8266
Check current pin value instead always resetting to 0 PUBLISHED_FROM=33f77b60efa163c41e27f18e5db5bb94e65df28e
1 parent adbc698 commit 2e06827

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/esp8266/esp_pwm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ bool mgos_pwm_set(int pin, int freq, float duty) {
179179
if (th == 0 || tl == 0) {
180180
mgos_gpio_write(pin, (tl == 0));
181181
} else {
182-
mgos_gpio_write(pin, 0);
183-
p->val = 0;
184-
p->cnt = tl;
182+
p->val = mgos_gpio_read_out(pin);
183+
p->cnt = p->val ? th : tl;
185184
}
186185
ETS_FRC1_INTR_ENABLE();
187186

0 commit comments

Comments
 (0)