<commit_before>#include "FastLED.h"
#define qsubd(x, b)  ((x>b)?255:0)  // Digital unsigned subtraction macro. if result <0, then => 0. Otherwise, take on fixed value.
#define qsuba(x, b)  ((x>b)?x-b:0)  // Analog Unsigned subtraction macro. if result <0, then => 0
#define LED_DT 7              // Data pin to connect to the strip.
#define COLOR_ORDER GRB       // Are they RGB, GRB or what??
#define LED_TYPE WS2812B      // Don't forget to change LEDS.addLeds
#define NUM_LEDS 1500         // Number of LED's.
struct CRGB leds[NUM_LEDS];   // Initialize our LED array.
uint8_t max_bright = 255;     // Overall brightness definition. It can be changed on the fly.
unsigned long previousMillis; // Store last time the strip was updated.
int hue = 50;                 // Starting hue.
bool firstTimeRunningThroughPattern = true;

#define BEAUTIFUL_SPARKLES 1
#define NIGHT_SPARKLES 2
#define SINGLE_COLOR_SPARKLES 3
#define DAVE 4
#define SHOOTING_GRADIENTS 5
#define DISCO_BARBER_1 6
#define DISCO_TWIRL 7
#define DISCO_BARBER_2 8
#define DISCO_TWIRL_2 9

int maxPatternId = 9;
int rotationInMillseconds = 20000; // 20 seconds for production

// If we're testing one pattern, use holdPattern as true and the patternId as the starting pattern.
bool holdPattern = false;
int patternId = BEAUTIFUL_SPARKLES;
/*
bool holdPattern = true;
int patternId = DISCO_TWIRL;
*/

// Set up LEDs, fade them all to black.
void setup() {
  Serial.begin(57600);
  LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(max_bright);
  set_max_power_in_volts_and_milliamps(5, 10000);
  randomSeed(analogRead(0));
  delay(50);
  // Make the whole stick black on startup (helps with restarts).
  // TODO: Test this (untested code)
  for (int i=0; i<NUM_LEDS-1; i++) {
    leds[i] = CHSV(0, 0, 0);
  }
}

uint8_t offset = 0;
int ms = 0;

// Dave's pattern. By <NAME> with love.
// A gradient background, with rotating bright points and white sparkles.
void dave() {
  for (int k=0; k<NUM_LEDS-1; k++) {
    uint8_t k8 = k;
    uint8_t hue = (k/15 * 255) + (offset*5);
    uint8_t saturation = rand() % 255 > 252 ? 0 : 255; //NUM_LEDS - (k+offset*10);
    uint8_t value = k8 % 14 == offset % 14 ? 200 : 40; //NUM_LEDS- (k+offset*10);
    if(saturation == 0){
      value = 255;
    }
    leds[k] = CHSV(hue, saturation, value);
  }
  EVERY_N_MILLISECONDS(1000/24){
    ms++;
    if(ms % 3 == 0){
      offset++;
    }
  }
}

int numberOfSparkles = 1;
bool increasing = true;
int upAndDownBy(int value, int difference, int max, int min) {
  if (value < max && increasing) {
    value += difference;
  } else if (value > min) {
    value -= difference;
    increasing = false;
  } else {
    increasing = true;
    value += difference;
  }
  return value;
}

void nightSparkles() {
  if (firstTimeRunningThroughPattern) {
    hue = 32;
    numberOfSparkles = 40;
  }
  fadeToBlackBy(leds, NUM_LEDS, 180);
  numberOfSparkles = upAndDownBy(numberOfSparkles, 1, 80, 5);
  for (int i = 0; i < numberOfSparkles * 2; i++) {
    int pos = random16(NUM_LEDS);
    leds[pos] = CHSV(hue, 180, 255);<commit_msg>Renamed dave's pattern's variables<commit_after>#include "FastLED.h"
#define qsubd(x, b)  ((x>b)?255:0)  // Digital unsigned subtraction macro. if result <0, then => 0. Otherwise, take on fixed value.
#define qsuba(x, b)  ((x>b)?x-b:0)  // Analog Unsigned subtraction macro. if result <0, then => 0
#define LED_DT 7              // Data pin to connect to the strip.
#define COLOR_ORDER GRB       // Are they RGB, GRB or what??
#define LED_TYPE WS2812B      // Don't forget to change LEDS.addLeds
#define NUM_LEDS 1500         // Number of LED's.
struct CRGB leds[NUM_LEDS];   // Initialize our LED array.
uint8_t max_bright = 255;     // Overall brightness definition. It can be changed on the fly.
unsigned long previousMillis; // Store last time the strip was updated.
int hue = 50;                 // Starting hue.
bool firstTimeRunningThroughPattern = true;

#define BEAUTIFUL_SPARKLES 1
#define NIGHT_SPARKLES 2
#define SINGLE_COLOR_SPARKLES 3
#define DAVE 4
#define SHOOTING_GRADIENTS 5
#define DISCO_BARBER_1 6
#define DISCO_TWIRL 7
#define DISCO_BARBER_2 8
#define DISCO_TWIRL_2 9

int maxPatternId = 9;
int rotationInMillseconds = 20000; // 20 seconds for production

// If we're testing one pattern, use holdPattern as true and the patternId as the starting pattern.
bool holdPattern = false;
int patternId = BEAUTIFUL_SPARKLES;
/*
bool holdPattern = true;
int patternId = DISCO_TWIRL;
*/

// Set up LEDs, fade them all to black.
void setup() {
  Serial.begin(57600);
  LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(max_bright);
  set_max_power_in_volts_and_milliamps(5, 10000);
  randomSeed(analogRead(0));
  delay(50);
  // Make the whole stick black on startup (helps with restarts).
  // TODO: Test this (untested code)
  for (int i=0; i<NUM_LEDS-1; i++) {
    leds[i] = CHSV(0, 0, 0);
  }
}

uint8_t daveOffset = 0;
int daveMilliseconds = 0;

// Dave's pattern. By <NAME> with love.
// A gradient background, with rotating bright points and white sparkles.
void dave() {
  for (int k=0; k<NUM_LEDS-1; k++) {
    uint8_t k8 = k;
    uint8_t hue = (k/15 * 255) + (daveOffset*5);
    uint8_t saturation = rand() % 255 > 252 ? 0 : 255; //NUM_LEDS - (k+daveOffset*10);
    uint8_t value = k8 % 14 == daveOffset % 14 ? 200 : 40; //NUM_LEDS- (k+daveOffset*10);
    if(saturation == 0){
      value = 255;
    }
    leds[k] = CHSV(hue, saturation, value);
  }
  EVERY_N_MILLISECONDS(1000/24){
    daveMilliseconds++;
    if(daveMilliseconds % 3 == 0){
      daveOffset++;
    }
  }
}

int numberOfSparkles = 1;
bool increasing = true;
int upAndDownBy(int value, int difference, int max, int min) {
  if (value < max && increasing) {
    value += difference;
  } else if (value > min) {
    value -= difference;
    increasing = false;
  } else {
    increasing = true;
    value += difference;
  }
  return value;
}

void nightSparkles() {
  if (firstTimeRunningThroughPattern) {
    hue = 32;
    numberOfSparkles = 40;
  }
  fadeToBlackBy(leds, NUM_LEDS, 180);
  numberOfSparkles = upAndDownBy(numberOfSparkles, 1, 80, 5);
  for (int i = 0; i < numberOfSparkles * 2; i++) {
    int pos = random16(NUM_LEDS);
    leds[pos] = CHSV(hue, 180, 255);
{'fraction_non_alphanumeric': 0.12101000476417341, 'fraction_numerical': 0.0435127838653327, 'mean_word_length': 3.3614958448753463, 'pattern_counts': {'":': 0, '<': 19, '<?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': '3048086', 'n_tokens_mistral': 2540, 'n_tokens_neox': 2272, 'n_words': 702}