Skip to content

Commit 1e24766

Browse files
fix pwm behavior at 100% (#1227)
1 parent 1e64826 commit 1e24766

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/shelly_output.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ Status OutputPin::SetState(bool on, const char *source) {
6666
}
6767

6868
Status OutputPin::SetStatePWM(float duty, const char *source) {
69-
if (duty != 0) {
70-
mgos_pwm_set(pin_, 400, duty);
71-
LOG(LL_DEBUG, ("Output %d: %f (%s)", id(), duty, source));
69+
LOG(LL_INFO, ("Duty: %.3f", duty));
70+
if (duty == 0 || duty == 1) {
71+
mgos_gpio_write(pin_, duty);
72+
LOG(LL_INFO,
73+
("Output %d: %s (%s)", id(), (duty == 0 ? "OFF" : "ON"), source));
7274
} else {
73-
mgos_pwm_set(pin_, 0, 0);
74-
LOG(LL_DEBUG, ("Output %d: OFF (%s)", id(), source));
75+
mgos_pwm_set(pin_, 400, duty);
76+
LOG(LL_INFO, ("Output %d: %f (%s)", id(), duty, source));
7577
}
7678
return Status::OK();
7779
}

0 commit comments

Comments
 (0)