Bei Full (Wert 255) nicht mehr PWM nutzen (255*4=1020, Maximum wäre aber 1023. Bei einer anderen Regel (z.B. w*4+3) würde bei 0 (aus) bereits ein wenig Licht per PWM geschaltet werden, was sicher noch schlechter wäre.

This commit is contained in:
starcalc 2017-12-01 17:53:20 +01:00
parent 862c2179c0
commit 364105de2c
1 changed files with 24 additions and 4 deletions

View File

@ -157,10 +157,30 @@ bool light3Handler(const HomieRange& range, const String& value) {
void output() { void output() {
// * 4 to scale the input up for ESP Arduino default 10 bit PWM // * 4 to scale the input up for ESP Arduino default 10 bit PWM
analogWrite(PIN_LIGHT, w0 * 4); if (w0 == FULL)
analogWrite(PIN_LIGHT1, w1 * 4); {
analogWrite(PIN_LIGHT2, w2 * 4); digitalWrite(PIN_LIGHT, HIGH);
analogWrite(PIN_LIGHT3, w3 * 4); } else {
analogWrite(PIN_LIGHT, w0 * 4);
}
if (w1 == FULL)
{
digitalWrite(PIN_LIGHT1, HIGH);
} else {
analogWrite(PIN_LIGHT1, w0 * 4);
}
if (w2 == FULL)
{
digitalWrite(PIN_LIGHT2, HIGH);
} else {
analogWrite(PIN_LIGHT2, w0 * 4);
}
if (w3 == FULL)
{
digitalWrite(PIN_LIGHT3, HIGH);
} else {
analogWrite(PIN_LIGHT3, w0 * 4);
}
} }
void loopHandler() void loopHandler()