Skip to content

A tweening and easing library for Arduino inspired by the good work done at Greensock.

License

Notifications You must be signed in to change notification settings

WesWedding/TweenDuino

TweenDuino Animation Library

Easily transition numeric variables or class members to/from final values gradually over time, using an intuitive API.

Main: Build Status (main) Dev: Build Status (dev)

Timelines and Tweens

The fundamental components of this library are two classes: the Timeline and Tween.

Tweens are used to change a value nicely along a curve from a starting value to an ending value. This value can be something like a brightness value used in some LED logic, or the speed or angle of a motor.

Timelines are containers that store a series of Tweens and play them in sequence. Using a timeline allows you use this tween sequence to do complicated animations or behaviors that would otherwise require potentially hard to understand for loops or mathmatical formulae.

Additional Library Required

Currently depends on the Easing library, a version of Andy Brown's original easing library for the easing math.

If you are using VSCode's Arduino extension or the official Arduino IDE, you can install this dependency via the appropriate Library Manager.

Usage

See the examples folder for full working examples, however the basic approach is...

. . .

Timeline timeline;
int value = 0.0;

setup() {

    // Add a series of 3 tweens as follows...

    // Move value up "100" gradually over 5 seconds.
    timeline.addTo(value, 100, 5000);
    // Move value down to "1" gradually over 3 seconds.
    timeline.addTo(value, 1, 3000);
    // Move value to "9001" gradually over 5 seconds.
    timeline.addTo(value, 9001, 8000);
}

// Watch the number smoothly change as the sketch cycles in loop().
loop() {
    const int now = millis();
    timeline.update(now);
}

. . .

Technical Note: Max timeline size

By default, a Timeline comes with enough storage for 10 tweens. If you want to reduce the memory footprint (or increase the number of tweens you want to store) you will want to use a #define TIMELINE_SIZE XXX statement, where "XXX" is an integer value, to control this. Make sure this #define happens before your include statement!

...

#define TIMELINE_SIZE 10
#include <TweenDuino.h>
#include <Adafruit_NeoPixel.h>
#include <CapacitiveSensor.h>

...

Code of Conduct

This project adheres to the Contributor Covenenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to conduct@wawco.com.

About

A tweening and easing library for Arduino inspired by the good work done at Greensock.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •