<commit_before>/*
  Ultrasonick.h - Library for HC-SR04 Ultrasonic Ranging Module in a minimalist way.
  Created by <NAME> (@AloErickSimoes), April 3, 2014.
  Released into the Creative Commons Attribution-ShareAlike 4.0 International.
*/

/**
* TODO: Consider removing compatibility for the old Arduino API
*/
#if (ARDUINO >= 100)
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

#include "Ultrasonick.h"

Ultrasonick::Ultrasonick(int trigPin, int echoPin) {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  _trigPin = trigPin;
  _echoPin = echoPin;
}

int Ultrasonick::timing() {
  digitalWrite(_trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(_trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(_trigPin, LOW);
  return pulseIn(_echoPin, HIGH); // duration
}

/**
* TODO: Enable the change of sound velocity constants
* TODO: Change the variable type to a minnor size
*/
int Ultrasonick::distanceRead(int und) {
  if (und)
    return timing() / 28 / 2 ; //distance in CM
  else
    return timing() / 71 / 2; //distance in INC
}

int Ultrasonick::distanceRead() {
  /*
  If the unit of measure is not passed as a parameter,
  by default, it will return the distance in centimeters.
  To change the default, replace CM by INC.
  */
  distanceRead(CM);
}<commit_msg>fix: No return statement in function returning non-void<commit_after>/*
  Ultrasonick.h - Library for HC-SR04 Ultrasonic Ranging Module in a minimalist way.
  Created by <NAME> (@AloErickSimoes), April 3, 2014.
  Released into the Creative Commons Attribution-ShareAlike 4.0 International.
*/

/**
* TODO: Consider removing compatibility for the old Arduino API
*/
#if (ARDUINO >= 100)
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

#include "Ultrasonick.h"

Ultrasonick::Ultrasonick(int trigPin, int echoPin) {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  _trigPin = trigPin;
  _echoPin = echoPin;
}

int Ultrasonick::timing() {
  digitalWrite(_trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(_trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(_trigPin, LOW);
  return pulseIn(_echoPin, HIGH); // duration
}

/**
* TODO: Enable the change of sound velocity constants
* TODO: Change the variable type to a minnor size
*/
int Ultrasonick::distanceRead(int und) {
  if (und)
    return timing() / 28 / 2 ; //distance in CM
  else
    return timing() / 71 / 2; //distance in INC
}

int Ultrasonick::distanceRead() {
  /*
  If the unit of measure is not passed as a parameter,
  by default, it will return the distance in centimeters.
  To change the default, replace CM by INC.
  */
  return distanceRead(CM);
}
{'fraction_non_alphanumeric': 0.1112372304199773, 'fraction_numerical': 0.015891032917139614, 'mean_word_length': 4.007575757575758, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '766716', 'n_tokens_mistral': 948, 'n_tokens_neox': 866, 'n_words': 290}