diff --git a/lib/treppe/treppe.cpp b/lib/treppe/treppe.cpp index 06fff63..e8a6839 100644 --- a/lib/treppe/treppe.cpp +++ b/lib/treppe/treppe.cpp @@ -283,21 +283,21 @@ void Treppe::set_idle_pwm(uint16_t new_idle_pwm) Serial.printf("Treppe: idle_pwm=%d\n", idle_pwm); berechne_dimmer(); activate_idle_pwm(true); - activate_idle_pwm(false); // well :) } void Treppe::activate_idle_pwm(bool active) { - static uint8_t former_active = 0; + static uint16_t last_pwm = 0; if (fsm_outputs.status == ST_RUHEZUSTAND || fsm_outputs.status == ST_INAKTIV_LDR) { - if (active != former_active) + idle_pwm_internal = idle_pwm * active; + if (idle_pwm_internal != last_pwm) { - idle_pwm_internal = idle_pwm * active; // Dimming Function for all LEDS ? + berechne_dimmer(); pwmController.setAllChannelsPWM(idle_pwm_internal); - former_active = active; + last_pwm = idle_pwm_internal; } } }