<commit_before>/* qti.c
 * 
 * Module contains everything needed to operate a PING sonar sensor.
 *
 * MAE3780 Mechatronics Final Project 2013
 * Cornell University
 * <NAME>, <NAME>, <NAME>
 */

#ifndef F_CPU
#define F_CPU 16000000UL
#endif

// Include standard headers
#include <avr/io.h>			// For general I/O
#include <util/delay.h>		// For delay
#include <avr/interrupt.h>	// For interrupts
#include <stdint.h>			// For data types

// Include local headers
#include "motor.h"			// Motor control to stop motors
#include "qti.h"			// Own header file

/* Connection Details
 * Pin	Sensor Placement
 * ---------------------
 * PD0	Center
 * PD1	Front
 * PD2	Back
 */

// Variable definitions
volatile int8_t qti_touchingBounds=0;

/* Begin Internal Functions Here
 * =============================
 *
 */

ISR(PCINT2_vect){
// ISR to detect out-of-bounds

	//If center QTI detects white 
	if ((PIND>>0)&1){
		_delay_us(500);
		//Check again after short wait
		if ((PIND>>0)&1){
			// Accept defeat
			
			// Turn Motors off
			motor_setSpeed(0,0);
			motor_setSpeed(0,1);

			//Initialize LED
			DDRB |= (1<<5);
			while (1){
				//Blink LED indefinitely
				PORTB ^= (1<<5);
				_delay_ms(250);
			}
		}
	}
	qti_touchingBounds = 0;
	if ((PIND>>1)&1){
		// Set to 1 if front is touching
		qti_touchingBounds = 1;
	}else if ((PIND>>2)&1){
		// Set to -1 if back is touching
		qti_touchingBounds = -1;	
	}
}<commit_msg>Fixed motor control upon defeat to conform to new interface<commit_after>/* qti.c
 * 
 * Module contains everything needed to operate a PING sonar sensor.
 *
 * MAE3780 Mechatronics Final Project 2013
 * Cornell University
 * <NAME>, <NAME>, <NAME>
 */

#ifndef F_CPU
#define F_CPU 16000000UL
#endif

// Include standard headers
#include <avr/io.h>			// For general I/O
#include <util/delay.h>		// For delay
#include <avr/interrupt.h>	// For interrupts
#include <stdint.h>			// For data types

// Include local headers
#include "motor.h"			// Motor control to stop motors
#include "qti.h"			// Own header file

/* Connection Details
 * Pin	Sensor Placement
 * ---------------------
 * PD0	Center
 * PD1	Front
 * PD2	Back
 */

// Variable definitions
volatile int8_t qti_touchingBounds=0;

/* Begin Internal Functions Here
 * =============================
 *
 */

ISR(PCINT2_vect){
// ISR to detect out-of-bounds

	//If center QTI detects white 
	if ((PIND>>0)&1){
		_delay_us(500);
		//Check again after short wait
		if ((PIND>>0)&1){
			// Accept defeat
			
			// Turn Motors off
			motor_setSpeed(0,0);

			//Initialize LED
			DDRB |= (1<<5);
			while (1){
				//Blink LED indefinitely
				PORTB ^= (1<<5);
				_delay_ms(250);
			}
		}
	}
	qti_touchingBounds = 0;
	if ((PIND>>1)&1){
		// Set to 1 if front is touching
		qti_touchingBounds = 1;
	}else if ((PIND>>2)&1){
		// Set to -1 if back is touching
		qti_touchingBounds = -1;	
	}
}
{'fraction_non_alphanumeric': 0.16608269096005607, 'fraction_numerical': 0.03433777154870357, 'mean_word_length': 2.8270777479892764, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, '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': '24613', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1025, 'n_words': 304}