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:
parent
862c2179c0
commit
364105de2c
|
@ -157,10 +157,30 @@ bool light3Handler(const HomieRange& range, const String& value) {
|
|||
|
||||
void output() {
|
||||
// * 4 to scale the input up for ESP Arduino default 10 bit PWM
|
||||
if (w0 == FULL)
|
||||
{
|
||||
digitalWrite(PIN_LIGHT, HIGH);
|
||||
} else {
|
||||
analogWrite(PIN_LIGHT, w0 * 4);
|
||||
analogWrite(PIN_LIGHT1, w1 * 4);
|
||||
analogWrite(PIN_LIGHT2, w2 * 4);
|
||||
analogWrite(PIN_LIGHT3, w3 * 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()
|
||||
|
|
Loading…
Reference in New Issue