From 6a04a4d1c938da6ab7360d28ef018c2d59ec273e Mon Sep 17 00:00:00 2001 From: bartschdo76253 Date: Mon, 5 Jul 2021 16:57:09 +0200 Subject: [PATCH] improved activate_idle --- lib/treppe/treppe.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/treppe/treppe.cpp b/lib/treppe/treppe.cpp index ba1e596..369f566 100644 --- a/lib/treppe/treppe.cpp +++ b/lib/treppe/treppe.cpp @@ -237,7 +237,7 @@ void Treppe::setup() pwmController.init(PCA9685_PhaseBalancer_None); //pwmController.init(PCA9685_PhaseBalancer_Linear); pwmController.setPWMFrequency(100); - pwmController.setAllChannelsPWM(idle_brightness); + //pwmController.setAllChannelsPWM(idle_brightness); pinMode(A0, INPUT); pinMode(SENSOR_OBEN, INPUT); @@ -258,15 +258,20 @@ void Treppe::set_idle_pwm(uint16_t _idle_brightness) Serial.printf("Treppe: idle_brightness=%d\n", idle_brightness); } -void Treppe::activate_idle_pwm(bool active){ +void Treppe::activate_idle_pwm(bool active) +{ static uint8_t former_active = 0; - if(active != former_active && fsm_outputs.status == ST_RUHEZUSTAND){ - idle_bright_internal = idle_brightness * active; - // Dimming Function for all LEDS ? - pwmController.setAllChannelsPWM(idle_bright_internal); - former_active = active; - } + if (fsm_outputs.status == ST_RUHEZUSTAND || fsm_outputs.status == ST_INAKTIV_LDR) + { + if (active != former_active) + { + idle_bright_internal = idle_brightness * active; + // Dimming Function for all LEDS ? + pwmController.setAllChannelsPWM(idle_bright_internal); + former_active = active; + } + } } void Treppe::set_active_pwm(uint16_t _active_brightness) {