     return rval;
 }
 
+/* stepAnimation returns true if it is time for the next step in the animation,
+ * according to the SPEED parameter. */
+bool stepAnimation() {
+    static uint32_t lastClock = 0;
+    uint32_t diff;
+    uint32_t clock;
+    uint32_t expectedDelay;
+
+    /* Animations are disabled when speed is zero */
+    if (parameters[PARAMETER_SPEED] == 0) {
+        return false;
+    }
+
+    clock = millis();
+    diff = clock - lastClock;
+
+    /* Otherwise, delay 1/SPEED milliseconds */
+    lastClock = clock;
+    expectedDelay = 1000 / parameters[PARAMETER_SPEED];
+
+    return diff >= expectedDelay;
+}
+
 /* modeSolid draws a solid color across all LEDs, according to the parameters
  * HUE, SATURATION, VALUE. */
 void modeSolid() {

/* Rainbow colors, used to signify active parameter to the user. */
CRGB rainbowColors[MAX_PARAMETERS] = {
    CHSV(0,   255, 255),
    CHSV(36,  255, 255),
    CHSV(73,  255, 255),
    CHSV(109, 255, 255),
    CHSV(146, 255, 255),
    CHSV(182, 255, 255),
    CHSV(219, 255, 255)
};

/* Initial setup, called once on boot. */

CRGB leds[NUM_LEDS];

/* All the different modes that are available. */
#define MAX_MODES 2
void modeSolid();
void modeRainbow();
void (*modes[MAX_MODES])() = {
    &modeSolid,
    &modeRainbow
};

/* Define the different parameters that can be changed using the rotary wheel. */
#define PARAMETER_MODE 0
