improved activate_idle

This commit is contained in:
Dominik Bartsch 2021-07-05 16:57:09 +02:00
parent 53efb0c309
commit 6a04a4d1c9

View File

@ -237,7 +237,7 @@ void Treppe::setup()
pwmController.init(PCA9685_PhaseBalancer_None); pwmController.init(PCA9685_PhaseBalancer_None);
//pwmController.init(PCA9685_PhaseBalancer_Linear); //pwmController.init(PCA9685_PhaseBalancer_Linear);
pwmController.setPWMFrequency(100); pwmController.setPWMFrequency(100);
pwmController.setAllChannelsPWM(idle_brightness); //pwmController.setAllChannelsPWM(idle_brightness);
pinMode(A0, INPUT); pinMode(A0, INPUT);
pinMode(SENSOR_OBEN, INPUT); pinMode(SENSOR_OBEN, INPUT);
@ -258,16 +258,21 @@ void Treppe::set_idle_pwm(uint16_t _idle_brightness)
Serial.printf("Treppe: idle_brightness=%d\n", 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; static uint8_t former_active = 0;
if(active != former_active && fsm_outputs.status == ST_RUHEZUSTAND){ if (fsm_outputs.status == ST_RUHEZUSTAND || fsm_outputs.status == ST_INAKTIV_LDR)
{
if (active != former_active)
{
idle_bright_internal = idle_brightness * active; idle_bright_internal = idle_brightness * active;
// Dimming Function for all LEDS ? // Dimming Function for all LEDS ?
pwmController.setAllChannelsPWM(idle_bright_internal); pwmController.setAllChannelsPWM(idle_bright_internal);
former_active = active; former_active = active;
} }
} }
}
void Treppe::set_active_pwm(uint16_t _active_brightness) void Treppe::set_active_pwm(uint16_t _active_brightness)
{ {
active_brightness = _active_brightness; active_brightness = _active_brightness;