<commit_before>Meteor.startup(function () {
	var SerialPort = serialport.SerialPort;
	var arduino = new SerialPort("/dev/ttyACM1", {
		baudrate: 9600
	});
	arduino.open(function(err) {
		if (err) {
			console.log("Failed to open: " + err);
		} else {
			console.log("Serial port open");
			Meteor.methods({
				writeData: function(velocity, y) {
					var num = 196 * (velocity === 0 ? 1 : 0) + y * 32 + (velocity < 0 ? 0 : 1) * 16 + Math.abs(velocity); 
					var buff = new Buffer(1);
					buff.writeUInt8(num, 0);
					console.log(buff);
					arduino.write(buff);
				}
			});
		}	
	});
});
<commit_msg>Added position method<commit_after>var VELOCITY_RATIO = 200;
var xPrev, yPrev, timePrev;

Meteor.startup(function () {
	var SerialPort = serialport.SerialPort;
	var arduino = new SerialPort("/dev/ttyACM0", {
		baudrate: 9600
	});
	arduino.open(function(err) {
		if (err) {
			console.log("Failed to open: " + err);
		} else {
			console.log("Serial port open");
			Meteor.methods({
				writeData: function(velocity, y) {
					var num = 196 * (velocity === 0 ? 1 : 0) + y * 32 + (velocity < 0 ? 0 : 1) * 16 + Math.abs(velocity); 
					var buff = new Buffer(1);
					buff.writeUInt8(num, 0);
					console.log(buff);
					arduino.write(buff);
				},
				
				logPosition: function(x, y) {
					var time = new Date().getMilliseconds();
					if (xPrev != undefined && yPrev != undefined && timePrev != undefined) {
						var xVelocity = VELOCITY_RATIO * Math.abs(x - xPrev) / (time - timePrev);
						if (xVelocity < 0) xVelocity = Math.max(xVelocity, -15);
						else xVelocity = Math.min(xVelocity, 15);
						var yVelocity = Math.min(15, VELOCITY_RATIO * Math.abs(y - yPrev) / (time - timePrev));
						if (yVelocity < 0) yVelocity = Math.max(yVelocity, -15);
						else yVelocity = Math.min(yVelocity, 15);
						console.log("X Velocity: " + xVelocity);
						console.log("Y Velocity: " + yVelocity);
						Meteor.call('writeData', xVelocity, 0);
						Meteor.call('writeData', yVelocity, 1);
					}
					xPrev = x;
					yPrev = y;
					timePrev = time;
				}
			});
		}	
	});
});

{'fraction_non_alphanumeric': 0.16362763915547024, 'fraction_numerical': 0.02831094049904031, 'mean_word_length': 2.868274582560297, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7549023', 'n_tokens_mistral': 986, 'n_tokens_neox': 761, 'n_words': 172}