jandelgado / jled

Non-blocking LED controlling library for Arduino and friends.
MIT License
324 stars 51 forks source link

Allow to trigger callback after an effect is finished #83

Closed jandelgado closed 1 year ago

jandelgado commented 2 years ago

82 inspired this MR:

Added a new UpdateAndFinally method that will update the effect like Update but will trigger the provided callback when the effect is finished. This allows e.g. reconfiguration of an effect.

Example:

#include <jled.h>

auto breathe = JLed(2).Breathe(500);

void setup() { }

void loop()  {
  breathe.UpdateAndFinally(
          [] (JLed& led, void*) {
            led.Breathe(random(50,5000));
            led.Reset();
    }
  );
}
coveralls commented 2 years ago

Coverage Status

Coverage increased (+0.08%) to 97.03% when pulling 12684d8d64f460cf0187314053b6ff2dd481129a on add_update_and_finally into 1971249379c6d9038f42c14c36d1ace589e1960b on master.