<commit_before>#include "base64/Base64.h"

const int ledPin = 13;
byte counter;
const byte CLOCK = 248;
const byte START = 250;
const byte CONTINUE = 251;
const byte STOP = 252;
const int redLed = 1;

void OnNoteOn(byte channel, byte note, byte velocity)
{
  digitalWrite(ledPin, HIGH);
}

void OnNoteOff(byte channel, byte note, byte velocity)
{
  digitalWrite(ledPin, LOW);
}

void SystemExclusiveMessage(const unsigned char *array, short unsigned int size, bool sysexbool) {
  unsigned char *dataArray = (unsigned char*)(array + 4);
  unsigned int realSize = size - 5;

  int decodedLen = base64_dec_len((char*)dataArray, realSize);
  Serial.println(decodedLen);
  char decoded[decodedLen];

  base64_decode(decoded, (char*)dataArray, realSize);

  Serial.println(decoded);

}

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(redLed, OUTPUT);
  Serial.begin(9600);
  usbMIDI.setHandleNoteOff(OnNoteOff);
  usbMIDI.setHandleNoteOn(OnNoteOn);
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
  usbMIDI.setHandleRealTimeSystem(RealTimeSystem);
  usbMIDI.setHandleSysEx(SystemExclusiveMessage);
  Serial.println("start");
}

void loop()
{
  usbMIDI.read();
}

void RealTimeSystem(byte realtimebyte) {
  if (realtimebyte == CLOCK) {
    counter++;
    if (counter == 24) {
      counter = 0;
      digitalWrite(redLed, HIGH);
    }
    if (counter == 23) {
      digitalWrite(redLed, HIGH);
    }

    if (counter == 6) {
      digitalWrite(redLed, LOW);
    }
  }

  if (realtimebyte == START || realtimebyte == CONTINUE) {
    counter = 0;
    digitalWrite(redLed, HIGH);
  }

  if (realtimebyte == STOP) {
    digitalWrite(redLed, LOW);
  }
}
<commit_msg>Add libraries and more buttons<commit_after>#include <Bounce2.h>

#include <Adafruit_GFX.h>

#include <SPI.h>

#include <Wire.h>

#include <Adafruit_SSD1306.h>

#include "base64/Base64.h"

byte counter;
const byte CLOCK = 248;
const byte START = 250;
const byte CONTINUE = 251;
const byte STOP = 252;
const int ledPin = 13;

const byte channelButtonStart = 0;
//const byte channelButtonLedStart = 14;
const byte numberOfChannelButtons = 2;
const byte ledPins[] = {/*10, 11, 12,*/ 14, 15, 16};
Bounce channelButtons[numberOfChannelButtons];
boolean channelButtonStates[numberOfChannelButtons];
boolean channelButtonDown[numberOfChannelButtons];

const byte bpmLed = 22;


void OnNoteOn(byte channel, byte note, byte velocity)
{
  digitalWrite(ledPin, HIGH);
}

void OnNoteOff(byte channel, byte note, byte velocity)
{
  digitalWrite(ledPin, LOW);
}

void SystemExclusiveMessage(const unsigned char *array, short unsigned int size, bool sysexbool) {
  unsigned char *dataArray = (unsigned char*)(array + 4);
  unsigned int realSize = size - 5;

  int decodedLen = base64_dec_len((char*)dataArray, realSize);
  Serial.println(decodedLen);
  char decoded[decodedLen];

  base64_decode(decoded, (char*)dataArray, realSize);

  Serial.println(decoded);

}

void setupButtons() {
  for (byte i = 0; i < numberOfChannelButtons; i++) {
    pinMode(channelButtonStart + i, INPUT_PULLUP);
    channelButtons[i].attach(channelButtonStart + i);
    channelButtons[i].interval(10);
    channelButtonStates[i] = false;
    channelButtonDown[i] = false;
  }
}

void setupLeds() {
  pinMode(ledPin, OUTPUT);
  pinMode(bpmLed, OUTPUT);
  for (byte i = 0; i < numberOfChannelButtons; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}


void setup()
{
  setupButtons();
  setupLeds();

  Serial.begin(9600);
  usbMIDI.setHandleNoteOff(OnNoteOff);
  usbMIDI.setHandleNoteOn(OnNoteOn);
  usbMIDI.setHandleRealTimeSystem(RealTimeSystem);
  usbMIDI.setHandleSysEx(SystemExclusiveMessage);

  ledTest();

  Serial.println("start");
}

void ledTest() {
  ledTest(ledPin);
  ledTest(bpmLed);
  for (byte i = 0; i < numberOfChannelButtons; i++) {
    ledTest(ledPins[i]);
    //    digitalWrite(channelButtonLedStart +i,HIGH);
  }
}

void ledTest(byte pin) {
  digitalWrite(pin, HIGH);
  delay(200);
  digitalWrite(pin, LOW);
  delay(200);
}

void updateButtons() {
  for (byte i = 0; i < numberOfChannelButtons; i++) {
    if (channelButtons[i].update()) {
      if (channelButtons[i].read() == LOW) {
        channelButtonDown[i] = true;
      } else if (channelButtonDown[i]) {
        channelButtonStates[i] = 1 - channelButtonStates[i];
        channelButtonDown[i] = false;
        if (channelButtonStates[i]) {
          digitalWrite(ledPins[i], HIGH);
        } else {
          digitalWrite(ledPins[i], LOW);
        }
      }
    }
  }
}

void loop()
{
  usbMIDI.read();
  updateButtons();
}

void RealTimeSystem(byte realtimebyte) {
  if (realtimebyte == CLOCK) {
    counter++;
    if (counter == 24) {
      counter = 0;
      digitalWrite(bpmLed, HIGH);
    }
    if (counter == 23) {
      digitalWrite(bpmLed, HIGH);
    }

    if (counter == 6) {
      digitalWrite(bpmLed, LOW);
    }
  }

  if (realtimebyte == START || realtimebyte == CONTINUE) {
    counter = 0;
    digitalWrite(bpmLed, HIGH);
  }

  if (realtimebyte == STOP) {
    digitalWrite(bpmLed, LOW);
  }
}

{'fraction_non_alphanumeric': 0.13271360759493672, 'fraction_numerical': 0.022745253164556962, 'mean_word_length': 3.948140900195695, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, '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': '5856696', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1802, 'n_words': 399}