jandelgado/jled

Repeat() and DelayAfter() on the same effect in a sequence

mattbk opened this issue · 4 comments

mattbk commented

When I run code like this, I would expect the first effect to repeat three times with a delay of three seconds after each time. But the first effect runs once and then it moves on to the next effect. Am I missing something?

It looks like Repeat() alone works as expected but DelayAfter() alone does not.

Modified from https://github.com/jandelgado/jled/blob/master/examples/sequence/sequence.ino.

#include <jled.h>

constexpr auto LED_PIN = 3;

JLed leds[] = {
    JLed(LED_PIN).Breathe(2000).Repeat(3).DelayAfter(1000),
    JLed(LED_PIN).Blink(750, 250).Repeat(3),
    JLed(LED_PIN).FadeOff(1000).Repeat(3),
    JLed(LED_PIN).Blink(500, 500).Repeat(3),
    JLed(LED_PIN).FadeOn(1000).Repeat(3),
    JLed(LED_PIN).Off(5000)
};

JLedSequence sequence(JLedSequence::eMode::SEQUENCE, leds);

void setup() { }

void loop() {
    sequence.Update();
    delay(1);
}

Thanks a bunch for the Morse example, I'm using it for exactly that purpose (to key a radio). The use case is that I want to repeat a Morse message n times, then wait a number of seconds. But without DelayAfter() on the message, the final dit and the first dah run together.

mattbk commented

I realized that for my use case, I can add an extra space (" ") at the end of the MorseEffect message, and the messages won't run together. I don't think this manual intervention is possible for regular LED sequences, though.

Thanks for the report - I can confirm that there is a problem in the JLed code, introduced recently (and not covered by tests...). Will investigate further ...

fixed with 4.13.1, please check if it's ok now

mattbk commented

Works a treat, thank you!