private void Key_Up(object sender, KeyRoutedEventArgs e) { if (_ezb != null) { if (e.Key.ToString() == "W") { BotMove.reverse(move_vec, _ezb); } else if (e.Key.ToString() == "S") { BotMove.forward(move_vec, _ezb); } else if (e.Key.ToString() == "A") { BotMove.right(move_vec, _ezb); } else if (e.Key.ToString() == "D") { BotMove.left(move_vec, _ezb); } else if (e.Key.ToString() == "U") { } else if (e.Key.ToString() == "I") { } else if (e.Key.ToString() == "O") { } else if (e.Key.ToString() == "P") { } } }
/* * Handler for Left Button */ private void Left_Btn_Click(object sender, RoutedEventArgs e) { if (_ezb != null) { BotMove.left(move_vec, _ezb); } }
private async void Key_Down(object sender, KeyRoutedEventArgs e) { int servo_speed = 5; if (_ezb != null) { if (e.Key.ToString() == "W") { BotMove.forward(move_vec, _ezb); } else if (e.Key.ToString() == "S") { BotMove.reverse(move_vec, _ezb); } else if (e.Key.ToString() == "A") { BotMove.left(move_vec, _ezb); } else if (e.Key.ToString() == "D") { BotMove.right(move_vec, _ezb); } else if (e.Key.ToString() == "U") //open LEFT { await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D12, EZ_B.Servo.SERVO_MIN, 0); } else if (e.Key.ToString() == "I") //close LEFT { //left claw await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D12, EZ_B.Servo.SERVO_CENTER, 0); } else if (e.Key.ToString() == "O") //close RIGHT { //right claw await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D16, EZ_B.Servo.SERVO_CENTER, 0); } else if (e.Key.ToString() == "P") //open RIGHT { //grab using right hand await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D16, EZ_B.Servo.SERVO_MIN, 0); } // neck nod movement else if (e.Key.ToString() == "J") //move neck to top pos { await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D9, 150, 3); } else if (e.Key.ToString() == "K") //move neck to center { await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D9, EZ_B.Servo.SERVO_CENTER, 3); } else if (e.Key.ToString() == "L") //move neck to down pos { await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D9, 30, 3); } //neck swivel movement else if (e.Key.ToString() == "Z") // move neck swivel left { await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D10, 150, servo_speed); } else if (e.Key.ToString() == "X") // move neck swivel center { await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D10, EZ_B.Servo.SERVO_CENTER, servo_speed); } else if (e.Key.ToString() == "C") // move neck swivel right { await _ezb.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D10, 30, servo_speed); } } }