<commit_before>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
#include "Light.h"

// TODO: move to NeoMatrix to take advantage of the 3x stacked strips
#include <Streaming.h>
#include <Metro.h>
#include <EasyTransfer.h>
#include <LightMessage.h> // common message definition

// watchdog timer
#include <avr/wdt.h>


#define PIN 4

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//Adafruit_NeoPixel strip = Adafruit_NeoPixel(49, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix strip = rimJob;

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {

    rimJob.begin();
    rimJob.show();
    //rimJob.setTextWrap(true);
    //rimJob.Color(255, 0, 0);
    //strip.begin();
    //strip.show(); // Initialize all pixels to 'off'
    redL.begin();
    redL.show();
    grnL.begin();
    grnL.show();
    bluL.begin();
    bluL.show();
    yelL.begin();
    yelL.show();

}

void loop() {

    colorWipe(redL, redL.Color(127, 0, 0), 20);
    colorWipe(redL, redL.Color(127, 127, 0), 20);
    colorWipe(grnL, Blu, 20);
    colorWipe(grnL, Yel, 20);
    colorWipe(yelL, Red, 20);
    colorWipe(yelL, Grn, 20);
    colorWipe(bluL, Blu, 20);
    colorWipe(bluL, Yel, 20);
    // Some example procedures showing how to display to the pixels:
    colorWipeMatrix(rimJob, Yel, 1); // Blue
    colorWipeMatrix(rimJob, Grn, 1); // Green
    /*colorWipeMatrix(rimJob, Red, 1); // Red
    colorWipeMatrix(rimJob, Blu, 1); // Blue
    */

    // Send a theater pixel chase in...
    /*
    theaterChase(strip.Color(127, 127, 127), 50); // White
    theaterChase(strip.Color(127,   0,   0), 50); // Red
    theaterChase(strip.Color(  0,   0, 127), 50); // Blue

    rainbow(20);
    rainbowCycle(20);
    theaterChaseRainbow(50);
    */
}
void colorWipeMatrix(Adafruit_NeoMatrix &matrix, uint32_t c, uint8_t wait) {
    for (uint16_t x = 0; x < matrix.width(); x++) {
        matrix.drawPixel(x, 0, c);
        matrix.drawPixel(x, 1, c);
        matrix.drawPixel(x, 2, c);
        matrix.show();
        delay(wait);
    }
}

// Fill the dots one after the other with a color
void colorWipe(Adafruit_NeoPixel &button, uint8_t c, uint8_t wait) {
    for (uint16_t i = 0; i < button.numPixels(); i++) {
        button.setPixelColor(i, c);
        button.show();
        delay(wait);
    }
}

void rainbow(uint8_t wait) {
    uint16_t i, j;

    for(j=0; j<256; j++) {
        for(i=0; i<strip.numPixels(); i++) {
            strip.setPixelColor(i, Wheel((i+j) & 255));<commit_msg>start work on handling simultaneous animations<commit_after>#include <Adafruit_GFX.h>
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
#include "Light.h"

// TODO: move to NeoMatrix to take advantage of the 3x stacked strips
#include <Streaming.h>
#include <Metro.h>
#include <EasyTransfer.h>
#include <LightMessage.h> // common message definition

// watchdog timer
#include <avr/wdt.h>


#define PIN 4

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//Adafruit_NeoPixel strip = Adafruit_NeoPixel(49, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix strip = rimJob;

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {

    rimJob.begin();
    rimJob.show();
    //rimJob.setTextWrap(true);
    //rimJob.Color(255, 0, 0);
    //strip.begin();
    //strip.show(); // Initialize all pixels to 'off'
    redL.begin();
    redL.show();
    /*grnL.begin();
    grnL.show();
    bluL.begin();
    bluL.show();
    yelL.begin();
    yelL.show();
    */

    setStripColor(redL, RED_MAX, GRN_MAX, BLU_MAX);
}

void setStripColor(Adafruit_NeoPixel &strip, int r, int g, int b) {
    for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(r, g, b));
        strip.show();
    }
}

void loop() {
    bool rimReady = true;
    bool btnReady = true;
    if (stripUpdateInterval.check()) {

    /*
        colorWipe(redL, RED_MAX, GRN_MAX, LED_OFF, 10);
        setStripColor(redL, RED_MAX, LED_OFF, LED_OFF);
        colorWipe(redL, redL.Color(127, 127, 0), 20);
        */
    /*    colorWipe(grnL, Blu, 20);
        colorWipe(grnL, Yel, 20);
        colorWipe(yelL, Red, 20);
        colorWipe(yelL, Grn, 20);
        colorWipe(bluL, Blu, 20);
        colorWipe(bluL, Yel, 20);
        */
        // Some example procedures showing how to display to the pixels:
        /*colorWipeMatrix(rimJob, Grn, 1); // Green
        colorWipeMatrix(rimJob, Yel, 1); // Blue
        colorWipeMatrix(rimJob, Red, 1); // Red
        colorWipeMatrix(rimJob, Blu, 1); // Blue
        */

        // Send a theater pixel chase in...
        /*
        theaterChase(strip.Color(127, 127, 127), 50); // White
        theaterChase(strip.Color(127,   0,   0), 50); // Red
        theaterChase(strip.Color(  0,   0, 127), 50); // Blue

        rainbow(20);
        rainbowCycle(20);
        theaterChaseRainbow(50);
        */

        calculateAnimation();
        push(strip, rimReady);
        push(strip,
        stripUpdateInterval.reset();
    }
}

void push(Adafruit_NeoPixel &strip, bool &ready) {
    static Metro timer(wait);
    if (!timer.check()) return;
    strip.show();
    ready = true;
}

void calculateAnimation(void (*animate)(&strip, int r, int g, int b, uint8_t wait), bool &ready) {
    if (!ready) return;
    animate(strip, r, g, b, wait);
    ready = false;
}

void colorWipeMatrix(Adafruit_NeoMatrix &matrix, uint32_t c, uint8_t wait) {
    for (uint16_t x = 0; x < matrix.width(); x++) {
        if (timer.check()) {
            matrix.drawPixel(x, 0, c);
            matrix.drawPixel(x, 1, c);
            matrix.drawPixel(x, 2, c);
            matrix.show();
            timer.reset();
        }
    }
}

// Fill the dots one after the other with a color
void colorWipe(Adafruit_NeoPixel &button, int r, int g, int b, uint8_t wait) {
    Metro timer(wait);
    for (uint16_t i = 0; i < button.numPixels(); i++) {
        if (timer.check()) {
            button.setPixelColor(i, button.Color(r, g, b));
            button.show();
            timer.reset();
        }
    }
}

// color wipes the last 8 pixels
void laserWipe(Adafruit_NeoPixel &button, int r, int g, int b, uint8_t wait, int times = 3) {
    int currTimes = 0;

    while (currTimes < times) {
        for (uint16_t i = 0; i < button.numPixels(); i++) {
            button.setPixelColor(i, button.Color(r, g, b));
            button.show();
            delay(wait);
        }
        times++;
    }
}

void rainbow(uint8_t wait) {
    uint16_t i, j;

    for(j=0; j<256; j++) {
        for(i=0; i<strip.numPixels(); i++) {
            strip.setPixelColor(i, Wheel((i+j) & 255));
{'fraction_non_alphanumeric': 0.13890293225480282, 'fraction_numerical': 0.03501011122345804, 'mean_word_length': 2.66512274201019, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6329321', 'n_tokens_mistral': 3090, 'n_tokens_neox': 2777, 'n_words': 792}