For Easing I currently use these Functions:
Here is a very simple implementation with a red dot Bounce.easeOut of the End of the Strip
(demo gif: https://media.giphy.com/media/2tQq8f1bCwwTxbKYsQ/giphy.gif)
#include “Arduino.h”
#include “FastLED.h”
#include <BounceEase.h>
#include <QuarticEase.h>
#include <QuinticEase.h>
#include <BackEase.h>
#include <ElasticEase.h>
#define PIN_DATA 9
#define COLOR_ORDER GRB
#define CHIPSET WS2812
#define NUM_LEDS 64
// Easing
double runner = 0;
double runnerSpeed = 0.01;
int index = 0;
// Easing Functions
QuarticEase easeQuartic;
QuinticEase easeQuintic;
BounceEase easeBounce;
BackEase easeBack;
ElasticEase easeElastic;
struct CRGB leds[NUM_LEDS];
void setup() {
set_max_power_in_volts_and_milliamps(5, 450);// FastLED Power management set at 5V, 500mA.
FastLED.setBrightness(40); //Low value while testing
FastLED.addLeds<CHIPSET, PIN_DATA, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.clear();
//This is the one we are currently processing in the loop
easeBounce.setDuration(1);
easeBounce.setTotalChangeInPosition(NUM_LEDS-1);
//this could also be used in the loop
easeQuartic.setDuration(1);
easeQuartic.setTotalChangeInPosition(NUM_LEDS-1);
easeQuintic.setDuration(1);
easeQuintic.setTotalChangeInPosition(NUM_LEDS-1);
//I also add these to this demo code, as they are a bit tricky to use because of the overshot value
easeBack.setDuration(1);
easeBack.setOvershoot(2);
easeBack.setTotalChangeInPosition(NUM_LEDS-1);
easeElastic.setDuration(1);
easeElastic.setPeriod(0);
easeElastic.setAmplitude(0);
easeElastic.setTotalChangeInPosition(NUM_LEDS-1);
}
void loop() {
EVERY_N_MILLISECONDS(20) {
processEase();
FastLED.show();
}
}
void processEase(){
//Increase Runner 0.00 to 1.00 incrementing at 0.01 - 0.08 at best
runner += runnerSpeed;
//The calculated LED for the current Step in the ease
index = easeBounce.easeOut(runner);
//Reset on reach
if(runner>1) runner = 0;
//FastLED write
leds[index] = CRGB::Red;
//This will give the nice tail.
fadeToBlackBy(leds, NUM_LEDS, 80);
}