<commit_before>
char remainData;
const int M_SIZE=20;
const int M_VALUE=614;
int iii=0;
int mdata[M_SIZE];

void setup(){
  Serial.begin(9600);
  Serial.flush();
  initPorts();
}

void initPorts () {
  for (int pinNumber = 0; pinNumber < 14; pinNumber++) {
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop() {
  while (Serial.available()) {
    if (Serial.available() > 0) {
      
      char c = Serial.read();
      updateDigitalPort(c);
    }
  } 
  delay(15);
  sendPinValues();
  delay(10);
}

//Made by <NAME> 20150423
int cal_slide(){ 
  int sensorValue=analogRead(A2);
  float linear = ((float)sensorValue/1024)*3;
  linear = exp(linear)*50;
  linear = map(linear, 50, 1001, 0, 1023);
  return (int)linear;  
}

//Made by <NAME> 20150423
int cal_sound(){ //calculate the moving average of the sound input 
  mdata[iii]= M_VALUE - analogRead(A0);
  iii++;
  if(iii>=M_SIZE) iii=0;
  
  int sensorValue=0;
  for(int i=0; i<M_SIZE; i++){
    sensorValue+=abs(mdata[i]); //Moving Average
  }
  sensorValue=sensorValue/M_SIZE; 
  
  //Serial.println(sensorValue); //Test by <NAME> 20150423
  return sensorValue;  
}


void sendPinValues() {
  int pinNumber = 0;
  for (pinNumber = 0; pinNumber < 6; pinNumber++) {
    sendAnalogValue(pinNumber);
  }
  for (pinNumber = 0; pinNumber < 14; pinNumber++) {
    if (!isPortWritable(pinNumber))
      sendDigitalValue(pinNumber);
  }
}

void updateDigitalPort (char c) {
  // first data
  if (c>>7) {
    // is output
    if ((c>>6) & 1) {
      // is data end at this chunk
      if ((c>>5) & 1) {
        int port = (c >> 1) & B1111;
        setPortWritable(port);
        if (c & 1)
          digitalWrite(port, HIGH);
        else
          digitalWrite(port, LOW);
      }
      else {
        remainData = c;
      }
    } else {
      int port = (c >> 1) & B1111;
      setPortReadable(port);
    }
  } else {
    int port = (remainData >> 1) & B1111;
    int value = ((remainData & 1) << 7) + (c & B1111111);
    setPortWritable(port);
    analogWrite(port, value);
    remainData = 0;
  }<commit_msg>delete isPortWriteable<commit_after>
char remainData;
const int M_SIZE=20;
const int M_VALUE=614;
int iii=0;
int mdata[M_SIZE];

void setup(){
  Serial.begin(9600);
  Serial.flush();
  initPorts();
}

void initPorts () {
  for (int pinNumber = 0; pinNumber < 14; pinNumber++) {
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop() {
  while (Serial.available()) {
    if (Serial.available() > 0) {
      
      char c = Serial.read();
      updateDigitalPort(c);
    }
  } 
  delay(15);
  sendPinValues();
  delay(10);
}

//Made by <NAME> 20150423
int cal_slide(){ 
  int sensorValue=analogRead(A2);
  float linear = ((float)sensorValue/1024)*3;
  linear = exp(linear)*50;
  linear = map(linear, 50, 1001, 0, 1023);
  return (int)linear;  
}

//Made by <NAME> 20150423
int cal_sound(){ //calculate the moving average of the sound input 
  mdata[iii]= M_VALUE - analogRead(A0);
  iii++;
  if(iii>=M_SIZE) iii=0;
  
  int sensorValue=0;
  for(int i=0; i<M_SIZE; i++){
    sensorValue+=abs(mdata[i]); //Moving Average
  }
  sensorValue=sensorValue/M_SIZE; 
  
  //Serial.println(sensorValue); //Test by <NAME> 20150423
  return sensorValue;  
}


void sendPinValues() {
  int pinNumber = 0;
  for (pinNumber = 0; pinNumber < 6; pinNumber++) {
    sendAnalogValue(pinNumber);
  }
  for (pinNumber = 0; pinNumber < 14; pinNumber++) {
    sendDigitalValue(pinNumber);
  }
}

void updateDigitalPort (char c) {
  // first data
  if (c>>7) {
    // is output
    if ((c>>6) & 1) {
      // is data end at this chunk
      if ((c>>5) & 1) {
        int port = (c >> 1) & B1111;
        setPortWritable(port);
        if (c & 1)
          digitalWrite(port, HIGH);
        else
          digitalWrite(port, LOW);
      }
      else {
        remainData = c;
      }
    } else {
      int port = (c >> 1) & B1111;
      setPortReadable(port);
    }
  } else {
    int port = (remainData >> 1) & B1111;
    int value = ((remainData & 1) << 7) + (c & B1111111);
    setPortWritable(port);
    analogWrite(port, value);
    remainData = 0;
  }
{'fraction_non_alphanumeric': 0.15345699831365936, 'fraction_numerical': 0.04914478438930378, 'mean_word_length': 2.7137745974955276, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '941345', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1519, 'n_words': 375}