public void HandleButtonPresses(string[] workingString) { bool button1Pressed = false; bool button2Pressed = false; bool button3Pressed = false; if (int.Parse(workingString[3]) > 0) { button1Pressed = true; } if (int.Parse(workingString[4]) > 0) { //Debug.Log("1 " + workingString[1]); //Debug.Log("2 " + workingString[2]); //Debug.Log(workingString[3]); //Debug.Log("4 " + workingString[4]); button2Pressed = true; } if (int.Parse(workingString[5]) > 0) { button3Pressed = true; } SerialPortEventManager.ButtonPress("button1", button1Pressed); SerialPortEventManager.ButtonPress("button2", button2Pressed); SerialPortEventManager.ButtonPress("button3", button3Pressed); }
//I set this axis as the base axis, then I just need to know how much rotation from that axis this experiences. I need to treat anything over 180 as negative value private void TellStandMowerRotation() { if (this.gameObject.activeSelf && !mLockControls) { Vector3 tempVector = Vector3.zero; tempVector.x = ConvertToRotationAmount(transform.rotation.eulerAngles.x); tempVector.y = ConvertToRotationAmount(transform.rotation.eulerAngles.y); tempVector.z = ConvertToRotationAmount(transform.rotation.eulerAngles.z); SerialPortEventManager.ChangeRotation(tempVector, mIsIMUAvailable); } }
void Update() { if (mIsActiveMenu) { if (mButtons.Count > 0) { if (mActionButtons[2]) //TODO move this assignement to higher up for cleaner code { SelectCurrentButton(); } if (mLeftAxisValue != 0) { if (mLeftAxisValue > 0) { if (Time.time >= mNextSelectionTime) { mCurrentButtonInt--; ChangeActiveButton(); } } else if (mLeftAxisValue < 0) { if (Time.time >= mNextSelectionTime) { mCurrentButtonInt++; ChangeActiveButton(); } } } } if (mLocksControlWhenActive) { SerialPortEventManager.ChangeRotation(Vector3.zero, false); } } }
public void ReadArduinoOutput() { //Format should arrive as "H,0.00,0.00,0,0,0,F" string[] workingString = mNewDataString.Split(','); if (workingString.Length == 7) { //workingString = workingString.Substring(2, workingString.Length - 3); //string tempString = workingString.Substring(10, 1); //Debug.Log(tempString); float rightLMB = float.Parse(workingString[1]); float leftLMB = float.Parse(workingString[2]); if ((-mXboxDeadZone <= rightLMB) && (rightLMB <= mXboxDeadZone)) { rightLMB = 0; } if ((-mXboxDeadZone <= leftLMB) && (leftLMB < mXboxDeadZone)) { leftLMB = 0; } SerialPortEventManager.LMBUpdated("rightLMB", rightLMB); SerialPortEventManager.LMBUpdated("leftLMB", leftLMB); HandleButtonPresses(workingString); } else { Debug.Log(workingString[0] + " , " + workingString[2]); Debug.LogError("Arduino Format Wrong or null:" + mNewDataString.Length); } }