Skip to content

LED fading ON transitions to OFF as soon as the fading is over #7

@cyrille-g

Description

@cyrille-g

This is caused by calling this ad the end of the loop:

if(_ledState == LED_STATE_FADE)
	updateAnalog();
else if (_outputState != LED_FADED_ON)
	updateDigital();

solution tested and working:

add a third led state in the .h :
#define LED_FADED_ON 2

change the case LED_STATE_FADE in the loop by this:
case LED_STATE_FADE:
if((millis() - _lastTime) <= _fadeTime) {
unsigned long progress = millis() - _lastTime;
_brightness = map(progress, 0, _fadeTime, _fadeFrom, _fadeTo);
}
else {
_ledState = LED_STATE_IDLE;
if (_fadeTo == 0) {
_outputState = LED_OFF;
}
else{
_outputState = LED_FADED_ON;
}
}
break;

change the last call of the loop by this:
if(_ledState == LED_STATE_FADE)
updateAnalog();
else if (_outputState != LED_FADED_ON)
updateDigital();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions