added calibration and thresholding to gyro code