From 146c950e7751981ef9ab73c1db3a5cad9f48bce8 Mon Sep 17 00:00:00 2001 From: Markus Kirberg Date: Fri, 17 May 2024 09:53:19 +0200 Subject: [PATCH] fix pwm: restore old behaviour for turning off (does not turn off sometimes...) --- src/shelly_output.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shelly_output.cpp b/src/shelly_output.cpp index 255f4070..a3066124 100644 --- a/src/shelly_output.cpp +++ b/src/shelly_output.cpp @@ -67,8 +67,10 @@ Status OutputPin::SetState(bool on, const char *source) { Status OutputPin::SetStatePWM(float duty, const char *source) { LOG(LL_INFO, ("Duty: %.3f", duty)); - if (duty == 0 || duty == 1) { - mgos_gpio_write(pin_, duty); + if (duty == 0) { + mgos_pwm_set(pin_, 0, 0); + } else if (duty == 1) { + mgos_gpio_write(pin_, 1); LOG(LL_INFO, ("Output %d: %s (%s)", id(), (duty == 0 ? "OFF" : "ON"), source)); } else {