<commit_before>#include "FastLED.h"

#define NUM_LEDS 64
#define PIN 6

CRGB leds[NUM_LEDS];
int hue = 0;
int sat = 255;
int val = 60;

// pixel indices of various sized squares
int p1[] = { 4, 27, 28, 35, 36 };
int p2[] = { 12, 18, 19, 20, 21, 26, 29, 34, 37, 42, 43, 44, 45 };
int p3[] = { 20, 9, 10, 11, 12, 13, 14, 17, 22, 25, 30, 33, 38, 41, 46, 49, 50, 51, 52, 53, 54 };
int p4[] = { 28, 0, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 57, 58, 59, 60, 61, 62, 63 };
int* pp[] = { p1, p2, p3, p4, p3, p2 };
int ppp = 1;
int vv = 90;

void setup() {
  FastLED.addLeds<WS2812, PIN>(leds, NUM_LEDS);
}

void loop() {
  for (int i=0; i<64; i++) {
    leds[i].setHSV(hue, sat, val);
  }

  int* z = pp[ppp];
  for (int i=0; i<z[0]; i++) {
    leds[z[i + 1]].setHSV(0, 0, vv);
  }
  ppp = (ppp + 1) % 6;

  FastLED.show();
  delay(100);
  hue++;
}<commit_msg>Refactor: Extract drawBackground, animate, draw methods. Extract frame period parameter.<commit_after>#include "FastLED.h"

#define NUM_LEDS 64
#define PIN 6
#define FRAME_PERIOD_MILLIS 200

CRGB leds[NUM_LEDS];
int hue = 0;
int sat = 255;
int val = 60;

// pixel indices of various sized squares
int p1[] = { 4, 27, 28, 35, 36 };
int p2[] = { 12, 18, 19, 20, 21, 26, 29, 34, 37, 42, 43, 44, 45 };
int p3[] = { 20, 9, 10, 11, 12, 13, 14, 17, 22, 25, 30, 33, 38, 41, 46, 49, 50, 51, 52, 53, 54 };
int p4[] = { 28, 0, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 57, 58, 59, 60, 61, 62, 63 };
int* pp[] = { p1, p2, p3, p4, p3, p2 };
int ppp = 1;
int vv = 90;
int sss = 2;
CHSV spen(120, 255, val);

void drawBackground(CHSV hsv);
void animate(int &frameIndex, CHSV pen);
void draw(int *frame, CHSV pen);

void setup() {
  FastLED.addLeds<WS2812, PIN>(leds, NUM_LEDS);
}

void loop() {
//  drawBackground(CHSV(hue, sat, val));
  drawBackground(CHSV(0, 0, 0));
  
  animate(ppp, CHSV(0, 0, vv));
  animate(sss, spen);

  hue++;

  FastLED.show();
  delay(FRAME_PERIOD_MILLIS);
}

void drawBackground(CHSV hsv) {
  for (int i=0; i<NUM_LEDS; i++) {
    leds[i] = hsv;
  }
  
}

void animate(int &frameIndex, CHSV pen) {
  frameIndex = frameIndex % 4;
  int *frame = pp[frameIndex];
  draw(frame, pen);
  frameIndex = (frameIndex + 1) % 4;
}

void draw(int *frame, CHSV pen) {
  for (int i=0; i<frame[0]; i++) {
    leds[frame[i + 1]] = pen;
  }
  
}

{'fraction_non_alphanumeric': 0.20076400679117148, 'fraction_numerical': 0.1430390492359932, 'mean_word_length': 3.301094890510949, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1968279', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1077, 'n_words': 358}