<commit_before>import RPi.GPIO as GPIO
import time
# GPIO.setmode(GPIO.BCM)

# TRIG = 23 
# ECHO = 24


class RangeFinder:
	
	def __init__(self):
		GPIO.setmode(GPIO.BCM)
		self.TRIG = 23
		self.ECHO = 24

	def initialize(self):
		print "Distance Measurement In Progress"

		GPIO.setup(self.TRIG,GPIO.OUT)
		GPIO.setup(self.ECHO,GPIO.IN)

		GPIO.output(self.TRIG, False)
		print "Waiting For Sensor To Settle"
		time.sleep(2)


	def distance_read(self):
		# send ultrasonic pulse
		GPIO.output(self.TRIG, True)
		time.sleep(0.00001)  # 10uS pules
		GPIO.output(self.TRIG, False)

		# listen for the echo
		while GPIO.input(self.ECHO)==0:
			pulse_start = time.time()

		# echo was heard
		while GPIO.input(self.ECHO)==1:
			pulse_end = time.time()

		# time differential; time.time() returns the time in seconds
		pulse_duration = pulse_end - pulse_start

		distance = pulse_duration * 17150  # 17150 = (34300 cm/s) / 2
		distance = round(distance, 2)  # distance is in cm

		distance_m = pulse_duration * 171.50  # 171.50 = (343 m/s) / 2
		# distance_m = round(distance, 2)  # distance is in meters

		print "Raw travel time: ",pulse_duration,"s"
		print "Distance (meters):",distance_m,"meters"

		print "Distance (cm):",distance,"cm\n"


	def wait(self):
		time.sleep(1)

	def finish(self):
		print "Measurement stopped"
		GPIO.cleanup()


<commit_msg>works reasonably well with the 1 second delay.<commit_after>import RPi.GPIO as GPIO
import time
# GPIO.setmode(GPIO.BCM)

# TRIG = 23 
# ECHO = 24


class RangeFinder:
	
	def __init__(self):
		GPIO.setmode(GPIO.BCM)
		self.TRIG = 23
		self.ECHO = 24

	def initialize(self):
		print "Distance Measurement In Progress"

		GPIO.setup(self.TRIG,GPIO.OUT)
		GPIO.setup(self.ECHO,GPIO.IN)

		GPIO.output(self.TRIG, False)
		print "Waiting For Sensor To Settle"
		time.sleep(2)


	def distance_read(self):
		# send ultrasonic pulse
		GPIO.output(self.TRIG, True)
		time.sleep(0.00001)  # 10uS pules
		GPIO.output(self.TRIG, False)

		# listen for the echo
		while GPIO.input(self.ECHO)==0:
			pulse_start = time.time()

		# echo was heard
		while GPIO.input(self.ECHO)==1:
			pulse_end = time.time()

		# time differential; time.time() returns the time in seconds
		pulse_duration = pulse_end - pulse_start

		distance = pulse_duration * 17150  # 17150 = (34300 cm/s) / 2
		distance = round(distance, 2)  # distance is in cm

		distance_m = pulse_duration * 171.50  # 171.50 = (343 m/s) / 2
		# distance_m = round(distance, 2)  # distance is in meters

		print "Raw travel time: ",pulse_duration,"s"
		print "Distance (meters):",distance_m,"meters"

		print "Distance (cm):",distance,"cm\n"


	def wait(self):
		time.sleep(1)

	def finish(self):
		GPIO.cleanup()
		print "Measurement stopped"



{'fraction_non_alphanumeric': 0.12504557054320087, 'fraction_numerical': 0.038279256288734964, 'mean_word_length': 3.6429780033840946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3069995', 'n_tokens_mistral': 1193, 'n_tokens_neox': 980, 'n_words': 255}